public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3513] Fortran: BOZ literal constants are not compatible to any type [PR103413]
@ 2022-10-26 20:31 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-10-26 20:31 UTC (permalink / raw)
  To: gcc-cvs

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

commit r13-3513-gf7d28818179247685f3c101f9f2f16366f56309b
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Oct 26 21:00:44 2022 +0200

    Fortran: BOZ literal constants are not compatible to any type [PR103413]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/103413
            * symbol.cc (gfc_type_compatible): A boz-literal-constant has no type
            and thus is not considered compatible to any type.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/103413
            * gfortran.dg/illegal_boz_arg_4.f90: New test.

Diff:
---
 gcc/fortran/symbol.cc                           |  4 ++++
 gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90 | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 6050359d521..49fb37864bd 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -5139,6 +5139,10 @@ gfc_type_compatible (gfc_typespec *ts1, gfc_typespec *ts2)
   bool is_union1 = (ts1->type == BT_UNION);
   bool is_union2 = (ts2->type == BT_UNION);
 
+  /* A boz-literal-constant has no type.  */
+  if (ts1->type == BT_BOZ || ts2->type == BT_BOZ)
+    return false;
+
   if (is_class1
       && ts1->u.derived->components
       && ((ts1->u.derived->attr.is_class
diff --git a/gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90 b/gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90
new file mode 100644
index 00000000000..856cfa9211f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-options "-std=f2018" }
+! PR fortran/103413
+! Contributed by G.Steinmetz
+
+program p
+  type t
+     class(*), allocatable :: a
+  end type
+  type(t) :: x
+  allocate (x%a, source=z'1') ! { dg-error "type incompatible" }
+  allocate (x%a, mold=z'1')   ! { dg-error "type incompatible" }
+end

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-26 20:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 20:31 [gcc r13-3513] Fortran: BOZ literal constants are not compatible to any type [PR103413] Harald Anlauf

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).