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.
This commit is contained in:
parent
068baae186
commit
f7d2881817
2 changed files with 17 additions and 0 deletions
|
@ -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
|
||||
|
|
13
gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90
Normal file
13
gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue