aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2019-10-04 21:21:21 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2019-10-04 21:21:21 +0000
commit0e8879cb36eca17e7b1ff8f2124bbc5ec3c6dc91 (patch)
treefd3df1f93a3f6ab12af8579221760afa0f7cf4b0 /gcc/fortran/decl.c
parent36edf9cab1d4a444497c2aaf57c4ce61f7a67901 (diff)
downloadgcc-0e8879cb36eca17e7b1ff8f2124bbc5ec3c6dc91.zip
gcc-0e8879cb36eca17e7b1ff8f2124bbc5ec3c6dc91.tar.gz
gcc-0e8879cb36eca17e7b1ff8f2124bbc5ec3c6dc91.tar.bz2
PR fortran.91959
2019-10-04 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran.91959 * fortran/decl.c (variable_decl): Re-arrange code for matching %FILL. 2019-10-04 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran.91959 * gfortran.dg/pr91959.f90: New test. From-SVN: r276601
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c60
1 files changed, 33 insertions, 27 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 96b6f3f..d439906 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2441,6 +2441,7 @@ variable_decl (int elem)
match m;
bool t;
gfc_symbol *sym;
+ char c;
initializer = NULL;
as = NULL;
@@ -2454,40 +2455,45 @@ variable_decl (int elem)
name to be '%FILL' which gives it an anonymous (inaccessible) name. */
m = MATCH_NO;
gfc_gobble_whitespace ();
- if (gfc_peek_ascii_char () == '%')
+ c = gfc_peek_ascii_char ();
+ if (c == '%')
{
- gfc_next_ascii_char ();
+ gfc_next_ascii_char (); /* Burn % character. */
m = gfc_match ("fill");
- }
-
- if (m != MATCH_YES)
- {
- m = gfc_match_name (name);
- if (m != MATCH_YES)
- goto cleanup;
- }
-
- else
- {
- m = MATCH_ERROR;
- if (gfc_current_state () != COMP_STRUCTURE)
+ if (m == MATCH_YES)
{
- if (flag_dec_structure)
- gfc_error ("%qs not allowed outside STRUCTURE at %C", "%FILL");
- else
- gfc_error ("%qs at %C is a DEC extension, enable with "
+ if (gfc_current_state () != COMP_STRUCTURE)
+ {
+ if (flag_dec_structure)
+ gfc_error ("%qs not allowed outside STRUCTURE at %C", "%FILL");
+ else
+ gfc_error ("%qs at %C is a DEC extension, enable with "
"%<-fdec-structure%>", "%FILL");
- goto cleanup;
- }
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
+
+ if (attr_seen)
+ {
+ gfc_error ("%qs entity cannot have attributes at %C", "%FILL");
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
- if (attr_seen)
+ /* %FILL components are given invalid fortran names. */
+ snprintf (name, GFC_MAX_SYMBOL_LEN + 1, "%%FILL%u", fill_id++);
+ }
+ else
{
- gfc_error ("%qs entity cannot have attributes at %C", "%FILL");
- goto cleanup;
+ gfc_error ("Invalid character %qc in variable name at %C", c);
+ return MATCH_ERROR;
}
-
- /* %FILL components are given invalid fortran names. */
- snprintf (name, GFC_MAX_SYMBOL_LEN + 1, "%%FILL%u", fill_id++);
+ }
+ else
+ {
+ m = gfc_match_name (name);
+ if (m != MATCH_YES)
+ goto cleanup;
}
var_locus = gfc_current_locus;