aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2016-09-04 20:00:48 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2016-09-04 20:00:48 +0000
commitf2bc4e4800590aa59b0ac126676786dd4ce77867 (patch)
treeaa692a2f3cd5fb4c8444351757e8c9277c8bd5da /gcc/fortran
parentaa9cdb975501bf1019d390b41df6fe6ddea040b7 (diff)
downloadgcc-f2bc4e4800590aa59b0ac126676786dd4ce77867.zip
gcc-f2bc4e4800590aa59b0ac126676786dd4ce77867.tar.gz
gcc-f2bc4e4800590aa59b0ac126676786dd4ce77867.tar.bz2
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 <kargl@gcc.gnu.org> 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 <kargl@gcc.gnu.org> PR fortran/77391 * gfortran.dg/pr77391.f90: New test. From-SVN: r239982
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/resolve.c38
2 files changed, 33 insertions, 11 deletions
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 <kargl@gcc.gnu.org>
+ 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 <kargl@gcc.gnu.org>
+
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. */