This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] Fix PR 16433


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]