public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] PR27698 - Add diagnostic message for invalid names
@ 2007-01-03 16:49 Bernhard Fischer
  2007-01-04  5:05 ` Steve Kargl
  0 siblings, 1 reply; 5+ messages in thread
From: Bernhard Fischer @ 2007-01-03 16:49 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

[-- 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-01-07 16:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-03 16:49 [patch, fortran] PR27698 - Add diagnostic message for invalid names Bernhard Fischer
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

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).