diff options
author | Janus Weil <janus@gcc.gnu.org> | 2016-12-12 19:54:54 +0100 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2016-12-12 19:54:54 +0100 |
commit | 068b961b6a5ad37898cee76ce0e80ef46001eb03 (patch) | |
tree | 94f26051c1bbc2bd927fc10c86cdce7e02428131 | |
parent | e4d604062535264fd7973c29f3343d1e51951437 (diff) | |
download | gcc-068b961b6a5ad37898cee76ce0e80ef46001eb03.zip gcc-068b961b6a5ad37898cee76ce0e80ef46001eb03.tar.gz gcc-068b961b6a5ad37898cee76ce0e80ef46001eb03.tar.bz2 |
re PR fortran/78392 (ICE in gfc_trans_auto_array_allocation, at fortran/trans-array.c:5979)
2016-12-12 Janus Weil <janus@gcc.gnu.org>
PR fortran/78392
* expr.c (gfc_is_constant_expr): Specification functions are not
compile-time constants. Update documentation (add reference to F08
standard), add a FIXME.
(external_spec_function): Add reference to F08 standard.
* resolve.c (resolve_fl_variable): Ditto.
2016-12-12 Janus Weil <janus@gcc.gnu.org>
PR fortran/78392
* gfortran.dg/constant_shape.f90: New test case.
From-SVN: r243580
-rw-r--r-- | gcc/fortran/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fortran/expr.c | 28 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/constant_shape.f90 | 20 |
5 files changed, 41 insertions, 25 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1597a89..7a47db2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2016-12-12 Janus Weil <janus@gcc.gnu.org> + + PR fortran/78392 + * expr.c (gfc_is_constant_expr): Specification functions are not + compile-time constants. Update documentation (add reference to F08 + standard), add a FIXME. + (external_spec_function): Add reference to F08 standard. + * resolve.c (resolve_fl_variable): Ditto. + 2016-12-10 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/78226 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 3464a20..c4a6ae1 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -881,15 +881,15 @@ done: } -/* Function to determine if an expression is constant or not. This - function expects that the expression has already been simplified. */ +/* Determine if an expression is constant in the sense of F08:7.1.12. + * This function expects that the expression has already been simplified. + * FIXME: Return a bool, not an int. */ int gfc_is_constant_expr (gfc_expr *e) { gfc_constructor *c; gfc_actual_arglist *arg; - gfc_symbol *sym; if (e == NULL) return 1; @@ -918,25 +918,6 @@ gfc_is_constant_expr (gfc_expr *e) return 0; } - /* Specification functions are constant. */ - /* F95, 7.1.6.2; F2003, 7.1.7 */ - sym = NULL; - if (e->symtree) - sym = e->symtree->n.sym; - if (e->value.function.esym) - sym = e->value.function.esym; - - if (sym - && sym->attr.function - && sym->attr.pure - && !sym->attr.intrinsic - && !sym->attr.recursive - && sym->attr.proc != PROC_INTERNAL - && sym->attr.proc != PROC_ST_FUNCTION - && sym->attr.proc != PROC_UNKNOWN - && gfc_sym_get_dummy_args (sym) == NULL) - return 1; - if (e->value.function.isym && (e->value.function.isym->elemental || e->value.function.isym->pure @@ -2739,7 +2720,8 @@ restricted_args (gfc_actual_arglist *a) /************* Restricted/specification expressions *************/ -/* Make sure a non-intrinsic function is a specification function. */ +/* Make sure a non-intrinsic function is a specification function, + * see F08:7.1.11.5. */ static bool external_spec_function (gfc_expr *e) diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index c7d872c..ece4d75 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11825,8 +11825,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag) && !sym->attr.pointer && is_non_constant_shape_array (sym)) { - /* The shape of a main program or module array needs to be - constant. */ + /* F08:C541. The shape of an array defined in a main program or module + * needs to be constant. */ gfc_error ("The module or main program array %qs at %L must " "have constant shape", sym->name, &sym->declared_at); specification_expr = saved_specification_expr; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6657b5..d333de1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-12 Janus Weil <janus@gcc.gnu.org> + + PR fortran/78392 + * gfortran.dg/constant_shape.f90: New test case. + 2016-12-12 Marek Polacek <polacek@redhat.com> PR c++/78647 diff --git a/gcc/testsuite/gfortran.dg/constant_shape.f90 b/gcc/testsuite/gfortran.dg/constant_shape.f90 new file mode 100644 index 0000000..c2eaf82 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/constant_shape.f90 @@ -0,0 +1,20 @@ +! { dg-do compile } +! +! PR 78392: ICE in gfc_trans_auto_array_allocation, at fortran/trans-array.c:5979 +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +module mytypes + implicit none + contains + pure integer function get_i () + get_i = 13 + end function +end module + +program test + use mytypes + implicit none + integer, dimension(get_i()) :: x ! { dg-error "must have constant shape" } + print *, size (x) +end |