re PR fortran/79072 (ICE with class(*) pointer function result and character value)
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 22 Nov 2017 11:37:16 +0000 (11:37 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 22 Nov 2017 11:37:16 +0000 (11:37 +0000)
2017-11-22  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/79072
* trans-stmt.c (trans_associate_var): Weaken the over strong
condition for using the fake result decl.

2017-11-22  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/79072
* gfortran.dg/class_result_6.f90: New test for comment 10 of
the PR.

From-SVN: r255053

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

index 4ba7327be33e5b912dc8489d8cdb597cdc234d94..7fc965baf81c6a1351a8426e95520a34ac9e6353 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-22  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/79072
+       * trans-stmt.c (trans_associate_var): Weaken the over strong
+       condition for using the fake result decl.
+
 2017-11-20  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/79072
index 6cf798160997d55688717b619892af36249f37ba..db913bfe5156917d85df6f29138588a4d99db246 100644 (file)
@@ -1828,8 +1828,7 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block)
          tmp = e->symtree->n.sym->ts.u.cl->backend_decl;
        }
       else if (e->symtree->n.sym->attr.function
-              && e->symtree->n.sym == e->symtree->n.sym->result
-              && e->symtree->n.sym == e->symtree->n.sym->ns->proc_name)
+              && e->symtree->n.sym == e->symtree->n.sym->result)
        {
          tmp = gfc_get_fake_result_decl (e->symtree->n.sym, 0);
          tmp = gfc_class_len_get (tmp);
index 7bfd96b8e0221c26924b2eda5bab71e3af2936bb..39dd1446bac04a0e746c4e488961e3c2845b204a 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-22  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/79072
+       * gfortran.dg/class_result_6.f90: New test for comment 10 of
+       the PR.
+
 2017-11-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/83084
diff --git a/gcc/testsuite/gfortran.dg/class_result_6.f90 b/gcc/testsuite/gfortran.dg/class_result_6.f90
new file mode 100644 (file)
index 0000000..44e17a2
--- /dev/null
@@ -0,0 +1,24 @@
+! { dg-do run }
+!
+! Test the fix for PR79072 comment #12. A description of the problem
+! is to be found in class_result_5.f90.
+!
+! Contributed by Neil Carlson  <neil.n.carlson@gmail.com>
+!
+  character(3), target :: a = 'foo'
+  class(*), pointer :: b
+  b => ptr()
+  select type (b)
+    type is (character(*))
+      if (a .ne. "bar") call abort
+  end select
+contains
+  function ptr()
+    class(*), pointer :: ptr
+    ptr => a
+    select type (ptr)
+      type is (character(*))
+        ptr = "bar"
+    end select
+  end function
+end