aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorTobias Schlüter <tobi@gcc.gnu.org>2007-10-07 13:45:15 +0200
committerTobias Schlüter <tobi@gcc.gnu.org>2007-10-07 13:45:15 +0200
commitc4d4556f8daab94ba0be96ee6f56507da1ae4b94 (patch)
tree46ae2ca6e15985534293a1fe9546fb98f8318399 /gcc/fortran
parent3a6b0f546506cf36a9b9eaca9008bc6cd705bb2e (diff)
downloadgcc-c4d4556f8daab94ba0be96ee6f56507da1ae4b94.zip
gcc-c4d4556f8daab94ba0be96ee6f56507da1ae4b94.tar.gz
gcc-c4d4556f8daab94ba0be96ee6f56507da1ae4b94.tar.bz2
re PR fortran/20851 (dummy argument may not appear in specification expression in elemental procedure)
PR fortran/20851 fortran/ * expr.c (check_inquiry): Typo fix in error message. (check_init_expr): Same * 3. (check_restricted): Verify that no dummy arguments appear in restricted expressions in ELEMENTAL procedures. * resolve.c (resolve_fl_variable): Exchange order of checks to avoid side-effect. testsuite/ * initialization_1.f90: Fix dg-error annotations. * initialization_14.f90: New. * initialization_7.f90: Fix dg-error annotations. * initialization_9.f90: Likewise. From-SVN: r129069
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog10
-rw-r--r--gcc/fortran/expr.c21
-rw-r--r--gcc/fortran/resolve.c22
3 files changed, 37 insertions, 16 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 9cc097c..28ed3f7 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2007-10-07 Tobias Schlüter <tobi@gcc.gnu.org>
+
+ PR fortran/20851
+ * expr.c (check_inquiry): Typo fix in error message.
+ (check_init_expr): Same * 3.
+ (check_restricted): Verify that no dummy arguments appear in
+ restricted expressions in ELEMENTAL procedures.
+ * resolve.c (resolve_fl_variable): Exchange order of checks to
+ avoid side-effect.
+
2007-10-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/33609
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 0c68095..151b465 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2012,7 +2012,7 @@ check_inquiry (gfc_expr *e, int not_restricted)
&& ap->expr->symtree->n.sym->ts.type == BT_CHARACTER
&& ap->expr->symtree->n.sym->ts.cl->length == NULL)
{
- gfc_error ("assumed character length variable '%s' in constant "
+ gfc_error ("Assumed character length variable '%s' in constant "
"expression at %L", e->symtree->n.sym->name, &e->where);
return MATCH_ERROR;
}
@@ -2204,19 +2204,19 @@ check_init_expr (gfc_expr *e)
switch (e->symtree->n.sym->as->type)
{
case AS_ASSUMED_SIZE:
- gfc_error ("assumed size array '%s' at %L is not permitted "
+ gfc_error ("Assumed size array '%s' at %L is not permitted "
"in an initialization expression",
e->symtree->n.sym->name, &e->where);
break;
case AS_ASSUMED_SHAPE:
- gfc_error ("assumed shape array '%s' at %L is not permitted "
+ gfc_error ("Assumed shape array '%s' at %L is not permitted "
"in an initialization expression",
e->symtree->n.sym->name, &e->where);
break;
case AS_DEFERRED:
- gfc_error ("deferred array '%s' at %L is not permitted "
+ gfc_error ("Deferred array '%s' at %L is not permitted "
"in an initialization expression",
e->symtree->n.sym->name, &e->where);
break;
@@ -2429,6 +2429,19 @@ check_restricted (gfc_expr *e)
sym = e->symtree->n.sym;
t = FAILURE;
+ /* If a dummy argument appears in a context that is valid for a
+ restricted expression in an elemental procedure, it will have
+ already been simplified away once we get here. Therefore we
+ don't need to jump through hoops to distinguish valid from
+ invalid cases. */
+ if (sym->attr.dummy && sym->ns == gfc_current_ns
+ && sym->ns->proc_name && sym->ns->proc_name->attr.elemental)
+ {
+ gfc_error ("Dummy argument '%s' not allowed in expression at %L",
+ sym->name, &e->where);
+ break;
+ }
+
if (sym->attr.optional)
{
gfc_error ("Dummy argument '%s' at %L cannot be OPTIONAL",
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 50164f6..61be64f 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -6968,22 +6968,20 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
is_non_constant_shape_array. */
specification_expr = 1;
- if (!sym->attr.use_assoc
+ 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
&& !sym->attr.allocatable
&& !sym->attr.pointer
&& is_non_constant_shape_array (sym))
{
- /* 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);
- specification_expr = 0;
- return FAILURE;
- }
+ /* The shape of a main program or module array needs to be
+ constant. */
+ gfc_error ("The module or main program array '%s' at %L must "
+ "have constant shape", sym->name, &sym->declared_at);
+ specification_expr = 0;
+ return FAILURE;
}
if (sym->ts.type == BT_CHARACTER)