From f2bc4e4800590aa59b0ac126676786dd4ce77867 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Sun, 4 Sep 2016 20:00:48 +0000 Subject: re PR fortran/77391 (gfortran allows CHARACTER(LEN=:),PARAMETER:: STRING='constant' buts does not report it as an extension) 2016-09-04 Steven G. Kargl PR fortran/77391 * resolve.c (deferred_requirements): New function to check F2008:C402. (resolve_fl_variable,resolve_fl_parameter): Use it. 2016-09-04 Steven G. Kargl PR fortran/77391 * gfortran.dg/pr77391.f90: New test. From-SVN: r239982 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/resolve.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 11 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0b452f4..8e525dc 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,11 @@ 2016-09-04 Steven G. Kargl + PR fortran/77391 + * resolve.c (deferred_requirements): New function to check F2008:C402. + (resolve_fl_variable,resolve_fl_parameter): Use it. + +2016-09-04 Steven G. Kargl + PR fortran/77460 * simplify.c (simplify_transformation_to_scalar): On error, result may be NULL, simply return. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 39c1330..f8ba00b 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11488,6 +11488,27 @@ resolve_fl_variable_derived (gfc_symbol *sym, int no_init_flag) } +/* F2008, C402 (R401): A colon shall not be used as a type-param-value + except in the declaration of an entity or component that has the POINTER + or ALLOCATABLE attribute. */ + +static bool +deferred_requirements (gfc_symbol *sym) +{ + if (sym->ts.deferred + && !(sym->attr.pointer + || sym->attr.allocatable + || sym->attr.omp_udr_artificial_var)) + { + gfc_error ("Entity %qs at %L has a deferred type parameter and " + "requires either the POINTER or ALLOCATABLE attribute", + sym->name, &sym->declared_at); + return false; + } + return true; +} + + /* Resolve symbols with flavor variable. */ static bool @@ -11527,17 +11548,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag) } /* Constraints on deferred type parameter. */ - if (sym->ts.deferred - && !(sym->attr.pointer - || sym->attr.allocatable - || sym->attr.omp_udr_artificial_var)) - { - gfc_error ("Entity %qs at %L has a deferred type parameter and " - "requires either the pointer or allocatable attribute", - sym->name, &sym->declared_at); - specification_expr = saved_specification_expr; - return false; - } + if (!deferred_requirements (sym)) + return false; if (sym->ts.type == BT_CHARACTER) { @@ -13682,6 +13694,10 @@ resolve_fl_parameter (gfc_symbol *sym) return false; } + /* Constraints on deferred type parameter. */ + if (!deferred_requirements (sym)) + return false; + /* Make sure a parameter that has been implicitly typed still matches the implicit type, since PARAMETER statements can precede IMPLICIT statements. */ -- cgit v1.1