aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSteve Kargl <kargl@gcc.gnu.org>2022-12-22 20:38:57 -0800
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2022-12-22 21:19:39 -0800
commit7e76cd96950f49ce21246d44780e972d86b2bcdd (patch)
treeb823c1e9b507eb1ba3af99c6172eca58ebb81cfa /gcc
parent8ec5fcb6fc79e5bcca23c3fecbaf09d4566cb1d5 (diff)
downloadgcc-7e76cd96950f49ce21246d44780e972d86b2bcdd.zip
gcc-7e76cd96950f49ce21246d44780e972d86b2bcdd.tar.gz
gcc-7e76cd96950f49ce21246d44780e972d86b2bcdd.tar.bz2
Remove not needed assert macro which fails.
PR fortran/106731 gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_auto_array_allocation): Remove gcc_assert (!TREE_STATIC()). gcc/testsuite/ChangeLog: * gfortran.dg/pr106731.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/trans-array.cc1
-rw-r--r--gcc/testsuite/gfortran.dg/pr106731.f9058
2 files changed, 58 insertions, 1 deletions
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index b7d4c41..44177aa 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -6614,7 +6614,6 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym,
type = TREE_TYPE (type);
gcc_assert (!sym->attr.use_assoc);
- gcc_assert (!TREE_STATIC (decl));
gcc_assert (!sym->module);
if (sym->ts.type == BT_CHARACTER
diff --git a/gcc/testsuite/gfortran.dg/pr106731.f90 b/gcc/testsuite/gfortran.dg/pr106731.f90
new file mode 100644
index 0000000..470830c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr106731.f90
@@ -0,0 +1,58 @@
+! { dg-do run }
+! PR106731 ICE on automatic array of derived type
+module causes_ice
+ implicit none
+
+ type :: t
+ real(8) :: x
+ contains
+ procedure, private :: write_formatted
+ generic :: write(formatted) => write_formatted
+ end type t
+
+ contains
+
+ subroutine write_formatted(this, unit, iotype, v_list, iostat, iomsg)
+ class(t), intent(in) :: this
+ integer, intent(in) :: unit
+ character(*), intent(in) :: iotype
+ integer, intent(in) :: v_list(:)
+ integer, intent(out) :: iostat
+ character(*), intent(inout) :: iomsg
+ write(unit, '(a,3x,f10.5)', iostat=iostat, iomsg=iomsg) 'dummy', this%x
+ end subroutine write_formatted
+
+end module causes_ice
+
+module use_t
+ use causes_ice
+ implicit none
+
+ public :: automatic_alloc
+
+ contains
+
+ subroutine automatic_alloc(n)
+ integer, intent(in) :: n
+
+ ! Automatic array: ICE!
+ type(t) :: automatic(n)
+
+ ! Allocatable: works
+ type(t), allocatable :: alloc(:)
+ allocate(alloc(n))
+
+ automatic%x = 42.34675_8
+
+ ! Do anything
+ print *, 'n=',n,automatic%x
+ print *, 'n=',n,automatic
+
+ end subroutine automatic_alloc
+
+end module use_t
+
+program test
+ use use_t
+ call automatic_alloc(1)
+end program test