]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/56575 (An invalid OO code causes ICE)
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 13 Mar 2013 05:32:07 +0000 (05:32 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 13 Mar 2013 05:32:07 +0000 (05:32 +0000)
2013-03-13  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-13  Paul Thomas  <pault@gcc.gnu.org>

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

From-SVN: r196627

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 1539ccef81faa95f9c2665f9eb6ae8d903f1adcc..6ffba521238c9d489c7c3c1c592e2d49bfe0ebf6 100644 (file)
@@ -1,3 +1,11 @@
+2013-03-13  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/55362
index 8e52c472bada16930d4124a2d831233b49ef7fea..0ad7f7b5b9ee4b40656319993fc506e4fa98a9a0 100644 (file)
@@ -3759,7 +3759,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 17efdb5b37385b99176ef1edfc8973f09d7c223e..8729e1567be4c1d70294916f6302d58aa70497f7 100644 (file)
@@ -11967,6 +11967,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 e81622ae8a46e38aa73c5bdbf9fcdeb293c6a824..36b521b5ec4dd43c63731a25c93765eb8ffe3dea 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-13  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/56575
+       * gfortran.dg/class_56.f90: New test.
+
 2013-03-10  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/55362
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..7ec4bda
--- /dev/null
@@ -0,0 +1,21 @@
+! { 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