aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2006-11-07 14:27:53 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2006-11-07 14:27:53 +0100
commit775e6c3a7b9301534d2e6ee3bff8178cde910b49 (patch)
treec63b26fdfe160e12fa7a62ffabe00e56d67e1b2a /gcc/fortran/decl.c
parentc927b11c7832ba293da24201305efa7c3dd64cb0 (diff)
downloadgcc-775e6c3a7b9301534d2e6ee3bff8178cde910b49.zip
gcc-775e6c3a7b9301534d2e6ee3bff8178cde910b49.tar.gz
gcc-775e6c3a7b9301534d2e6ee3bff8178cde910b49.tar.bz2
re PR fortran/29601 (VOLATILE attribute and statement)
fortran/ 2006-11-06 Tobias Burnus <burnus@net-b.de> PR fortran/29601 * symbol.c (check_conflict, gfc_add_volatile): Add volatile support. * decl.c (match_attr_spec, gfc_match_volatile): Add volatile support. * gfortran.h (symbol_attribute): Add volatile_ to struct. * resolve.c (was_declared): Add volatile support. * trans-decl.c (gfc_finish_var_decl): Add volatile support. * match.h: Declare gfc_match_volatile. * parse.c (decode_statement): Recognize volatile. * modules.c (ab_attribute, attr_bits, mio_symbol_attribute): Add volatile support. * dump-parse-tree.c (gfc_show_attr): Add volatile support. testsuite/ 2006-11-06 Tobias Burnus <burnus@net-b.de> PR fortran/29601 * gfortran.dg/volatile.f90: Add. * gfortran.dg/volatile2.f90: Add. * gfortran.dg/volatile3.f90: Add. * gfortran.dg/volatile4.f90: Add. * gfortran.dg/volatile5.f90: Add. * gfortran.dg/volatile6.f90: Add. * gfortran.dg/volatile7.f90: Add. From-SVN: r118545
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index e326b94..a476c64 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2025,7 +2025,7 @@ match_attr_spec (void)
DECL_ALLOCATABLE = GFC_DECL_BEGIN, DECL_DIMENSION, DECL_EXTERNAL,
DECL_IN, DECL_OUT, DECL_INOUT, DECL_INTRINSIC, DECL_OPTIONAL,
DECL_PARAMETER, DECL_POINTER, DECL_PRIVATE, DECL_PUBLIC, DECL_SAVE,
- DECL_TARGET, DECL_COLON, DECL_NONE,
+ DECL_TARGET, DECL_VOLATILE, DECL_COLON, DECL_NONE,
GFC_DECL_END /* Sentinel */
}
decl_types;
@@ -2048,6 +2048,7 @@ match_attr_spec (void)
minit (", public", DECL_PUBLIC),
minit (", save", DECL_SAVE),
minit (", target", DECL_TARGET),
+ minit (", volatile", DECL_VOLATILE),
minit ("::", DECL_COLON),
minit (NULL, DECL_NONE)
};
@@ -2168,6 +2169,9 @@ match_attr_spec (void)
case DECL_TARGET:
attr = "TARGET";
break;
+ case DECL_VOLATILE:
+ attr = "VOLATILE";
+ break;
default:
attr = NULL; /* This shouldn't happen */
}
@@ -2282,6 +2286,15 @@ match_attr_spec (void)
t = gfc_add_target (&current_attr, &seen_at[d]);
break;
+ case DECL_VOLATILE:
+ if (gfc_notify_std (GFC_STD_F2003,
+ "Fortran 2003: VOLATILE attribute at %C")
+ == FAILURE)
+ t = FAILURE;
+ else
+ t = gfc_add_volatile (&current_attr, NULL, &seen_at[d]);
+ break;
+
default:
gfc_internal_error ("match_attr_spec(): Bad attribute");
}
@@ -3944,6 +3957,59 @@ syntax:
}
+match
+gfc_match_volatile (void)
+{
+ gfc_symbol *sym;
+ match m;
+
+ if (gfc_notify_std (GFC_STD_F2003,
+ "Fortran 2003: VOLATILE statement at %C")
+ == FAILURE)
+ return MATCH_ERROR;
+
+ if (gfc_match (" ::") == MATCH_NO && gfc_match_space () == MATCH_NO)
+ {
+ return MATCH_ERROR;
+ }
+
+ if (gfc_match_eos () == MATCH_YES)
+ goto syntax;
+
+ for(;;)
+ {
+ m = gfc_match_symbol (&sym, 0);
+ switch (m)
+ {
+ case MATCH_YES:
+ if (gfc_add_volatile (&sym->attr, sym->name,
+ &gfc_current_locus) == FAILURE)
+ return MATCH_ERROR;
+ goto next_item;
+
+ case MATCH_NO:
+ break;
+
+ case MATCH_ERROR:
+ return MATCH_ERROR;
+ }
+
+ next_item:
+ if (gfc_match_eos () == MATCH_YES)
+ break;
+ if (gfc_match_char (',') != MATCH_YES)
+ goto syntax;
+ }
+
+ return MATCH_YES;
+
+syntax:
+ gfc_error ("Syntax error in VOLATILE statement at %C");
+ return MATCH_ERROR;
+}
+
+
+
/* Match a module procedure statement. Note that we have to modify
symbols in the parent's namespace because the current one was there
to receive symbols that are in an interface's formal argument list. */