fix PR 86484 and PR 84543
authorJanus Weil <janus@gcc.gnu.org>
Sun, 16 Sep 2018 19:57:52 +0000 (21:57 +0200)
committerJanus Weil <janus@gcc.gnu.org>
Sun, 16 Sep 2018 19:57:52 +0000 (21:57 +0200)
2018-09-16  Janus Weil  <janus@gcc.gnu.org>

PR fortran/86484
PR fortran/84543
* match.c (gfc_match_assignment): For a polymorphic assignment,
make sure that the vtab for the rhs type is generated.

2018-09-16  Janus Weil  <janus@gcc.gnu.org>

PR fortran/86484
PR fortran/84543
* gfortran.dg/class_assign_2.f90: New test case.
* gfortran.dg/class_assign_3.f90: New test case.

From-SVN: r264350

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_assign_2.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/class_assign_3.f90 [new file with mode: 0644]

index 6f4872e65d690c8784f85475a18411be27792f98..4c6c2445d1ac822a13107084edce3a75141fc5ee 100644 (file)
@@ -1,3 +1,10 @@
+2018-09-16  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/86484
+       PR fortran/84543
+       * match.c (gfc_match_assignment): For a polymorphic assignment,
+       make sure that the vtab for the rhs type is generated.
+
 2018-09-16  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/37802
index 85247dd8334e4686fe08d3f42a33144d12608d33..badd3c4a5dee5b00080f955f819cbb3b7ca17e07 100644 (file)
@@ -1366,6 +1366,9 @@ gfc_match_assignment (void)
 
   gfc_check_do_variable (lvalue->symtree);
 
+  if (lvalue->ts.type == BT_CLASS)
+    gfc_find_vtab (&rvalue->ts);
+
   return MATCH_YES;
 }
 
index e37c1773bffd489be99f8d014812a954854174e2..79ecbb7f61af17db4618c57a24ad9b674c29b541 100644 (file)
@@ -1,3 +1,10 @@
+2018-09-16  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/86484
+       PR fortran/84543
+       * gfortran.dg/class_assign_2.f90: New test case.
+       * gfortran.dg/class_assign_3.f90: New test case.
+
 2018-09-16  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/37802
diff --git a/gcc/testsuite/gfortran.dg/class_assign_2.f90 b/gcc/testsuite/gfortran.dg/class_assign_2.f90
new file mode 100644 (file)
index 0000000..3b8db4a
--- /dev/null
@@ -0,0 +1,22 @@
+! { dg-do link }
+!
+! PR 86484:[OOP] Undefined symbol when using polymorphic intrinsic assignment
+!
+! Contributed by Rich Townsend <townsend@astro.wisc.edu>
+
+program test_assign
+
+  implicit none
+
+  type :: foo_t
+  end type
+
+  type, extends (foo_t) :: bar_t
+  end type
+
+  class(foo_t), allocatable :: f
+  type(bar_t)               :: b
+
+  f = b
+
+end
diff --git a/gcc/testsuite/gfortran.dg/class_assign_3.f90 b/gcc/testsuite/gfortran.dg/class_assign_3.f90
new file mode 100644 (file)
index 0000000..e51651e
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do link }
+!
+! PR 84543: undefined reference to __copy_INTEGER_4_.3788
+!
+! Contributed by Neil Carlson <neil.n.carlson@gmail.com>
+
+class(*), allocatable :: x
+x = 42
+end