From c17bad5326d5f1f79207409e13e80ec61934ebfe Mon Sep 17 00:00:00 2001 From: Dominique d'Humieres Date: Wed, 3 Apr 2019 23:32:13 +0200 Subject: [PATCH] [multiple changes] 2019-04-03 Steven G. Kargl PR fortran/68567 * expr.c (gfc_reduce_init_expr): Add extra check to avoid dereferencing a null pointer. 2019-04-03 Dominique d'Humieres PR fortran/68567 * gfortran.dg/parameter_array_error_1.f90: New test. From-SVN: r270137 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/expr.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/parameter_array_error_1.f90 | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/parameter_array_error_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0fc9d97e6f0..835ef4ee337 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-04-03 Steven G. Kargl + + PR fortran/68567 + * expr.c (gfc_reduce_init_expr): Add extra check to avoid + dereferencing a null pointer. + 2019-04-03 Dominique d'Humieres PR fortran/89375 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 47ec35f6d8a..3b46b4e802e 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3003,7 +3003,7 @@ gfc_reduce_init_expr (gfc_expr *expr) t = gfc_check_init_expr (expr); gfc_init_expr_flag = false; - if (!t) + if (!t || !expr) return false; if (expr->expr_type == EXPR_ARRAY) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fd16b9204eb..bbf96bf5d30 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-04-03 Dominique d'Humieres + + PR fortran/68567 + * gfortran.dg/parameter_array_error_1.f90: New test. + 2019-04-03 qing zhao PR tree-optimization/89730 diff --git a/gcc/testsuite/gfortran.dg/parameter_array_error_1.f90 b/gcc/testsuite/gfortran.dg/parameter_array_error_1.f90 new file mode 100644 index 00000000000..eebdd29dccf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/parameter_array_error_1.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR68567 +! Contributed by Gerhard Steinmetz +! +program p + integer, parameter :: a(:) = [2, 1] ! { dg-error "cannot be automatic or of deferred shape" } +end -- 2.30.2