]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/82814 (ICE from submodule character function)
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 17 May 2018 15:31:42 +0000 (15:31 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 17 May 2018 15:31:42 +0000 (15:31 +0000)
2017-05-17  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/82814
* gfortran.dg/submodule_31.f08: New test.

From-SVN: r260325

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/submodule_31.f08 [new file with mode: 0644]

index ad4945ec1c0ced316599d628cd0c7eca4337e376..3bf4e5c6727fe76e4dc47cd3c146cb8f517fdce4 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-17  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/82814
+       Backport from trunk
+       * gfortran.dg/submodule_31.f08: New test.
+
 2018-05-16  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/83149
diff --git a/gcc/testsuite/gfortran.dg/submodule_31.f08 b/gcc/testsuite/gfortran.dg/submodule_31.f08
new file mode 100644 (file)
index 0000000..72594d0
--- /dev/null
@@ -0,0 +1,54 @@
+! { dg-do run }
+!
+! Test the fix for PR82814 in which an ICE occurred for the submodule allocation.
+!
+! Contributed by "Werner Blokbuster"  <werner.blokbuster@gmail.com>
+!
+module u
+
+    implicit none
+
+    interface unique
+        module function uniq_char(input) result(uniq)
+            character(*), intent(in) :: input(:)
+            character(size(input)), allocatable :: uniq(:)
+        end function uniq_char
+    end interface unique
+
+contains
+
+    module function uniq2(input) result(uniq)
+        character(*), intent(in) :: input(:)
+        character(size(input)), allocatable :: uniq(:)
+            allocate(uniq(1))
+            uniq = 'A'
+    end function uniq2
+
+end module u
+
+
+submodule (u) z
+
+    implicit none
+
+contains
+
+    module function uniq_char(input) result(uniq)
+        character(*), intent(in) :: input(:)
+        character(size(input)), allocatable :: uniq(:)
+            allocate(uniq(1)) ! This used to ICE
+            uniq = 'A'
+    end function uniq_char
+
+end submodule z
+
+
+program test_uniq
+    use u
+    implicit none
+    character(1), dimension(4) :: chr = ['1','2','1','2']
+
+    write(*,*) unique(chr)
+    write(*,*) uniq2(chr)
+
+end program test_uniq