]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2016-11-30 Janus Weil <janus@gcc.gnu.org>
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Nov 2016 07:25:36 +0000 (07:25 +0000)
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Nov 2016 07:25:36 +0000 (07:25 +0000)
PR fortran/78573
* decl.c (build_struct): On error, return directly and do not build
class symbol.

2016-11-30  Janus Weil  <janus@gcc.gnu.org>

PR fortran/78573
* gfortran.dg/class_61.f90: New test case.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242996 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_61.f90 [new file with mode: 0644]

index d0dd3063f9a8cbeb5340a56b55838914287175c9..840eb8f17b8e6c4fcc2a8fcae74f48fe7ea23b5d 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-30  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/78573
+       * decl.c (build_struct): On error, return directly and do not build
+       class symbol.
+
 2016-11-29  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/58175
index 21eaafe488f0dbf0dd4e5388cd5d80b033c1ecb2..411d496dd5b443600bd46328b07bc71a5ce99489 100644 (file)
@@ -1850,7 +1850,6 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init,
 {
   gfc_state_data *s;
   gfc_component *c;
-  bool t = true;
 
   /* F03:C438/C439. If the current symbol is of the same derived type that we're
      constructing, it must have the pointer attribute.  */
@@ -1952,7 +1951,7 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init,
        {
          gfc_error ("Pointer array component of structure at %C must have a "
                     "deferred shape");
-         t = false;
+         return false;
        }
     }
   else if (c->attr.allocatable)
@@ -1961,7 +1960,7 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init,
        {
          gfc_error ("Allocatable component of structure at %C must have a "
                     "deferred shape");
-         t = false;
+         return false;
        }
     }
   else
@@ -1970,20 +1969,15 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init,
        {
          gfc_error ("Array component of structure at %C must have an "
                     "explicit shape");
-         t = false;
+         return false;
        }
     }
 
 scalar:
   if (c->ts.type == BT_CLASS)
-    {
-      bool t2 = gfc_build_class_symbol (&c->ts, &c->attr, &c->as);
+    return gfc_build_class_symbol (&c->ts, &c->attr, &c->as);
 
-      if (t)
-       t = t2;
-    }
-
-  return t;
+  return true;
 }
 
 
index aeac71a5847bcafb2fb88a151284a11bff147d47..47e41fcd369363a8d52d74981ee05c5be61e7c48 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-30  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/78573
+       * gfortran.dg/class_61.f90: New test case.
+
 2016-11-29  David Malcolm  <dmalcolm@redhat.com>
 
        PR preprocessor/78569
diff --git a/gcc/testsuite/gfortran.dg/class_61.f90 b/gcc/testsuite/gfortran.dg/class_61.f90
new file mode 100644 (file)
index 0000000..207e1e8
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+!
+! PR 78573: [7 Regression] [OOP] ICE in resolve_component, at fortran/resolve.c:13405
+!
+! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de>
+
+program p
+  type t1
+    class(t2), pointer :: q(2)  ! { dg-error "must have a deferred shape" }
+  end type
+end