]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/88357 (ICE in parse_associate, at fortran/parse.c:4568)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 8 Dec 2018 18:09:05 +0000 (18:09 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 8 Dec 2018 18:09:05 +0000 (18:09 +0000)
2018-12-08  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/88357
* class.c (insert_component_ref): Check for NULL pointer and
previous error message issued.
* parse.c (parse_associate): Check for NULL pointer.
* resolve.c (resolve_assoc_var): Check for NULL pointer.

2018-12-08  Steven G. Kargl  <kargl@gcc.gnu.org>

* gfortran.dg/pr88357_1.f90: New test.
* gfortran.dg/pr88357_2.f90: New test.

From-SVN: r266908

gcc/fortran/ChangeLog
gcc/fortran/class.c
gcc/fortran/parse.c
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr88357_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr88357_2.f90 [new file with mode: 0644]

index 9e17decbe18856b0ad8727398e3491934eaf1c64..8603e431f73fd2944d36ff3f8f0c2bd3cf12b7b7 100644 (file)
@@ -1,3 +1,11 @@
+2018-12-08  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/88357
+       * class.c (insert_component_ref): Check for NULL pointer and 
+       previous error message issued.
+       * parse.c (parse_associate): Check for NULL pointer.
+       * resolve.c (resolve_assoc_var): Check for NULL pointer.
+
 2018-12-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/88377
index 2eae7f0f3515f8af237627625a9a038c966f9e07..105511d03ccc6b5d428ff52a62bffee8d220ae80 100644 (file)
@@ -72,14 +72,18 @@ along with GCC; see the file COPYING3.  If not see
 static void
 insert_component_ref (gfc_typespec *ts, gfc_ref **ref, const char * const name)
 {
-  gfc_symbol *type_sym;
   gfc_ref *new_ref;
+  int wcnt, ecnt;
 
   gcc_assert (ts->type == BT_DERIVED || ts->type == BT_CLASS);
-  type_sym = ts->u.derived;
 
-  gfc_find_component (type_sym, name, true, true, &new_ref);
+  gfc_find_component (ts->u.derived, name, true, true, &new_ref);
+
+  gfc_get_errors (&wcnt, &ecnt);
+  if (ecnt > 0 && !new_ref)
+    return;
   gcc_assert (new_ref->u.c.component);
+
   while (new_ref->next)
     new_ref = new_ref->next;
   new_ref->next = *ref;
index 56d0d050bc3b07206177c6bfad4f3c52377e9394..7acd8cfa4fbbc311ebb87da4d12f77bcb4dbbacb 100644 (file)
@@ -4563,7 +4563,7 @@ parse_associate (void)
          else
            rank = a->target->rank;
          /* When the rank is greater than zero then sym will be an array.  */
-         if (sym->ts.type == BT_CLASS)
+         if (sym->ts.type == BT_CLASS && CLASS_DATA (sym))
            {
              if ((!CLASS_DATA (sym)->as && rank != 0)
                  || (CLASS_DATA (sym)->as
index b2090218d48637d6c27196d8d0fd46bcc639bd80..35352c6757fc70364d16870d804a03958fa6e4e3 100644 (file)
@@ -8715,7 +8715,8 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target)
     {
       /* target's rank is 0, but the type of the sym is still array valued,
         which has to be corrected.  */
-      if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as)
+      if (sym->ts.type == BT_CLASS
+         && CLASS_DATA (sym) && CLASS_DATA (sym)->as)
        {
          gfc_array_spec *as;
          symbol_attribute attr;
index dc7c20416194342c6115d11ebfac1abb6e173bc0..f4a7885e0af7117bda80bc84711dcae78acc0f2a 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-08  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       * gfortran.dg/pr88357_1.f90: New test.
+       * gfortran.dg/pr88357_2.f90: New test.
+
 2018-12-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/88304
diff --git a/gcc/testsuite/gfortran.dg/pr88357_1.f90 b/gcc/testsuite/gfortran.dg/pr88357_1.f90
new file mode 100644 (file)
index 0000000..5cda86e
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+program p
+   type t
+   end type
+   class(t) :: x[*]     ! { dg-error "must be dummy, allocatable or pointer" }
+   associate (y => x)
+   end associate
+end
diff --git a/gcc/testsuite/gfortran.dg/pr88357_2.f90 b/gcc/testsuite/gfortran.dg/pr88357_2.f90
new file mode 100644 (file)
index 0000000..d89511b
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+program p
+   type t
+   end type
+   class(t) :: x     ! { dg-error "must be dummy, allocatable or pointer" }
+   associate (y => x)
+   end associate
+end