From 9bce3c1cc4f6ae378870d3c5de4a1eb8cde6c1c2 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 31 Jan 2007 10:18:33 +0100 Subject: re PR fortran/30520 (Conflics checking of VOLATILE attribute needs improvement) fortran/ 2007-01-31 Tobias Burnus PR fortran/30520 * interface.c (compare_actual_formal): Check conformance between actual and VOLATILE dummy arguments. * symbol.c (gfc_add_volatile): Allow setting of VOLATILE multiple times in different scopes. * decl.c (gfc_match_volatile): Search symbol in host association. testsuite/ 2007-01-31 Tobias Burnus PR fortran/30520 * gfortran.dg/volatile8.f90: New argument conformance test. * gfortran.dg/volatile9.f90: New scope test. From-SVN: r121379 --- gcc/fortran/ChangeLog | 9 +++++++++ gcc/fortran/decl.c | 4 +++- gcc/fortran/interface.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ gcc/fortran/symbol.c | 12 ++++++++---- 4 files changed, 68 insertions(+), 5 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f8b33dd..7d6680f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2007-01-31 Tobias Burnus + + PR fortran/30520 + * interface.c (compare_actual_formal): Check conformance between + actual and VOLATILE dummy arguments. + * symbol.c (gfc_add_volatile): Allow setting of VOLATILE + multiple times in different scopes. + * decl.c (gfc_match_volatile): Search symbol in host association. + 2007-01-31 Kazu Hirata * simplify.c, trans-array.c: Fix comment typos. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 2470722..b25bcc0 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -4221,7 +4221,9 @@ gfc_match_volatile (void) for(;;) { - m = gfc_match_symbol (&sym, 0); + /* VOLATILE is special because it can be added to host-associated + symbols locally. */ + m = gfc_match_symbol (&sym, 1); switch (m) { case MATCH_YES: diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 91674bf..9ce42cc 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1417,6 +1417,54 @@ compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal, return 0; } + /* C1232 (R1221) For an actual argument which is an array section or + an assumed-shape array, the dummy argument shall be an assumed- + shape array, if the dummy argument has the VOLATILE attribute. */ + + if (f->sym->attr.volatile_ + && a->expr->symtree->n.sym->as + && a->expr->symtree->n.sym->as->type == AS_ASSUMED_SHAPE + && !(f->sym->as && f->sym->as->type == AS_ASSUMED_SHAPE)) + { + if (where) + gfc_error ("Assumed-shape actual argument at %L is " + "incompatible with the non-assumed-shape " + "dummy argument '%s' due to VOLATILE attribute", + &a->expr->where,f->sym->name); + return 0; + } + + if (f->sym->attr.volatile_ + && a->expr->ref && a->expr->ref->u.ar.type == AR_SECTION + && !(f->sym->as && f->sym->as->type == AS_ASSUMED_SHAPE)) + { + if (where) + gfc_error ("Array-section actual argument at %L is " + "incompatible with the non-assumed-shape " + "dummy argument '%s' due to VOLATILE attribute", + &a->expr->where,f->sym->name); + return 0; + } + + /* C1233 (R1221) For an actual argument which is a pointer array, the + dummy argument shall be an assumed-shape or pointer array, if the + dummy argument has the VOLATILE attribute. */ + + if (f->sym->attr.volatile_ + && a->expr->symtree->n.sym->attr.pointer + && a->expr->symtree->n.sym->as + && !(f->sym->as + && (f->sym->as->type == AS_ASSUMED_SHAPE + || f->sym->attr.pointer))) + { + if (where) + gfc_error ("Pointer-array actual argument at %L requires " + "an assumed-shape or pointer-array dummy " + "argument '%s' due to VOLATILE attribute", + &a->expr->where,f->sym->name); + return 0; + } + match: if (a == actual) na = i; diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index c130dee..05c7eae 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -877,10 +877,14 @@ try gfc_add_volatile (symbol_attribute * attr, const char *name, locus * where) { - if (check_used (attr, name, where)) - return FAILURE; - - if (attr->volatile_) + /* No check_used needed as 11.2.1 of the F2003 standard allows + that the local identifier made accessible by a use statement can be + given a VOLATILE attribute. */ + + /* TODO: The following allows multiple VOLATILE statements for + use-associated variables and it prevents setting VOLATILE for a host- + associated variable which is already marked as VOLATILE in the host. */ + if (attr->volatile_ && !attr->use_assoc) { if (gfc_notify_std (GFC_STD_LEGACY, "Duplicate VOLATILE attribute specified at %L", -- cgit v1.1