Dear all, the PR contains a lengthy discussion of several testcases, some which were considered invalid and thus removed from the testsuite (charlen_03.f90, charlen_10.f90), charlen_15.f90 was resolved elsewhere, so that only class_61.f90 was left with an invalid access after error recovery with an instrumented compiler.
I could reproduce the issue triggered by class_61.f90 using valgrind, and found that the attached trivial, almost obvious patch solves it. It even regtests cleanly on x86_64-pc-linux-gnu. OK for master? Open branches where testcase class_61.f90 exists? Thanks, Harald PR fortran/78746 - invalid access after error recovery 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.
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index fa6f756d285..891db391907 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -14384,7 +14396,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);