From: Bernhard Fischer <rep.nop@aon.at>
To: fortran@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org
Subject: [patch, fortran] PR27698 - Add diagnostic message for invalid names
Date: Wed, 03 Jan 2007 16:49:00 -0000 [thread overview]
Message-ID: <20070103165049.GA16663@aon.at> (raw)
[-- Attachment #1: Type: text/plain, Size: 864 bytes --]
:ADDPATCH fortran:
According to 3.2.1, a name is
letter [alphanumeric-character]...
While we did reject invalid names, this PR wanted to have a diagnostic
message to be printed along rejecting the invalid name.
The attached patch adds this diagnostic message, adds one testcase to
expect the newly added error message and adjusts testcases that trigger
the new error.
Bootstrapped and regtested with check-gfortran on i686-linux-gnu. Ok for
trunk?
PS:
A vaguely related issue in the area of invalid names is whether or not
-fdollar-ok should allow for the '$' as the very first character in a
name ¹). Accepting it would mean that implicit types may need to be
updated for dollar as first char ²)
Attached patch does not address this issue.
¹)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27698#c6
²)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27698#c11
[-- Attachment #2: gcc.gfortran.pr27698.01.txt --]
[-- Type: text/plain, Size: 410 bytes --]
fortran/ChangeLog
2007-01-03 Bernhard Fischer <aldot@gcc.gnu.org>
PR fortran/27698
* match.c (gfc_match_name): Print diagnostics for invalid character
in names.
testsuite/ChangeLog
2007-01-03 Bernhard Fischer <aldot@gcc.gnu.org>
PR fortran/27698
* gfortran.dg/invalid_name.f90: New test.
* gfortran.dg/do_iterator.f90: Adjust pattern for expected error.
* gfortran.dg/gomp/pr29759.f90: Ditto.
[-- Attachment #3: gcc.gfortran.pr27698.01.diff --]
[-- Type: text/plain, Size: 2737 bytes --]
Index: gcc-4.3/gcc/fortran/match.c
===================================================================
--- gcc-4.3/gcc/fortran/match.c (revision 120338)
+++ gcc-4.3/gcc/fortran/match.c (working copy)
@@ -396,6 +396,8 @@ gfc_match_name (char *buffer)
c = gfc_next_char ();
if (!ISALPHA (c))
{
+ if (gfc_error_flag_test() == 0)
+ gfc_error ("Invalid character in name at %C");
gfc_current_locus = old_loc;
return MATCH_NO;
}
Index: gcc-4.3/gcc/testsuite/gfortran.dg/invalid_name.f90
===================================================================
--- gcc-4.3/gcc/testsuite/gfortran.dg/invalid_name.f90 (revision 0)
+++ gcc-4.3/gcc/testsuite/gfortran.dg/invalid_name.f90 (revision 0)
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! Tests the fix for PR27698, where names not starting with a letter were
+! rejected but not diagnosed with a proper message.
+SUBROUTINE _foo ! { dg-error "Invalid character in name" }
+END
+
Index: gcc-4.3/gcc/testsuite/gfortran.dg/do_iterator.f90
===================================================================
--- gcc-4.3/gcc/testsuite/gfortran.dg/do_iterator.f90 (revision 120338)
+++ gcc-4.3/gcc/testsuite/gfortran.dg/do_iterator.f90 (working copy)
@@ -10,4 +10,4 @@ DO I=1,5 ! { dg-error "cannot be r
READ(5,*,iostat=i) j ! { dg-error "cannot be redefined" "changing do-iterator 3" }
ENDDO
END
-
+! { dg-error "Invalid character" "character" { target *-*-* } 7 }
Index: gcc-4.3/gcc/testsuite/gfortran.dg/gomp/pr29759.f90
===================================================================
--- gcc-4.3/gcc/testsuite/gfortran.dg/gomp/pr29759.f90 (revision 120338)
+++ gcc-4.3/gcc/testsuite/gfortran.dg/gomp/pr29759.f90 (working copy)
@@ -22,21 +22,21 @@ PROGRAM test_omp
!$OMP PARALLEL & ! { dg-error "Unclassifiable OpenMP" }
-!$ NUM_THREADS(2) ! { dg-error "Unclassifiable" }
+!$ NUM_THREADS(2) ! { dg-error "Unclassifiable|Invalid character" }
!$OMP END PARALLEL ! { dg-error "Unexpected" }
!$OMP PARALLEL & ! { dg-error "Unclassifiable OpenMP" }
-!$ & NUM_THREADS(2) ! { dg-error "Unclassifiable" }
+!$ & NUM_THREADS(2) ! { dg-error "Unclassifiable|Invalid character" }
!$OMP END PARALLEL ! { dg-error "Unexpected" }
!$OMP PARALLEL & ! { dg-error "Unclassifiable OpenMP" }
!
-!$ NUM_THREADS(2) ! { dg-error "Unclassifiable" }
+!$ NUM_THREADS(2) ! { dg-error "Unclassifiable|Invalid character" }
!$OMP END PARALLEL ! { dg-error "Unexpected" }
!$OMP PARALLEL & ! { dg-error "Unclassifiable OpenMP" }
!
-!$ & NUM_THREADS(2) ! { dg-error "Unclassifiable" }
+!$ & NUM_THREADS(2) ! { dg-error "Unclassifiable|Invalid character" }
!$OMP END PARALLEL ! { dg-error "Unexpected" }
END PROGRAM
next reply other threads:[~2007-01-03 16:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-03 16:49 Bernhard Fischer [this message]
2007-01-04 5:05 ` Steve Kargl
2007-01-04 10:10 ` Bernhard Fischer
2007-01-05 6:16 ` Steve Kargl
2007-01-07 16:43 ` Bernhard Fischer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070103165049.GA16663@aon.at \
--to=rep.nop@aon.at \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).