From ca39e6f200109cd52ad6102a6b272cc95f6f9aea Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Fri, 5 Oct 2007 12:33:07 +0000 Subject: gfortran.h (gfc_get_data_variable, [...]): Move to decl.c. * gfortran.h (gfc_get_data_variable, gfc_get_data_value, gfc_get_data): Move to decl.c. (global_used): Rename into gfc_global_used. (gfc_formalize_init_value, gfc_get_section_index, gfc_assign_data_value, gfc_assign_data_value_range, gfc_advance_section): Move to data.h. (gfc_set_in_match_data): Remove. * decl.c (gfc_get_data_variable, gfc_get_data_value, gfc_get_data): Move here. (gfc_set_in_match_data): Rename into set_in_match_data. (gfc_match_data): Likewise. (add_global_entry): Rename global_used into gfc_global_used. * data.c: Include data.h. * trans.h (gfc_todo_error): Remove. * trans-array.c (gfc_trans_array_constructor, gfc_conv_ss_startstride, gfc_conv_loop_setup): Change gfc_todo_error into assertions. * resolve.c (resolve_global_procedure): Rename global_used into gfc_global_used. * parse.c (gfc_global_used, parse_module, add_global_procedure, add_global_program): Likewise. * trans-intrinsic.c (gfc_walk_intrinsic_function): Rename global_used into gfc_global_used. * Make-lang.in: Add dependencies on fortran/data.h. * data.h: New file. From-SVN: r129034 --- gcc/fortran/ChangeLog | 28 ++++++++++++++++++++++++++++ gcc/fortran/Make-lang.in | 3 ++- gcc/fortran/data.c | 1 + gcc/fortran/data.h | 24 ++++++++++++++++++++++++ gcc/fortran/decl.c | 20 ++++++++++++++------ gcc/fortran/gfortran.h | 14 +------------- gcc/fortran/parse.c | 10 +++++----- gcc/fortran/resolve.c | 3 ++- gcc/fortran/trans-array.c | 17 ++++++++++------- gcc/fortran/trans-intrinsic.c | 7 +++---- gcc/fortran/trans.h | 4 ---- 11 files changed, 90 insertions(+), 41 deletions(-) create mode 100644 gcc/fortran/data.h (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 488d280..834a5b9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,31 @@ +2007-10-05 Francois-Xavier Coudert + + * gfortran.h (gfc_get_data_variable, gfc_get_data_value, + gfc_get_data): Move to decl.c. + (global_used): Rename into gfc_global_used. + (gfc_formalize_init_value, gfc_get_section_index, + gfc_assign_data_value, gfc_assign_data_value_range, + gfc_advance_section): Move to data.h. + (gfc_set_in_match_data): Remove. + * decl.c (gfc_get_data_variable, gfc_get_data_value, + gfc_get_data): Move here. + (gfc_set_in_match_data): Rename into set_in_match_data. + (gfc_match_data): Likewise. + (add_global_entry): Rename global_used into gfc_global_used. + * data.c: Include data.h. + * trans.h (gfc_todo_error): Remove. + * trans-array.c (gfc_trans_array_constructor, + gfc_conv_ss_startstride, gfc_conv_loop_setup): Change + gfc_todo_error into assertions. + * resolve.c (resolve_global_procedure): Rename global_used into + gfc_global_used. + * parse.c (gfc_global_used, parse_module, add_global_procedure, + add_global_program): Likewise. + * trans-intrinsic.c (gfc_walk_intrinsic_function): Rename + global_used into gfc_global_used. + * Make-lang.in: Add dependencies on fortran/data.h. + * data.h: New file. + 2007-10-04 Francois-Xavier Coudert PR fortran/33529 diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in index 7b4b4c7..16d4d35 100644 --- a/gcc/fortran/Make-lang.in +++ b/gcc/fortran/Make-lang.in @@ -324,5 +324,6 @@ fortran/trans-intrinsic.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \ gt-fortran-trans-intrinsic.h fortran/dependency.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h fortran/trans-common.o: $(GFORTRAN_TRANS_DEPS) $(TARGET_H) $(RTL_H) -fortran/resolve.o: fortran/dependency.h +fortran/resolve.o: fortran/dependency.h fortran/data.h +fortran/data.o: fortran/data.h fortran/options.o: $(PARAMS_H) $(TARGET_H) diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c index 14c1b1a..59ac5e9 100644 --- a/gcc/fortran/data.c +++ b/gcc/fortran/data.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "gfortran.h" +#include "data.h" static void formalize_init_expr (gfc_expr *); diff --git a/gcc/fortran/data.h b/gcc/fortran/data.h new file mode 100644 index 0000000..5f89d98 --- /dev/null +++ b/gcc/fortran/data.h @@ -0,0 +1,24 @@ +/* Header for functions resolving DATA statements. + Copyright (C) 2007 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +void gfc_formalize_init_value (gfc_symbol *); +void gfc_get_section_index (gfc_array_ref *, mpz_t *, mpz_t *); +try gfc_assign_data_value (gfc_expr *, gfc_expr *, mpz_t); +void gfc_assign_data_value_range (gfc_expr *, gfc_expr *, mpz_t, mpz_t); +void gfc_advance_section (mpz_t *, gfc_array_ref *, mpz_t *); diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index d0eb0ef..d2c94a1 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -25,6 +25,14 @@ along with GCC; see the file COPYING3. If not see #include "match.h" #include "parse.h" + +/* Macros to access allocate memory for gfc_data_variable, + gfc_data_value and gfc_data. */ +#define gfc_get_data_variable() gfc_getmem (sizeof (gfc_data_variable)) +#define gfc_get_data_value() gfc_getmem (sizeof (gfc_data_value)) +#define gfc_get_data() gfc_getmem( sizeof (gfc_data)) + + /* This flag is set if an old-style length selector is matched during a type-declaration statement. */ @@ -92,8 +100,8 @@ gfc_in_match_data (void) return in_match_data; } -void -gfc_set_in_match_data (bool set_value) +static void +set_in_match_data (bool set_value) { in_match_data = set_value; } @@ -496,7 +504,7 @@ gfc_match_data (void) gfc_data *new; match m; - gfc_set_in_match_data (true); + set_in_match_data (true); for (;;) { @@ -520,7 +528,7 @@ gfc_match_data (void) gfc_match_char (','); /* Optional comma */ } - gfc_set_in_match_data (false); + set_in_match_data (false); if (gfc_pure (NULL)) { @@ -531,7 +539,7 @@ gfc_match_data (void) return MATCH_YES; cleanup: - gfc_set_in_match_data (false); + set_in_match_data (false); gfc_free_data (new); return MATCH_ERROR; } @@ -4256,7 +4264,7 @@ add_global_entry (const char *name, int sub) if (s->defined || (s->type != GSYM_UNKNOWN && s->type != (sub ? GSYM_SUBROUTINE : GSYM_FUNCTION))) - global_used(s, NULL); + gfc_global_used(s, NULL); else { s->type = sub ? GSYM_SUBROUTINE : GSYM_FUNCTION; diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 5495ae7..203e1e7 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1793,10 +1793,6 @@ typedef struct gfc_data } gfc_data; -#define gfc_get_data_variable() gfc_getmem(sizeof(gfc_data_variable)) -#define gfc_get_data_value() gfc_getmem(sizeof(gfc_data_value)) -#define gfc_get_data() gfc_getmem(sizeof(gfc_data)) - /* Structure for holding compile options */ typedef struct @@ -1909,16 +1905,8 @@ extern iterator_stack *iter_stack; /************************ Function prototypes *************************/ -/* data.c */ -void gfc_formalize_init_value (gfc_symbol *); -void gfc_get_section_index (gfc_array_ref *, mpz_t *, mpz_t *); -try gfc_assign_data_value (gfc_expr *, gfc_expr *, mpz_t); -void gfc_assign_data_value_range (gfc_expr *, gfc_expr *, mpz_t, mpz_t); -void gfc_advance_section (mpz_t *, gfc_array_ref *, mpz_t *); - /* decl.c */ bool gfc_in_match_data (void); -void gfc_set_in_match_data (bool); /* scanner.c */ void gfc_scanner_done_1 (void); @@ -2371,7 +2359,7 @@ void gfc_show_typespec (gfc_typespec *); /* parse.c */ try gfc_parse_file (void); -void global_used (gfc_gsymbol *, locus *); +void gfc_global_used (gfc_gsymbol *, locus *); /* dependency.c */ int gfc_dep_compare_expr (gfc_expr *, gfc_expr *); diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 14acb86..f357c7a 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -3088,7 +3088,7 @@ done: something else. */ void -global_used (gfc_gsymbol *sym, locus *where) +gfc_global_used (gfc_gsymbol *sym, locus *where) { const char *name; @@ -3154,7 +3154,7 @@ parse_block_data (void) s = gfc_get_gsymbol (gfc_new_block->name); if (s->defined || (s->type != GSYM_UNKNOWN && s->type != GSYM_BLOCK_DATA)) - global_used(s, NULL); + gfc_global_used(s, NULL); else { s->type = GSYM_BLOCK_DATA; @@ -3185,7 +3185,7 @@ parse_module (void) s = gfc_get_gsymbol (gfc_new_block->name); if (s->defined || (s->type != GSYM_UNKNOWN && s->type != GSYM_MODULE)) - global_used(s, NULL); + gfc_global_used(s, NULL); else { s->type = GSYM_MODULE; @@ -3232,7 +3232,7 @@ add_global_procedure (int sub) if (s->defined || (s->type != GSYM_UNKNOWN && s->type != (sub ? GSYM_SUBROUTINE : GSYM_FUNCTION))) - global_used(s, NULL); + gfc_global_used(s, NULL); else { s->type = sub ? GSYM_SUBROUTINE : GSYM_FUNCTION; @@ -3254,7 +3254,7 @@ add_global_program (void) s = gfc_get_gsymbol (gfc_new_block->name); if (s->defined || (s->type != GSYM_UNKNOWN && s->type != GSYM_PROGRAM)) - global_used(s, NULL); + gfc_global_used(s, NULL); else { s->type = GSYM_PROGRAM; diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 536b3c5..452a8d8 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "bitmap.h" #include "arith.h" /* For gfc_compare_expr(). */ #include "dependency.h" +#include "data.h" /* Types used in equivalence statements. */ @@ -1359,7 +1360,7 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, int sub) gsym = gfc_get_gsymbol (sym->name); if ((gsym->type != GSYM_UNKNOWN && gsym->type != type)) - global_used (gsym, where); + gfc_global_used (gsym, where); if (gsym->type == GSYM_UNKNOWN) { diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 64a62db..2edc95b 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -1636,8 +1636,10 @@ gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss) if (ss->expr->ts.type == BT_CHARACTER) { bool const_string = get_array_ctor_strlen (&loop->pre, c, &ss->string_length); - if (!ss->string_length) - gfc_todo_error ("complex character array constructors"); + + /* Complex character array constructors should have been taken care of + and not end up here. */ + gcc_assert (ss->string_length); ss->expr->ts.cl->backend_decl = ss->string_length; @@ -2787,9 +2789,9 @@ gfc_conv_ss_startstride (gfc_loopinfo * loop) } } - if (loop->dimen == 0) - gfc_todo_error ("Unable to determine rank of expression"); - + /* We should have determined the rank of the expression by now. If + not, that's bad news. */ + gcc_assert (loop->dimen != 0); /* Loop over all the SS in the chain. */ for (ss = loop->ss; ss != gfc_ss_terminator; ss = ss->loop_chain) @@ -3280,8 +3282,9 @@ gfc_conv_loop_setup (gfc_loopinfo * loop) loopspec[n] = ss; */ } - if (!loopspec[n]) - gfc_todo_error ("Unable to find scalarization loop specifier"); + /* We should have found the scalarization loop specifier. If not, + that's bad news. */ + gcc_assert (loopspec[n]); info = &loopspec[n]->data.info; diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index cf7d1e1..7cc0c6f 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -4269,10 +4269,9 @@ gfc_walk_intrinsic_function (gfc_ss * ss, gfc_expr * expr, default: /* This probably meant someone forgot to add an intrinsic to the above - list(s) when they implemented it, or something's gone horribly wrong. - */ - gfc_todo_error ("Scalarization of non-elemental intrinsic: %s", - expr->value.function.name); + list(s) when they implemented it, or something's gone horribly + wrong. */ + gcc_unreachable (); } } diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index 7bff3aa..eafd280 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -632,10 +632,6 @@ struct lang_decl GTY(()) #define GFC_TYPE_ARRAY_DATAPTR_TYPE(node) \ (TYPE_LANG_SPECIFIC(node)->dataptr_type) -/* I changed this from sorry(...) because it should not return. */ -/* TODO: Remove gfc_todo_error before releasing version 1.0. */ -#define gfc_todo_error(args...) fatal_error("gfc_todo: Not Implemented: " args) - /* Build an expression with void type. */ #define build1_v(code, arg) build1(code, void_type_node, arg) #define build2_v(code, arg1, arg2) build2(code, void_type_node, \ -- cgit v1.1