* [PATCH] PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446
@ 2021-06-04 21:12 Harald Anlauf
2021-06-11 18:41 ` PING " Harald Anlauf
0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2021-06-04 21:12 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 706 bytes --]
ICE-on-invalid issues during error recovery. Testcase by Gerhard,
initial patch by Steve. I found another variant which needed an
additional fix for a NULL pointer dereference.
Regtested on x86_64-pc-linux-gnu.
OK for mainline / 11-branch?
Thanks,
Harald
Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446
Avoid NULL pointer dereferences during error recovery.
gcc/fortran/ChangeLog:
PR fortran/95502
* expr.c (gfc_check_pointer_assign): Avoid NULL pointer
dereference.
* match.c (gfc_match_pointer_assignment): Likewise.
* parse.c (gfc_check_do_variable): Avoid comparison with NULL
symtree.
gcc/testsuite/ChangeLog:
PR fortran/95502
* gfortran.dg/pr95502.f90: New test.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr95502.patch --]
[-- Type: text/x-patch, Size: 1706 bytes --]
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 956003ec605..b11ae7ce5c5 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3815,6 +3815,9 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
int proc_pointer;
bool same_rank;
+ if (!lvalue->symtree)
+ return false;
+
lhs_attr = gfc_expr_attr (lvalue);
if (lvalue->ts.type == BT_UNKNOWN && !lhs_attr.proc_pointer)
{
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 29462013038..d148de3e3b5 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -1409,7 +1409,7 @@ gfc_match_pointer_assignment (void)
gfc_matching_procptr_assignment = 0;
m = gfc_match (" %v =>", &lvalue);
- if (m != MATCH_YES)
+ if (m != MATCH_YES || !lvalue->symtree)
{
m = MATCH_NO;
goto cleanup;
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 0522b391393..6d7845e8517 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -4588,6 +4588,9 @@ gfc_check_do_variable (gfc_symtree *st)
{
gfc_state_data *s;
+ if (!st)
+ return 0;
+
for (s=gfc_state_stack; s; s = s->previous)
if (s->do_variable == st)
{
diff --git a/gcc/testsuite/gfortran.dg/pr95502.f90 b/gcc/testsuite/gfortran.dg/pr95502.f90
new file mode 100644
index 00000000000..d40fd9a5508
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95502.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446
+
+program p
+ integer, pointer :: z
+ nullify (z%kind) ! { dg-error "in variable definition context" }
+ z%kind => NULL() ! { dg-error "constant expression" }
+end
^ permalink raw reply [flat|nested] 2+ messages in thread
* PING [PATCH] PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446
2021-06-04 21:12 [PATCH] PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446 Harald Anlauf
@ 2021-06-11 18:41 ` Harald Anlauf
0 siblings, 0 replies; 2+ messages in thread
From: Harald Anlauf @ 2021-06-11 18:41 UTC (permalink / raw)
To: Harald Anlauf; +Cc: fortran, gcc-patches
*PING*
BTW this patch also addresses PR95501, so I'll update the Changelog.
Thanks,
Harald
> Gesendet: Freitag, 04. Juni 2021 um 23:12 Uhr
> Von: "Harald Anlauf" <anlauf@gmx.de>
> An: "fortran" <fortran@gcc.gnu.org>, "gcc-patches" <gcc-patches@gcc.gnu.org>
> Betreff: [PATCH] PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446
>
> ICE-on-invalid issues during error recovery. Testcase by Gerhard,
> initial patch by Steve. I found another variant which needed an
> additional fix for a NULL pointer dereference.
>
> Regtested on x86_64-pc-linux-gnu.
>
> OK for mainline / 11-branch?
>
> Thanks,
> Harald
>
>
> Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446
>
> Avoid NULL pointer dereferences during error recovery.
>
> gcc/fortran/ChangeLog:
>
> PR fortran/95502
> * expr.c (gfc_check_pointer_assign): Avoid NULL pointer
> dereference.
> * match.c (gfc_match_pointer_assignment): Likewise.
> * parse.c (gfc_check_do_variable): Avoid comparison with NULL
> symtree.
>
> gcc/testsuite/ChangeLog:
>
> PR fortran/95502
> * gfortran.dg/pr95502.f90: New test.
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-11 18:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04 21:12 [PATCH] PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446 Harald Anlauf
2021-06-11 18:41 ` PING " Harald Anlauf
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).