OSDN Git Service

2013-03-13 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Mar 2013 05:32:07 +0000 (05:32 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Mar 2013 05:32:07 +0000 (05:32 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@196627 138bc75d-0d04-0410-961f-82ee72b054a4

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 1539cce..6ffba52 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 8e52c47..0ad7f7b 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 17efdb5..8729e15 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 e81622a..36b521b 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