[multiple changes]
authorDominique d'Humieres <dominiq@gcc.gnu.org>
Wed, 3 Apr 2019 21:32:13 +0000 (23:32 +0200)
committerDominique d'Humieres <dominiq@gcc.gnu.org>
Wed, 3 Apr 2019 21:32:13 +0000 (23:32 +0200)
2019-04-03  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/68567
* expr.c (gfc_reduce_init_expr): Add extra check to avoid
dereferencing a null pointer.

2019-04-03  Dominique d'Humieres  <dominiq@gcc.gnu.org>

PR fortran/68567
* gfortran.dg/parameter_array_error_1.f90: New test.

From-SVN: r270137

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/parameter_array_error_1.f90 [new file with mode: 0644]

index 0fc9d97e6f024f050b9ae1ed75687b6a7f097190..835ef4ee3370b119c611aecbfad31c33c7653a6e 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-03  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/68567
+       * expr.c (gfc_reduce_init_expr): Add extra check to avoid
+       dereferencing a null pointer.
+
 2019-04-03  Dominique d'Humieres  <dominiq@gcc.gnu.org>
 
        PR fortran/89375
index 47ec35f6d8aab443d408f3804c826b5dcf6d5244..3b46b4e802e33590edb99b9c3875e8ba97c5bfcf 100644 (file)
@@ -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)
index fd16b9204eb86c06183d2c91f00926f503c97c98..bbf96bf5d30bb7d4f3c43ebd8bb5f73dac68e57b 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-03  Dominique d'Humieres  <dominiq@gcc.gnu.org>
+
+       PR fortran/68567
+       * gfortran.dg/parameter_array_error_1.f90: New test.
+
 2019-04-03  qing zhao  <qing.zhao@oracle.com>
 
        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 (file)
index 0000000..eebdd29
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR68567
+! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de>
+!
+program p
+   integer, parameter :: a(:) = [2, 1] ! { dg-error "cannot be automatic or of deferred shape" }
+end