-
- Downloads
fortran: Fix specification expression error with dummy procedures [PR111781]
This fixes a spurious invalid variable in specification expression error. The error was caused on the testcase from the PR by two different bugs. First, the call to is_parent_of_current_ns was unable to recognize correct host association and returned false. Second, an ad-hoc condition coming next was using a global variable previously improperly restored to false (instead of restoring it to its initial value). The latter happened on the testcase because one dummy argument was a procedure, and checking that argument what causing a check of all its arguments with the (improper) reset of the flag at the end, and that preceded the check of the next argument. For the first bug, the wrong result of is_parent_of_current_ns is fixed by correcting the namespaces that function deals with, both the one passed as argument and the current one tracked in the gfc_current_ns global. Two new functions are introduced to select the right namespace. Regarding the second bug, the problematic condition is removed, together with the formal_arg_flag associated with it. Indeed, that condition was (wrongly) allowing local variables to be used in array bounds of dummy arguments. PR fortran/111781 gcc/fortran/ChangeLog: * symbol.cc (gfc_get_procedure_ns, gfc_get_spec_ns): New functions. * gfortran.h (gfc_get_procedure_ns, gfc_get_spec ns): Declare them. (gfc_is_formal_arg): Remove. * expr.cc (check_restricted): Remove special case allowing local variable in dummy argument bound expressions. Use gfc_get_spec_ns to get the right namespace. * resolve.cc (gfc_is_formal_arg, formal_arg_flag): Remove. (gfc_resolve_formal_arglist): Set gfc_current_ns. Quit loop and restore gfc_current_ns instead of early returning. (resolve_symbol): Factor common array spec resolution code to... (resolve_symbol_array_spec): ... this new function. Additionnally set and restore gfc_current_ns. gcc/testsuite/ChangeLog: * gfortran.dg/spec_expr_8.f90: New test. * gfortran.dg/spec_expr_9.f90: New test.
Showing
- gcc/fortran/expr.cc 1 addition, 7 deletionsgcc/fortran/expr.cc
- gcc/fortran/gfortran.h 3 additions, 1 deletiongcc/fortran/gfortran.h
- gcc/fortran/resolve.cc 35 additions, 42 deletionsgcc/fortran/resolve.cc
- gcc/fortran/symbol.cc 58 additions, 0 deletionsgcc/fortran/symbol.cc
- gcc/testsuite/gfortran.dg/spec_expr_8.f90 24 additions, 0 deletionsgcc/testsuite/gfortran.dg/spec_expr_8.f90
- gcc/testsuite/gfortran.dg/spec_expr_9.f90 19 additions, 0 deletionsgcc/testsuite/gfortran.dg/spec_expr_9.f90
Loading
Please register or sign in to comment