public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gfortran] Fix PR 16433
@ 2004-07-11 17:48 Tobias Schlüter
  2004-07-11 18:07 ` Paul Brook
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Schlüter @ 2004-07-11 17:48 UTC (permalink / raw)
  To: GCC Fortran mailing list, patch


We used to give a warning for this valid code when compiled with -pedantic.
      real x
      double precision dx
      x = 2.0
      dx = x
      end
The warning is curious enough to be reproduced:
 In file /usr/local/src/gcc/gcc/testsuite/gfortran.dg/pr5473a.f:4

      dx = x
           1
Warning: Extension: Hexadecimal constant at (1) uses non-standard syntax.

This happened, because gfc_notify_std would be called before we were
even sure that we had actually found a boz-literal-constant. Fixed by
the below. Built and tested on i686-pc-linux. The disappearing of the
error message has been verified, and I will add a dg-bogus-warning
testcase to the testsuite along with the patch.

- Tobi

2004-07-11  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

	PR fortran/16433
	* primary.c (match_boz_constant): Call gfc_notify_std only if
	we actually have a non-standard boz-literal-constant.

Index: primary.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/primary.c,v
retrieving revision 1.7
diff -u -p -r1.7 primary.c
--- primary.c   9 Jul 2004 14:53:39 -0000       1.7
+++ primary.c   11 Jul 2004 14:43:17 -0000
@@ -235,7 +235,7 @@ match_integer_constant (gfc_expr ** resu
 static match
 match_boz_constant (gfc_expr ** result)
 {
-  int radix, delim, length;
+  int radix, delim, length, x_hex;
   locus old_loc;
   char *buffer;
   gfc_expr *e;
@@ -244,6 +244,7 @@ match_boz_constant (gfc_expr ** result)
   old_loc = gfc_current_locus;
   gfc_gobble_whitespace ();

+  x_hex = 0;
   switch (gfc_next_char ())
     {
     case 'b':
@@ -255,12 +256,7 @@ match_boz_constant (gfc_expr ** result)
       rname = "octal";
       break;
     case 'x':
-      if (pedantic
-         && (gfc_notify_std (GFC_STD_GNU, "Extension: Hexadecimal "
-                            "constant at %C uses non-standard syntax.")
-             == FAILURE))
-       goto backup;
-
+      x_hex = 1;
       /* Fall through.  */
     case 'z':
       radix = 16;
@@ -310,6 +306,16 @@ match_boz_constant (gfc_expr ** result)
       return MATCH_ERROR;
     }

+  if (x_hex
+      && pedantic
+      && (gfc_notify_std (GFC_STD_GNU, "Extension: Hexadecimal "
+                         "constant at %C uses non-standard syntax.")
+         == FAILURE))
+    {
+      gfc_free_expr (e);
+      return MATCH_ERROR;
+    }
+
   *result = e;
   return MATCH_YES;

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

end of thread, other threads:[~2004-07-11 14:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-11 17:48 [gfortran] Fix PR 16433 Tobias Schlüter
2004-07-11 18:07 ` Paul Brook

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