From 83eb71f4e4a081e25a5e953acfc8757c5f4e85fb Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Thu, 2 Jul 2015 17:29:04 +0000 Subject: [PATCH] re PR fortran/56520 (Syntax error causes misleading message: "Invalid character in name") 2015-07-02 Steven G. Kargl PR fortran/56520 * match.c (gfc_match_name): Special case unary minus and plus. 2015-07-02 Steven G. Kargl PR fortran/56520 * gfortran.dg/pr56520.f90: New test. From-SVN: r225349 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/match.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr56520.f90 | 13 +++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr56520.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b9777272ad9..fc946c14d97 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-07-02 Steven G. Kargl + + PR fortran/56520 + * match.c (gfc_match_name): Special case unary minus and plus. + 2015-07-02 Steven G. Kargl PR fortran/66545 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index e7fe8318164..c66addb180e 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9e92aae125c..21ba2faf60f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-02 Steven G. Kargl + + PR fortran/56520 + * gfortran.dg/pr56520.f90: New test. + 2015-07-02 Steven G. Kargl PR fortran/66545 diff --git a/gcc/testsuite/gfortran.dg/pr56520.f90 b/gcc/testsuite/gfortran.dg/pr56520.f90 new file mode 100644 index 00000000000..b074b8024ca --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr56520.f90 @@ -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 -- 2.30.2