diff options
author | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-12-10 19:53:07 +0000 |
---|---|---|
committer | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-12-10 19:53:07 +0000 |
commit | 3ea52af31c6ee2b96ce6be5ac7c4aa336a05f01e (patch) | |
tree | fd873c228f212288e3d63dae896648e0ca50835b /gcc/fortran/decl.c | |
parent | fce068fdbd2d4d13d3c57cb16bc9d17f22f36af1 (diff) | |
download | gcc-3ea52af31c6ee2b96ce6be5ac7c4aa336a05f01e.tar.gz |
fortran/
2006-12-10 Tobias Burnus <burnus@net-b.de>
PR fortran/23994
* interface.c (compare_actual_formal): PROTECTED is incompatible
with intent(out).
* symbol.c (check_conflict): Check for PROTECTED conflicts.
(gfc_add_protected): New function.
(gfc_copy_attr): Copy PROTECTED attribute.
* decl.c (match_attr_spec): Add PROTECTED support.
(gfc_match_protected): New function.
* dump-parse-tree.c (gfc_show_attr): Add PROTECTED support.
* gfortran.h (gfc_symbol): Add protected flag.
Add gfc_add_protected prototype.
* expr.c (gfc_check_pointer_assign): Add PROTECTED support.
* module.c (ab_attribute, attr_bits, mio_symbol_attribute,
mio_symbol_attribute):
Add PROTECTED support.
* resolve.c (resolve_equivalence): Add PROTECTED support.
* match.c (gfc_match_assignment,)gfc_match_pointer_assignment:
Check PROTECTED attribute.
* match.h: Add gfc_match_protected prototype.
* parse.c (decode_statement): Match PROTECTED statement.
* primary.c (match_variable): Add PROTECTED support.
testsuite/
2006-12-10 Tobias Burnus <burnus@net-b.de>
PR fortran/23994
* gfortran.dg/protected_1.f90: New test.
* gfortran.dg/protected_2.f90: New test.
* gfortran.dg/protected_3.f90: New test.
* gfortran.dg/protected_4.f90: New test.
* gfortran.dg/protected_5.f90: New test.
* gfortran.dg/protected_6.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119709 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 87 |
1 files changed, 85 insertions, 2 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 46c49ba9e8c..eb3323733ee 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -2116,8 +2116,9 @@ match_attr_spec (void) { GFC_DECL_BEGIN = 0, 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_VALUE, DECL_VOLATILE, DECL_COLON, DECL_NONE, + DECL_PARAMETER, DECL_POINTER, DECL_PROTECTED, DECL_PRIVATE, + DECL_PUBLIC, DECL_SAVE, DECL_TARGET, DECL_VALUE, DECL_VOLATILE, + DECL_COLON, DECL_NONE, GFC_DECL_END /* Sentinel */ } decl_types; @@ -2136,6 +2137,7 @@ match_attr_spec (void) minit (", optional", DECL_OPTIONAL), minit (", parameter", DECL_PARAMETER), minit (", pointer", DECL_POINTER), + minit (", protected", DECL_PROTECTED), minit (", private", DECL_PRIVATE), minit (", public", DECL_PUBLIC), minit (", save", DECL_SAVE), @@ -2250,6 +2252,9 @@ match_attr_spec (void) case DECL_POINTER: attr = "POINTER"; break; + case DECL_PROTECTED: + attr = "PROTECTED"; + break; case DECL_PRIVATE: attr = "PRIVATE"; break; @@ -2364,6 +2369,23 @@ match_attr_spec (void) t = gfc_add_pointer (¤t_attr, &seen_at[d]); break; + case DECL_PROTECTED: + if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE) + { + gfc_error ("PROTECTED at %C only allowed in specification " + "part of a module"); + t = FAILURE; + break; + } + + if (gfc_notify_std (GFC_STD_F2003, + "Fortran 2003: PROTECTED attribute at %C") + == FAILURE) + t = FAILURE; + else + t = gfc_add_protected (¤t_attr, NULL, &seen_at[d]); + break; + case DECL_PRIVATE: t = gfc_add_access (¤t_attr, ACCESS_PRIVATE, NULL, &seen_at[d]); @@ -3840,6 +3862,67 @@ done: } +match +gfc_match_protected (void) +{ + gfc_symbol *sym; + match m; + + if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE) + { + gfc_error ("PROTECTED at %C only allowed in specification " + "part of a module"); + return MATCH_ERROR; + + } + + if (gfc_notify_std (GFC_STD_F2003, + "Fortran 2003: PROTECTED 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_protected (&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 PROTECTED statement at %C"); + return MATCH_ERROR; +} + + + /* The PRIVATE statement is a bit weird in that it can be a attribute declaration, but also works as a standlone statement inside of a type declaration or a module. */ |