public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-9418] Fortran: BOZ literal constants are not interoperable
Date: Mon, 27 Dec 2021 19:51:15 +0000 (GMT)	[thread overview]
Message-ID: <20211227195115.181E33858438@sourceware.org> (raw)

https://gcc.gnu.org/g:e6dcc14640105d2daf9c7f279980543470be7866

commit r11-9418-ge6dcc14640105d2daf9c7f279980543470be7866
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Dec 20 22:12:33 2021 +0100

    Fortran: BOZ literal constants are not interoperable
    
    gcc/fortran/ChangeLog:
    
            PR fortran/103778
            * check.c (is_c_interoperable): A BOZ literal constant is not
            interoperable.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/103778
            * gfortran.dg/illegal_boz_arg_3.f90: New test.
    
    (cherry picked from commit ff0ad4b5e16b8828a6147ae2d5fec8068ef0778e)

Diff:
---
 gcc/fortran/check.c                             | 6 ++++++
 gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90 | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 6341756bf3e..e110ca01f2f 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -5181,6 +5181,12 @@ is_c_interoperable (gfc_expr *expr, const char **msg, bool c_loc, bool c_f_ptr)
       return false;
     }
 
+  if (expr->ts.type == BT_BOZ)
+    {
+      *msg = "BOZ literal constant";
+      return false;
+    }
+
   if (expr->ts.type == BT_CLASS)
     {
       *msg = "Expression is polymorphic";
diff --git a/gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90 b/gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90
new file mode 100644
index 00000000000..59fefa90971
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/103778
+
+program p
+  use iso_c_binding, only : c_sizeof
+  integer, parameter :: a = c_sizeof(z'1') ! { dg-error "cannot appear" }
+end


                 reply	other threads:[~2021-12-27 19:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211227195115.181E33858438@sourceware.org \
    --to=anlauf@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).