diff options
author | Harald Anlauf <anlauf@gmx.de> | 2020-06-30 23:36:56 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2020-06-30 23:36:56 +0200 |
commit | 267f84c6035c9380c8d1e9cb83ffe299c23e3a85 (patch) | |
tree | 68813cc841b880cc6da23ce35e74111b05ac6a06 | |
parent | 31427b974ed7b7dd54e28fec595e731bf6eea8ba (diff) | |
download | gcc-267f84c6035c9380c8d1e9cb83ffe299c23e3a85.zip gcc-267f84c6035c9380c8d1e9cb83ffe299c23e3a85.tar.gz gcc-267f84c6035c9380c8d1e9cb83ffe299c23e3a85.tar.bz2 |
PR fortran/88379 - ICE with allocatable coarray, class and associate
Catch NULL pointer dereference for ASSOCIATE on allocatable coarray variable.
gcc/fortran/
PR fortran/88379
* resolve.c (resolve_assoc_var): Avoid NULL pointer dereference.
-rw-r--r-- | gcc/fortran/resolve.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr88379.f90 | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index f3e8ffc..4a2abd0 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -9045,7 +9045,7 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target) as = NULL; sym->ts = *ts; sym->ts.type = BT_CLASS; - attr = CLASS_DATA (sym)->attr; + attr = CLASS_DATA (sym) ? CLASS_DATA (sym)->attr : sym->attr; attr.class_ok = 0; attr.associate_var = 1; attr.dimension = attr.codimension = 0; diff --git a/gcc/testsuite/gfortran.dg/pr88379.f90 b/gcc/testsuite/gfortran.dg/pr88379.f90 new file mode 100644 index 0000000..48a23af --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88379.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! PR fortran/88379 - ICE with allocatable coarray, class and associate + +program p + type t + end type t + class(t), allocatable :: x[:] + associate (y => x) + end associate +end |