public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-1695] PR fortran/95340 - ICE in gfc_match_select_rank, at fortran/match.c:6690
@ 2020-06-28 14:24 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2020-06-28 14:24 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b62cac6d92ff251213753475b69ec0b269cb7fae

commit r11-1695-gb62cac6d92ff251213753475b69ec0b269cb7fae
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Jun 28 16:24:15 2020 +0200

    PR fortran/95340 - ICE in gfc_match_select_rank, at fortran/match.c:6690
    
    Do not dereference NULL pointer when querying array shape of possibly
    improperly delared variable.
    
    gcc/fortran/
            PR fortran/95340
            * match.c (gfc_match_select_rank): Do not dereference NULL pointer.

Diff:
---
 gcc/fortran/match.c                   |  3 ++-
 gcc/testsuite/gfortran.dg/pr95340.f90 | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index b011634792e..db5174f3f21 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -6695,7 +6695,8 @@ gfc_match_select_rank (void)
       if (expr1->symtree)
 	{
 	  sym = expr1->symtree->n.sym;
-	  as = sym->ts.type == BT_CLASS ? CLASS_DATA (sym)->as : sym->as;
+	  as = (sym->ts.type == BT_CLASS
+		&& CLASS_DATA (sym)) ? CLASS_DATA (sym)->as : sym->as;
 	}
 
       if (expr1->expr_type != EXPR_VARIABLE
diff --git a/gcc/testsuite/gfortran.dg/pr95340.f90 b/gcc/testsuite/gfortran.dg/pr95340.f90
new file mode 100644
index 00000000000..edcdc935057
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95340.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! PR fortran/95340 - ICE in gfc_match_select_rank, at fortran/match.c:6690
+
+program p
+  type t
+  end type t
+  class(t) :: z   ! { dg-error "must be dummy, allocatable or pointer" }
+  select rank (z) ! { dg-error "must be an assumed rank variable" }
+  end select      ! { dg-error "Expecting END PROGRAM" }
+end


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-28 14:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-28 14:24 [gcc r11-1695] PR fortran/95340 - ICE in gfc_match_select_rank, at fortran/match.c:6690 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).