diff options
author | Harald Anlauf <anlauf@gmx.de> | 2022-02-01 21:36:42 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2022-02-01 21:36:42 +0100 |
commit | 447047a8f95c6bf4b1873f390c833e91aa8af18c (patch) | |
tree | 896b9ba848e3afa0102f4438eac57f89e4bb7447 | |
parent | 95ac5635409606386259d2ff21fb61738858ca4a (diff) | |
download | gcc-447047a8f95c6bf4b1873f390c833e91aa8af18c.zip gcc-447047a8f95c6bf4b1873f390c833e91aa8af18c.tar.gz gcc-447047a8f95c6bf4b1873f390c833e91aa8af18c.tar.bz2 |
Fortran: error recovery when simplifying EOSHIFT
gcc/fortran/ChangeLog:
PR fortran/104331
* simplify.cc (gfc_simplify_eoshift): Avoid NULL pointer
dereference when shape is not set.
gcc/testsuite/ChangeLog:
PR fortran/104331
* gfortran.dg/eoshift_9.f90: New test.
-rw-r--r-- | gcc/fortran/simplify.cc | 3 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/eoshift_9.f90 | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 8604162..6483f9c 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -2572,6 +2572,9 @@ gfc_simplify_eoshift (gfc_expr *array, gfc_expr *shift, gfc_expr *boundary, if (arraysize == 0) goto final; + if (array->shape == NULL) + goto final; + arrayvec = XCNEWVEC (gfc_expr *, arraysize); array_ctor = gfc_constructor_first (array->value.constructor); for (i = 0; i < arraysize; i++) diff --git a/gcc/testsuite/gfortran.dg/eoshift_9.f90 b/gcc/testsuite/gfortran.dg/eoshift_9.f90 new file mode 100644 index 0000000..f711b04 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/eoshift_9.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/104331 - ICE in gfc_simplify_eoshift +! Contributed by G.Steinmetz + +program p + character(3), parameter :: a(:) = ['123'] ! { dg-error "deferred shape" } + character(3), parameter :: b(*) = eoshift(a, 1) +end |