public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-9946] Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446
@ 2021-06-18 18:42 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2021-06-18 18:42 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0c084361a5a800ee0920bf29b6673816d2b35e76
commit r10-9946-g0c084361a5a800ee0920bf29b6673816d2b35e76
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Jun 16 22:04:22 2021 +0200
Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446
Avoid NULL pointer dereferences during error recovery.
gcc/fortran/ChangeLog:
PR fortran/95501
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/95501
PR fortran/95502
* gfortran.dg/pr95502.f90: New test.
(cherry picked from commit cfe0a2ec26867b290eb84af00317e60f8b67455c)
Diff:
---
gcc/fortran/expr.c | 3 +++
gcc/fortran/match.c | 2 +-
gcc/fortran/parse.c | 3 +++
gcc/testsuite/gfortran.dg/pr95502.f90 | 8 ++++++++
4 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index f946145eb1b..3c5246c7302 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3809,6 +3809,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 e1e4c1caeb4..ef6c86af2f9 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 3e19d5fdfbe..1501abfffd2 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -4440,6 +4440,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] only message in thread
only message in thread, other threads:[~2021-06-18 18:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 18:42 [gcc r10-9946] Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446 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).