From 3108836938c10cc746fe2118e8108e843039a2c7 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Thu, 10 Sep 2015 17:13:11 +0000 Subject: [PATCH] re PR fortran/67526 (ICE on missing end parenthesis in substring construct) 2015-09-09 Steven G. Kargl PR fortran/67526 * gfortran.dg/pr67526.f90: New test. 2015-09-09 Steven G. Kargl PR fortran/67526 * expr.c (gfc_check_init_expr): Do not dereference a NULL pointer. From-SVN: r227651 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/expr.c | 18 +++++++++++------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr67526.f90 | 9 +++++++++ 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr67526.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4e0d38ff0d1..13bb7b3fd63 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-09-10 Steven G. Kargl + + PR fortran/67526 + * expr.c (gfc_check_init_expr): Do not dereference a NULL pointer. + 2015-09-10 Paul Thomas PR fortran/66993 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 1d6f310f28c..3a0ef4d8f55 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2600,14 +2600,18 @@ gfc_check_init_expr (gfc_expr *e) break; case EXPR_SUBSTRING: - t = gfc_check_init_expr (e->ref->u.ss.start); - if (!t) - break; - - t = gfc_check_init_expr (e->ref->u.ss.end); - if (t) - t = gfc_simplify_expr (e, 0); + if (e->ref) + { + t = gfc_check_init_expr (e->ref->u.ss.start); + if (!t) + break; + t = gfc_check_init_expr (e->ref->u.ss.end); + if (t) + t = gfc_simplify_expr (e, 0); + } + else + t = false; break; case EXPR_STRUCTURE: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 34ad00712ff..db2f374987d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-09-10 Steven G. Kargl + + PR fortran/67526 + * gfortran.dg/pr67526.f90: New test. + 2015-09-10 Paolo Carlini PR c++/67318 diff --git a/gcc/testsuite/gfortran.dg/pr67526.f90 b/gcc/testsuite/gfortran.dg/pr67526.f90 new file mode 100644 index 00000000000..3c0834f28dc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr67526.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! Original code from gerhard dot steinmetz dot fortran at t-online dot de +! PR fortran/67526 +program p + character :: c1 = 'abc'(: ! { dg-error "error in SUBSTRING" } + character :: c2 = 'abc'(3: ! { dg-error "error in SUBSTRING" } + character :: c3 = 'abc'(:1 ! { dg-error "error in SUBSTRING" } + character :: c4 = 'abc'(2:2 ! { dg-error "error in SUBSTRING" } +end -- 2.30.2