re PR fortran/56520 (Syntax error causes misleading message: "Invalid character in name")

2015-07-02  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/56520
	* match.c (gfc_match_name): Special case unary minus and plus.

2015-07-02  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/56520
	* gfortran.dg/pr56520.f90: New test.

From-SVN: r225349
This commit is contained in:
Steven G. Kargl 2015-07-02 17:29:04 +00:00
parent 70db5f0228
commit 83eb71f4e4
4 changed files with 27 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2015-07-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/56520
* match.c (gfc_match_name): Special case unary minus and plus.
2015-07-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66545

View File

@ -537,7 +537,10 @@ gfc_match_name (char *buffer)
c = gfc_next_ascii_char ();
if (!(ISALPHA (c) || (c == '_' && flag_allow_leading_underscore)))
{
if (!gfc_error_flag_test () && c != '(')
/* Special cases for unary minus and plus, which allows for a sensible
error message for code of the form 'c = exp(-a*b) )' where an
extra ')' appears at the end of statement. */
if (!gfc_error_flag_test () && c != '(' && c != '-' && c != '+')
gfc_error ("Invalid character in name at %C");
gfc_current_locus = old_loc;
return MATCH_NO;

View File

@ -1,3 +1,8 @@
2015-07-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/56520
* gfortran.dg/pr56520.f90: New test.
2015-07-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66545

View File

@ -0,0 +1,13 @@
! { dg-do compile }
! PR fortran/56520
!
program misleading
implicit none
real a, c
a = 1.0
c = exp(+a) ) ! { dg-error "Unclassifiable statement" }
c = exp(-a) ) ! { dg-error "Unclassifiable statement" }
c = exp((a)) ) ! { dg-error "Unclassifiable statement" }
c = exp(a) ) ! { dg-error "Unclassifiable statement" }
c = exp(a)
end program misleading