* [PATCH] PR fortran/78746 - invalid access after error recovery
@ 2021-01-05 20:41 Harald Anlauf
2021-01-06 15:50 ` Thomas Koenig
0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2021-01-05 20:41 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 922 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr78746.patch --]
[-- Type: text/x-patch, Size: 420 bytes --]
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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PR fortran/78746 - invalid access after error recovery
2021-01-05 20:41 [PATCH] PR fortran/78746 - invalid access after error recovery Harald Anlauf
@ 2021-01-06 15:50 ` Thomas Koenig
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2021-01-06 15:50 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches
Hi Harald,
> OK for master? Open branches where testcase class_61.f90 exists?
OK for both (as you wrote, this one is really obvious).
Best regards
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-06 15:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 20:41 [PATCH] PR fortran/78746 - invalid access after error recovery Harald Anlauf
2021-01-06 15:50 ` Thomas Koenig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).