]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR fortran/78746 - invalid access after error recovery
authorHarald Anlauf <anlauf@gmx.de>
Wed, 6 Jan 2021 18:37:11 +0000 (19:37 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Thu, 7 Jan 2021 19:19:53 +0000 (20:19 +0100)
The error recovery after an invalid reference to an undefined CLASS
during a TYPE declaration lead to an invalid access.  Add a check.

gcc/fortran/ChangeLog:

* resolve.c (resolve_component): Add check for valid CLASS
reference before trying to access CLASS data.

(cherry picked from commit 8b6f1e8f97fe0d435d334075821149dbd85c8266)

gcc/fortran/resolve.c

index b210d9c881ddfa8fea79c674bda03d0a337e00e9..2a6f648ad5f6a20d16fb4af1837803b94ca06669 100644 (file)
@@ -14326,7 +14326,7 @@ resolve_component (gfc_component *c, gfc_symbol *sym)
   /* F2008, C448.  */
   if (c->ts.type == BT_CLASS)
     {
-      if (CLASS_DATA (c))
+      if (c->attr.class_ok && CLASS_DATA (c))
        {
          attr = &(CLASS_DATA (c)->attr);