[Bug fortran/25090] Bad automatic character length
--- Comment #7 from pault at gcc dot gnu dot org 2006-06-11 22:32 --- Subject: Bug 25090 Author: pault Date: Sun Jun 11 22:32:26 2006 New Revision: 114551 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=114551 Log: 2006-06-12 Paul Thomas [EMAIL PROTECTED] PR fortran/24558 PR fortran/20877 PR fortran/25047 * decl.c (get_proc_name): Add new argument to flag that a module function entry is being treated. If true, correct error condition, add symtree to module namespace and add a module procedure. (gfc_match_function_decl, gfc_match_entry, gfc_match_subroutine): Use the new argument in calls to get_proc_name. * resolve.c (resolve_entries): ENTRY symbol reference to to master entry namespace if a module function. * trans-decl.c (gfc_create_module_variable): Return if the symbol is an entry. PR fortran/23091 * resolve.c (resolve_fl_variable): Error if an automatic object has the SAVE attribute. PR fortran/24168 * expr.c (simplify_intrinsic_op): Transfer the rank and the locus to the simplified expression. PR fortran/25090 PR fortran/25058 * gfortran.h : Add int entry_id to gfc_symbol. * resolve.c : Add static variables current_entry_id and specification_expr. (resolve_variable): During code resolution, check if a reference to a dummy variable in an executable expression is preceded by its appearance as a parameter in an entry. Likewise check its specification expressions. (resolve_code): Update current_entry_id on EXEC_ENTRY. (resolve_charlen, resolve_fl_variable): Set and reset specifiaction_expr. (is_non_constant_shape_array): Do not return on detection of a variable but continue to resolve all the expressions. (resolve_codes): set current_entry_id to an out of range value. 2006-06-12 Paul Thomas [EMAIL PROTECTED] PR fortran/24558 * gfortran.dg/entry_6.f90: New test. PR fortran/20877 PR fortran/25047 * gfortran.dg/entry_7.f90: New test. PR fortran/23091 * gfortran.dg/saved_automatic_1.f90: New test. PR fortran/24168 * gfortran.dg/array_simplify_1.f90: New test. PR fortran/25090 * gfortran.dg/entry_dummy_ref_1.f90: New test. PR fortran/25058 * gfortran.dg/entry_dummy_ref_2.f90: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/array_simplify_1.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/entry_6.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/entry_7.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/entry_dummy_ref_1.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/entry_dummy_ref_2.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/saved_automatic_1.f90 Modified: branches/gcc-4_1-branch/gcc/fortran/ChangeLog branches/gcc-4_1-branch/gcc/fortran/decl.c branches/gcc-4_1-branch/gcc/fortran/expr.c branches/gcc-4_1-branch/gcc/fortran/gfortran.h branches/gcc-4_1-branch/gcc/fortran/resolve.c branches/gcc-4_1-branch/gcc/fortran/trans-decl.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25090
[Bug fortran/25090] Bad automatic character length
--- Comment #8 from pault at gcc dot gnu dot org 2006-06-11 22:37 --- Cracked on trunk and 4.1. Paul -- pault at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25090
[Bug fortran/25090] Bad automatic character length
--- Comment #6 from pault at gcc dot gnu dot org 2006-06-07 07:20 --- Subject: Bug 25090 Author: pault Date: Wed Jun 7 07:20:39 2006 New Revision: 114461 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=114461 Log: 2006-06-07 Paul Thomas [EMAIL PROTECTED] PR fortran/23091 * resolve.c (resolve_fl_variable): Error if an automatic object has the SAVE attribute. PR fortran/24168 * expr.c (simplify_intrinsic_op): Transfer the rank and the locus to the simplified expression. PR fortran/25090 PR fortran/25058 * gfortran.h : Add int entry_id to gfc_symbol. * resolve.c : Add static variables current_entry_id and specification_expr. (resolve_variable): During code resolution, check if a reference to a dummy variable in an executable expression is preceded by its appearance as a parameter in an entry. Likewise check its specification expressions. (resolve_code): Update current_entry_id on EXEC_ENTRY. (resolve_charlen, resolve_fl_variable): Set and reset specifiaction_expr. (is_non_constant_shape_array): Do not return on detection of a variable but continue to resolve all the expressions. (resolve_codes): set current_entry_id to an out of range value. 2006-06-07 Paul Thomas [EMAIL PROTECTED] PR fortran/23091 * gfortran.dg/saved_automatic_1.f90: New test. PR fortran/24168 * gfortran.dg/array_simplify_1.f90: New test. PR fortran/25090 * gfortran.dg/entry_dummy_ref_1.f90: New test. PR fortran/25058 * gfortran.dg/entry_dummy_ref_2.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/array_simplify_1.f90 trunk/gcc/testsuite/gfortran.dg/entry_dummy_ref_1.f90 trunk/gcc/testsuite/gfortran.dg/entry_dummy_ref_2.f90 trunk/gcc/testsuite/gfortran.dg/saved_automatic_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/expr.c trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25090
[Bug fortran/25090] Bad automatic character length
--- Comment #5 from pault at gcc dot gnu dot org 2006-05-21 07:35 --- Subject: Bug 25090 Author: pault Date: Sun May 21 07:35:05 2006 New Revision: 113949 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=113949 Log: 2006-05-21 Paul Thomas [EMAIL PROTECTED] PR fortran/25746 * interface.c (gfc_extend_assign): Use new code EXEC_ASSIGN_CALL. * gfortran.h : Put EXEC_ASSIGN_CALL in enum. * trans-stmt.c (gfc_conv_elemental_dependencies): New function. (gfc_trans_call): Call it. Add new boolian argument to flag need for dependency checking. Assert intent OUT and IN for arg1 and arg2. (gfc_trans_forall_1): Use new code EXEC_ASSIGN_CALL. trans-stmt.h : Modify prototype of gfc_trans_call. trans.c (gfc_trans_code): Add call for EXEC_ASSIGN_CALL. st.c (gfc_free_statement): Free actual for EXEC_ASSIGN_CALL. * dependency.c (gfc_check_fncall_dependency): Don't check other against itself. PR fortran/25090 * resolve.c : Remove resolving_index_expr. (entry_parameter): Remove. (gfc_resolve_expr, resolve_charlen, resolve_fl_variable): Remove calls to entry_parameter and references to resolving_index_expr. PR fortran/27584 * check.c (gfc_check_associated): Replace NULL assert with an error message, since it is possible to generate bad code that has us fall through to here.. PR fortran/19015 * iresolve.c (maxloc, minloc): If DIM is not present, pass the rank of ARRAY as the shape of the result. Otherwise, pass the shape of ARRAY, less the dimension DIM. (maxval, minval): The same, when DIM is present, otherwise no change. 2006-05-21 Paul Thomas [EMAIL PROTECTED] PR fortran/25746 * gfortran.dg/elemental_subroutine_3.f90: New test. PR fortran/25090 * gfortran.dg/entry_dummy_ref_1.f90: Remove. PR fortran/27584 * gfortran.dg/associated_target_1.f90: New test. PR fortran/19015 * gfortran.dg/maxloc_shape_1.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/associated_target_1.f90 trunk/gcc/testsuite/gfortran.dg/elemental_subroutine_3.f90 trunk/gcc/testsuite/gfortran.dg/maxloc_shape_1.f90 Removed: trunk/gcc/testsuite/gfortran.dg/entry_dummy_ref_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/check.c trunk/gcc/fortran/dependency.c trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/interface.c trunk/gcc/fortran/iresolve.c trunk/gcc/fortran/resolve.c trunk/gcc/fortran/st.c trunk/gcc/fortran/trans-stmt.c trunk/gcc/fortran/trans-stmt.h trunk/gcc/fortran/trans.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25090
[Bug fortran/25090] Bad automatic character length
--- Comment #4 from paul dot richard dot thomas at cea dot fr 2006-05-18 15:43 --- Created an attachment (id=11486) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11486action=view) A patch to the patch This fixes the problem with the patch, applied to trunk, that was reported by Grigory Zagorodnev at http://gcc.gnu.org/ml/fortran/2006-05/msg00233.html It needs tidying up before submission but seems to do what is needed. It also cures pr25058. Thanks, Grigory. Paul -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25090
[Bug fortran/25090] Bad automatic character length
--- Comment #2 from pault at gcc dot gnu dot org 2006-05-15 17:16 --- Subject: Bug 25090 Author: pault Date: Mon May 15 17:16:26 2006 New Revision: 113796 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=113796 Log: 2006-05-15 Paul Thomas [EMAIL PROTECTED] PR fortran/25090 * resolve.c: Static resolving_index_expr initialized. (entry_parameter): New function to emit errors for variables that are not entry parameters. (gfc_resolve_expr): Call entry_parameter, when resolving variables, if the namespace has entries and resolving_index_expr is set. (resolve_charlen): Set resolving_index_expr before the call to resolve_index_expr and reset it afterwards. (resolve_fl_variable): The same before and after the call to is_non_constant_shape_array, which ultimately makes a call to gfc_resolve_expr. PR fortran/25082 * resolve.c (resolve_code): Add error condition that the return expression must be scalar. PR fortran/24711 * matchexp.c (gfc_get_parentheses): New function. (match_primary): Remove inline code and call above. * gfortran.h: Provide prototype for gfc_get_parentheses. * resolve.c (resolve_array_ref): Call the above, when start is a derived type variable array reference. 2006-05-15 Paul Thomas [EMAIL PROTECTED] PR fortran/25090 * gfortran.dg/entry_dummy_ref_1.f90: New test. PR fortran/25082 * gfortran.dg/scalar_return_1.f90: New test. PR fortran/24711 * gfortran.dg/derived_comp_array_ref_1.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/derived_comp_array_ref_1.f90 trunk/gcc/testsuite/gfortran.dg/entry_dummy_ref_1.f90 trunk/gcc/testsuite/gfortran.dg/scalar_return_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/matchexp.c trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25090
[Bug fortran/25090] Bad automatic character length
--- Comment #3 from patchapp at dberlin dot org 2006-05-15 19:43 --- Subject: Bug number PR25090 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-05/msg00554.html -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25090
[Bug fortran/25090] Bad automatic character length
--- Comment #1 from paul dot richard dot thomas at cea dot fr 2006-05-11 10:22 --- The following patch fixes this bug. It makes use of existing calls to gfc_resolve_expr, whilst resolving specification expressions, to check that variables used are parameters of each and every entry. Since existing code is recycled and the test in gfc_resolve_epr is pretty exclusive, the load on resolution is negligible. I will submit asap. Paul Index: gcc/fortran/resolve.c === --- gcc/fortran/resolve.c (révision 113111) +++ gcc/fortran/resolve.c (copie de travail) @@ -60,6 +60,9 @@ resets the flag each time that it is read. */ static int formal_arg_flag = 0; +/* True if we are resolving a specification expression. */ +static int resolving_index_expr = 0; + int gfc_is_formal_arg (void) { @@ -2623,6 +2639,50 @@ } +/* Emits an error if the expression is a variable that is + not a parameter in all entry formal argument lists for + the namespace. */ + +static void +entry_parameter (gfc_expr *e) +{ + gfc_symbol *sym, *esym; + gfc_entry_list *entry; + gfc_formal_arglist *f; + bool p; + + if (e-expr_type != EXPR_VARIABLE) +return; + + sym = e-symtree-n.sym; + if (sym-ns-entries +!sym-attr.use_assoc +sym-attr.dummy +sym-ns == gfc_current_ns) +{ + entry = sym-ns-entries; + for (; entry; entry = entry-next) + { + esym = entry-sym; + p = false; + f = esym-formal; + for (; f !p; f = f-next) + { + if (f-sym f-sym-name +sym-name == f-sym-name) + { + p = true; + } + } + if (!p) + gfc_error (%s at %L must be a parameter of the entry at %L, + sym-name, e-where, esym-declared_at); + } +} + return; +} + + /* Resolve an expression. That is, make sure that types of operands agree with their operators, intrinsic operators are converted to function calls for overloaded types and unresolved function references are resolved. */ @@ -2647,6 +2707,10 @@ case EXPR_VARIABLE: t = resolve_variable (e); + + if (gfc_current_ns-entries resolving_index_expr) + entry_parameter (e); + if (t == SUCCESS) expression_rank (e); break; @@ -4597,7 +4661,6 @@ static try resolve_index_expr (gfc_expr * e) { - if (gfc_resolve_expr (e) == FAILURE) return FAILURE; @@ -4620,9 +4683,12 @@ cl-resolved = 1; + resolving_index_expr = 1; + if (resolve_index_expr (cl-length) == FAILURE) return FAILURE; + resolving_index_expr = 0; return SUCCESS; } @@ -4709,20 +4775,29 @@ if (resolve_fl_var_and_proc (sym, mp_flag) == FAILURE) return FAILURE; - /* The shape of a main program or module array needs to be constant. */ - if (sym-ns-proc_name -(sym-ns-proc_name-attr.flavor == FL_MODULE -|| sym-ns-proc_name-attr.is_main_program) -!sym-attr.use_assoc + /* Set this flag to check that variables are parameters of all entries. + This check is effected by the call to gfc_resolve_expr through + is_non_contant_shape_array. */ + resolving_index_expr = 1; + + if (!sym-attr.use_assoc !sym-attr.allocatable !sym-attr.pointer is_non_constant_shape_array (sym)) { - gfc_error (The module or main program array '%s' at %L must -have constant shape, sym-name, sym-declared_at); - return FAILURE; + /* The shape of a main program or module array needs to be constant. */ + if (sym-ns-proc_name + (sym-ns-proc_name-attr.flavor == FL_MODULE + || sym-ns-proc_name-attr.is_main_program)) + { + gfc_error (The module or main program array '%s' at %L must + have constant shape, sym-name, sym-declared_at); + return FAILURE; + } } + resolving_index_expr = 0; + if (sym-ts.type == BT_CHARACTER) { /* Make sure that character string variables with assumed length are -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25090