]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/90498 (ICE with select type/associate and derived type argument contain...
authorPaul Thomas <pault@gcc.gnu.org>
Sun, 19 May 2019 18:08:28 +0000 (18:08 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sun, 19 May 2019 18:08:28 +0000 (18:08 +0000)
2019-05-19  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/90498
* trans-stmt.c (trans_associate_var) Do not use the saved
descriptor if the expression is a COMPONENT_REF.

2019-05-19  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/90498
* gfortran.dg/associate_48.f90 : New test.

From-SVN: r271383

gcc/fortran/ChangeLog
gcc/fortran/trans-stmt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/associate_48.f90 [new file with mode: 0644]

index f992eb1889be3b8e9c0208b6641c1e0d9bc918c9..e0439881b0b60958d2788de1c10605c77cfabfba 100644 (file)
@@ -1,7 +1,14 @@
+2019-05-19  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backport from trunk
+       PR fortran/90498
+       * trans-stmt.c (trans_associate_var) Do not use the saved
+       descriptor if the expression is a COMPONENT_REF.
+
 2019-05-15  Janne Blomqvist  <jb@gcc.gnu.org>
 
        Backport from trunk
-        * parse.c (gfc_parse_file): Remove translation string markers.
+       * parse.c (gfc_parse_file): Remove translation string markers.
 
 2019-05-12  Janne Blomqvist  <jb@gcc.gnu.org>
 
index b9966ed93184f41828203ae813b2901641b4b436..5fa182bf05a936116d9b5105954072754c87d891 100644 (file)
@@ -1858,7 +1858,8 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block)
            {
              if (e->symtree
                  && DECL_LANG_SPECIFIC (e->symtree->n.sym->backend_decl)
-                && GFC_DECL_SAVED_DESCRIPTOR (e->symtree->n.sym->backend_decl))
+                 && GFC_DECL_SAVED_DESCRIPTOR (e->symtree->n.sym->backend_decl)
+                 && TREE_CODE (target_expr) != COMPONENT_REF)
                /* Use the original class descriptor stored in the saved
                   descriptor to get the target_expr.  */
                target_expr =
index 10e2f87307da9c9e8443cfd69bb89e49b9347a96..ba936a8b8eea5dbb66fb7814a259f3e20bed4d91 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-19  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backport from trunk
+       PR fortran/90498
+       * gfortran.dg/associate_48.f90 : New test.
+
 2019-05-17  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
diff --git a/gcc/testsuite/gfortran.dg/associate_48.f90 b/gcc/testsuite/gfortran.dg/associate_48.f90
new file mode 100644 (file)
index 0000000..5ce3a49
--- /dev/null
@@ -0,0 +1,41 @@
+! { dg=do run }
+!
+! Test the fix for PR90498.
+!
+! Contributed by Vladimir Fuka  <vladimir.fuka@gmail.com>
+!
+  type field_names_a
+    class(*), pointer :: var(:) =>null()
+  end type
+
+  type(field_names_a),pointer :: a(:)
+  allocate (a(2))
+
+  allocate (a(1)%var(2), source = ["hello"," vlad"])
+  allocate (a(2)%var(2), source = ["HELLO"," VLAD"])
+  call s(a)
+  deallocate (a(1)%var)
+  deallocate (a(2)%var)
+  deallocate (a)
+contains
+  subroutine s(a)
+
+    type(field_names_a) :: a(:)
+
+    select type (var => a(1)%var)
+      type is (character(*))
+        if (any (var .ne. ["hello"," vlad"])) stop 1
+      class default
+        stop
+    end select
+
+    associate (var => a(2)%var)
+      select type (var)
+        type is (character(*))
+          if (any (var .ne. ["HELLO"," VLAD"])) stop 2
+        class default
+          stop
+      end select
+    end associate
+  end
+end