]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR93253 – Document BOZ changes, make it friendlier in legacy code
authorTobias Burnus <tobias@codesourcery.com>
Thu, 16 Jan 2020 07:50:57 +0000 (08:50 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Thu, 16 Jan 2020 07:50:57 +0000 (08:50 +0100)
        PR fortran/93253
        * check.c (gfc_invalid_boz): Mention -fallow-invalid-boz
        in the error message.
        * gfortran.texi (BOZ literal constants): List another missing
        extension and refer to -fallow-invalid-boz.
        * lang.opt (fallow-invalid-boz): Also mention 'X' in the help text
        as it is not covered by the previous wording.
        * primary.c (match_boz_constant): Tweak wording such that it is
        clear how to fix the nonstandard use.

        PR fortran/93253
        * fortran.dg/boz_7.f90: Updated dg-error.

gcc/fortran/ChangeLog
gcc/fortran/check.c
gcc/fortran/gfortran.texi
gcc/fortran/lang.opt
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/boz_7.f90

index c3ca3dedd291148439572bc44a6d98424a53f647..889f01bce26b8add24901c698493e36be8341558 100644 (file)
@@ -1,3 +1,15 @@
+2020-01-16  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93253
+       * check.c (gfc_invalid_boz): Mention -fallow-invalid-boz
+       in the error message.
+       * gfortran.texi (BOZ literal constants): List another missing
+       extension and refer to -fallow-invalid-boz.
+       * lang.opt (fallow-invalid-boz): Also mention 'X' in the help text
+       as it is not covered by the previous wording.
+       * primary.c (match_boz_constant): Tweak wording such that it is
+       clear how to fix the nonstandard use.
+
 2020-01-09  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/65428
index c7f0187b3774ca494ab83ea1cccfeee51f0a8317..519aa8b8c2b640b4ee8fa03211aa7b810e47eab2 100644 (file)
@@ -67,7 +67,12 @@ gfc_invalid_boz (const char *msg, locus *loc)
       return false;
     }
 
-  gfc_error (msg, loc);
+  const char hint[] = " [see %<-fno-allow-invalid-boz%>]";
+  size_t len = strlen (msg) + strlen (hint) + 1;
+  char *msg2 = (char *) alloca (len);
+  strcpy (msg2, msg);
+  strcat (msg2, hint);
+  gfc_error (msg2, loc);
   return true;
 }
 
index 4cf8b3a5c24960d6aebc29257ce28cf041a4c8db..a50634ab9d26cbb5e628d3058d99847e55da7051 100644 (file)
@@ -1863,9 +1863,12 @@ Fortran standard states that the treatment of the sign bit is processor
 dependent.  Gfortran interprets the sign bit as a user would expect.
 
 As a deprecated extension, GNU Fortran allows hexadecimal BOZ literal
-constants to be specified using the @code{X} prefix.  The BOZ literal
+constants to be specified using the @code{X} prefix.  That the BOZ literal
 constant can also be specified by adding a suffix to the string, for
-example, @code{Z'ABC'} and @code{'ABC'X} are equivalent.
+example, @code{Z'ABC'} and @code{'ABC'X} are equivalent.  Additionally,
+as extension, BOZ literals are permitted in some contexts outside of
+@code{DATA} and the intrinsic functions listed in the Fortran standard.
+Use @option{-fallow-invalid-boz} to enable the extension.
 
 @node Real array indices
 @subsection Real array indices
index 3858331bcc0962185e14d266ce09053cbe35565b..59523f74acf9189a277971fdcf70f39c70a07f5c 100644 (file)
@@ -387,7 +387,7 @@ All intrinsics procedures are available regardless of selected standard.
 
 fallow-invalid-boz
 Fortran RejectNegative Var(flag_allow_invalid_boz)
-Allow a BOZ literal constant to appear in an invalid context.
+Allow a BOZ literal constant to appear in an invalid context and with X instead of Z.
 
 fallow-leading-underscore
 Fortran Undocumented Var(flag_allow_leading_underscore)
index e2b6fcb21062f259ec5775e078f62920d45006c4..07b8ac08ba20faf99bf91d3d144f01ea7d712b89 100644 (file)
@@ -433,7 +433,7 @@ match_boz_constant (gfc_expr **result)
 
   if (x_hex
       && gfc_invalid_boz ("Hexadecimal constant at %L uses "
-                         "nonstandard syntax", &gfc_current_locus))
+                         "nonstandard X instead of Z", &gfc_current_locus))
     return MATCH_ERROR;
 
   old_loc = gfc_current_locus;
index 143fda91d17d80cf2c10b8b4b1a9214510276f9c..d6ba8d6474d4f48ac0890b0466e62a2cca0f6674 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-16  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93253
+       * fortran.dg/boz_7.f90: Updated dg-error.
+
 2020-01-15  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/91073
index 45fa7a7df19a83d894876cbc8558cdf3d1e6813f..d2a51ac03e206f38bfb7055fb0923454514116b5 100644 (file)
@@ -7,6 +7,6 @@
 !
 integer :: k, m
 integer :: j = z'000abc' ! { dg-error "BOZ used outside a DATA statement" }
-data k/x'0003'/ ! { dg-error "nonstandard syntax" }
+data k/x'0003'/ ! { dg-error "nonstandard X instead of Z" }
 data m/'0003'z/ ! { dg-error "nonstandard postfix" }
 end