]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: BOZ literal constants are not interoperable
authorHarald Anlauf <anlauf@gmx.de>
Mon, 20 Dec 2021 21:12:33 +0000 (22:12 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Mon, 27 Dec 2021 19:51:54 +0000 (20:51 +0100)
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)

gcc/fortran/check.c
gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90 [new file with mode: 0644]

index 6a5b842d5a153a8b0e2176a375ea30ff4a0dd20c..eab12e9388795e598d20a9f955d5e0a68404e52b 100644 (file)
@@ -5194,6 +5194,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 (file)
index 0000000..59fefa9
--- /dev/null
@@ -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