re PR fortran/56575 (An invalid OO code causes ICE)
authorPaul Thomas <pault@gcc.gnu.org>
Sun, 10 Mar 2013 13:23:58 +0000 (13:23 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sun, 10 Mar 2013 13:23:58 +0000 (13:23 +0000)
2013-03-10  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/56575
* expr.c (gfc_default_initializer): Check that a class declared
type has any components.
* resolve.c (resolve_fl_derived0): On failing the test for C437
set the type to BT_UNKNOWN to prevent repeat error messages.
2013-03-10  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/56575
* gfortran.dg/class_56.f90: New test.

From-SVN: r196580

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_56.f90 [new file with mode: 0644]

index 4431327a5ec4c7767854b51f332dcbcffee4ae0b..e7e52316ccfc90fe67daea745846683266b1ba59 100644 (file)
@@ -1,3 +1,11 @@
+2013-03-10  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/56575
+       * expr.c (gfc_default_initializer): Check that a class declared
+       type has any components.
+       * resolve.c (resolve_fl_derived0): On failing the test for C437
+       set the type to BT_UNKNOWN to prevent repeat error messages.
+
 2013-03-03  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/56477
index fd17a05f361c33d17912f2ba6dd38d85cbaca52f..1b74a44ab74ff8b48e2266c71747afc131506d9e 100644 (file)
@@ -3886,7 +3886,8 @@ gfc_default_initializer (gfc_typespec *ts)
      types (otherwise we could use gfc_has_default_initializer()).  */
   for (comp = ts->u.derived->components; comp; comp = comp->next)
     if (comp->initializer || comp->attr.allocatable
-       || (comp->ts.type == BT_CLASS && CLASS_DATA (comp)->attr.allocatable))
+       || (comp->ts.type == BT_CLASS && CLASS_DATA (comp)
+           && CLASS_DATA (comp)->attr.allocatable))
       break;
 
   if (!comp)
index 01e68aba785191574a66c1f3a1ecc09df6e9fe01..bb0b946c9b3fd2cfc57427d9ad31bed80e7709d1 100644 (file)
@@ -12866,6 +12866,8 @@ resolve_fl_derived0 (gfc_symbol *sym)
        {
          gfc_error ("Component '%s' with CLASS at %L must be allocatable "
                     "or pointer", c->name, &c->loc);
+         /* Prevent a recurrence of the error.  */
+         c->ts.type = BT_UNKNOWN;
          return FAILURE;
        }
 
index 15156f7ae8c61dc8f3980d7aeb83576e4ef6f6ed..a63991ec35b3987e235474568136552a3e77dbca 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-10  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/56575
+       * gfortran.dg/class_56.f90: New test.
+
 2013-03-09  Richard Sandiford  <rdsandiford@googlemail.com>
 
        PR middle-end/56524
 2013-02-21  Marek Polacek  <polacek@redhat.com>
 
        PR tree-optimization/56398
-       * g++.dg/torture/pr56398.C: New test. 
+       * g++.dg/torture/pr56398.C: New test.
 
 2013-02-21  Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/gcc/testsuite/gfortran.dg/class_56.f90 b/gcc/testsuite/gfortran.dg/class_56.f90
new file mode 100644 (file)
index 0000000..26df798
--- /dev/null
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! Test fix for PR56575.
+!
+! Contributed by A Kasahara  <latlon90180+gcc_bugzilla@gmail.com>
+!
+module lib_container
+  implicit none
+
+  type:: Object
+  end type Object
+
+  type:: Container
+    class(Object):: v ! { dg-error "must be allocatable or pointer" }
+  end type Container
+
+contains
+
+  subroutine proc(self)
+    class(Container), intent(inout):: self
+  end subroutine proc
+end module lib_container
+