Commit 0e8879cb by Steven G. Kargl

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
parent 36edf9ca
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 Tobias Burnus <tobias@codesourcery.com> 2019-10-04 Tobias Burnus <tobias@codesourcery.com>
* error (error_print, gfc_format_decoder): Fix off-by one issue with %C. * error (error_print, gfc_format_decoder): Fix off-by one issue with %C.
......
...@@ -2441,6 +2441,7 @@ variable_decl (int elem) ...@@ -2441,6 +2441,7 @@ variable_decl (int elem)
match m; match m;
bool t; bool t;
gfc_symbol *sym; gfc_symbol *sym;
char c;
initializer = NULL; initializer = NULL;
as = NULL; as = NULL;
...@@ -2454,40 +2455,45 @@ variable_decl (int elem) ...@@ -2454,40 +2455,45 @@ variable_decl (int elem)
name to be '%FILL' which gives it an anonymous (inaccessible) name. */ name to be '%FILL' which gives it an anonymous (inaccessible) name. */
m = MATCH_NO; m = MATCH_NO;
gfc_gobble_whitespace (); 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"); m = gfc_match ("fill");
} if (m == MATCH_YES)
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 (flag_dec_structure) if (gfc_current_state () != COMP_STRUCTURE)
gfc_error ("%qs not allowed outside STRUCTURE at %C", "%FILL"); {
else if (flag_dec_structure)
gfc_error ("%qs at %C is a DEC extension, enable with " 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"); "%<-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"); gfc_error ("Invalid character %qc in variable name at %C", c);
goto cleanup; return MATCH_ERROR;
} }
}
/* %FILL components are given invalid fortran names. */ else
snprintf (name, GFC_MAX_SYMBOL_LEN + 1, "%%FILL%u", fill_id++); {
m = gfc_match_name (name);
if (m != MATCH_YES)
goto cleanup;
} }
var_locus = gfc_current_locus; var_locus = gfc_current_locus;
......
2019-10-04 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran.91959
* gfortran.dg/pr91959.f90: New test.
2019-10-04 Rafael Tsuha <rafael.tsuha@usp.br> 2019-10-04 Rafael Tsuha <rafael.tsuha@usp.br>
* gcc.dg/sinhovercosh-1.c: New test. * gcc.dg/sinhovercosh-1.c: New test.
......
! { dg-do compile }
! PR fortran/91959
! Code contributed by Gerhard Steinmetz
program p
implicit none
integer :: %a ! { dg-error "Invalid character" }
a = 1 ! { dg-error "has no IMPLICIT type" }
print *, a
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment