aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/expr.c18
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr67526.f909
4 files changed, 30 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 4e0d38f..13bb7b3 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-10 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/67526
+ * expr.c (gfc_check_init_expr): Do not dereference a NULL pointer.
+
2015-09-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/66993
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 1d6f310..3a0ef4d 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 34ad007..db2f374 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-10 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/67526
+ * gfortran.dg/pr67526.f90: New test.
+
2015-09-10 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/67318
diff --git a/gcc/testsuite/gfortran.dg/pr67526.f90 b/gcc/testsuite/gfortran.dg/pr67526.f90
new file mode 100644
index 0000000..3c0834f
--- /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