public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <burnus@net-b.de>
To: sgk@troutmask.apl.washington.edu,
	Tobias Burnus <tobias@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	fortran <fortran@gcc.gnu.org>,
	Gerald Pfeifer <gerald@pfeifer.com>
Subject: Re: [Patch, Fortran + wwwdocs] PR93253 – Document BOZ changes, make it friendlier in legacy code
Date: Wed, 15 Jan 2020 22:48:00 -0000	[thread overview]
Message-ID: <96a1ac0b-54e3-90a0-bef0-6a558b4c4905@net-b.de> (raw)
In-Reply-To: <20200115185646.GA3868@troutmask.apl.washington.edu>

[-- Attachment #1: Type: text/plain, Size: 930 bytes --]

Hi Steve,

regarding the release-notes text: I like your version – it helps if 
someone writes the text, who knows what changed. I have fixed a typo and 
adapted the syntax – see attachment. Any comment to it? Otherwise, I 
intent to commit it tomorrow.

Regarding the patch, I enclosed a revised version. Do you have more 
suggestions – or does it look okay now?

Thanks,

Tobias

On 1/15/20 7:56 PM, Steve Kargl wrote:
>> +    {
>> +      const char hint[] = ". Use %<-fallow-invalid-boz%> if you cannot fix it";
> Suggest adding ". [See %<-fallow-invalid-boz%>.]"

Followed your suggestion.

>> --- a/gcc/fortran/gfortran.texi
>> +++ b/gcc/fortran/gfortran.texi
I have reworded it a bit.
>> -			  "nonstandard syntax", &gfc_current_locus))
>> +			  "nonstandard X instead of Z", &gfc_current_locus))
> I suppose ok, but don't think a change is needed.
I still think the new version is more helpful. Hence …

[-- Attachment #2: BOZ-wwwdocs.diff --]
[-- Type: text/x-patch, Size: 1022 bytes --]

diff --git a/htdocs/gcc-10/changes.html b/htdocs/gcc-10/changes.html
index caa9df70..83404a1a 100644
--- a/htdocs/gcc-10/changes.html
+++ b/htdocs/gcc-10/changes.html
@@ -260,6 +260,16 @@ a work-in-progress.</p>
     with <code>-std=legacy</code>.  <code>-Wargument-mismatch</code>
     has been removed.
   </li>
+  <li>
+    The handling of a BOZ literal constant has been reworked to provide
+    better conformance to the Fortran 2008 and 2018 standards.  In these
+    Fortran standards, a BOZ literal constant is a typeless and kindless
+    entity.  As a part of the rework, documented and undocumented
+    extensions to the Fortran standard now emit errors during compilation.
+    Some these extensions are permitted with the
+    <code>-fallow-invalid-boz</code>, where the error is degraded to a
+    warning and the code is compiled as with older gfortran.
+  <li>
   <li>
     At any optimization level except<code>-Os</code>, gfortran now
     uses inline packing for arguments instead of calling a library

[-- Attachment #3: BOZ-diag-v2.diff --]
[-- Type: text/x-patch, Size: 3515 bytes --]

	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.

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index c7f0187b377..519aa8b8c2b 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -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;
 }
 
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 4cf8b3a5c24..a50634ab9d2 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -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
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index 3858331bcc0..59523f74acf 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -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)
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index e2b6fcb2106..07b8ac08ba2 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -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;
diff --git a/gcc/testsuite/gfortran.dg/boz_7.f90 b/gcc/testsuite/gfortran.dg/boz_7.f90
index 45fa7a7df19..d2a51ac03e2 100644
--- a/gcc/testsuite/gfortran.dg/boz_7.f90
+++ b/gcc/testsuite/gfortran.dg/boz_7.f90
@@ -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

  reply	other threads:[~2020-01-15 22:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 17:02 Tobias Burnus
2020-01-15 20:11 ` Steve Kargl
2020-01-15 22:48   ` Tobias Burnus [this message]
2020-01-15 23:57     ` Steve Kargl
2020-01-18 12:46     ` Gerald Pfeifer

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=96a1ac0b-54e3-90a0-bef0-6a558b4c4905@net-b.de \
    --to=burnus@net-b.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gerald@pfeifer.com \
    --cc=sgk@troutmask.apl.washington.edu \
    --cc=tobias@codesourcery.com \
    /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).