re PR fortran/77372 (ICE in simplify_ieee_selected_real_kind, at fortran/simplify...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 27 Aug 2016 15:38:55 +0000 (15:38 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 27 Aug 2016 15:38:55 +0000 (15:38 +0000)
2016-08-27  Steven G. Kargl <kargl@gcc.gnu.org>

PR fortran/77372
simplify.c (simplify_ieee_selected_real_kind): Check for NULL pointers.

2016-08-27  Steven G. Kargl <kargl@gcc.gnu.org>

PR fortran/77372
gfortran.dg/pr77372.f90: New test.

From-SVN: r239795

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

index 6def5b45ba29524e789a33279402a274db52323a..f15e93617ada6c935265edc5d4e5d6b4b1ac6799 100644 (file)
@@ -1,3 +1,8 @@
+2016-08-27  Steven G. Kargl <kargl@gcc.gnu.org>
+
+       PR fortran/77372
+       simplify.c (simplify_ieee_selected_real_kind): Check for NULL pointers.
+
 2016-08-25  Steven g. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/77351
index 8096a926161a0dc1c0a3bb5c47dfa2b102c226c8..6e6566d924548d792f09fbee0d56be2b25087bf2 100644 (file)
@@ -7044,9 +7044,17 @@ gfc_simplify_compiler_version (void)
 gfc_expr *
 simplify_ieee_selected_real_kind (gfc_expr *expr)
 {
-  gfc_actual_arglist *arg = expr->value.function.actual;
-  gfc_expr *p = arg->expr, *q = arg->next->expr,
-          *rdx = arg->next->next->expr;
+  gfc_actual_arglist *arg;
+  gfc_expr *p = NULL, *q = NULL, *rdx = NULL;
+
+  arg = expr->value.function.actual;
+  p = arg->expr;
+  if (arg->next)
+    {
+      q = arg->next->expr;
+      if (arg->next->next)
+       rdx = arg->next->next->expr;
+    }
 
   /* Currently, if IEEE is supported and this module is built, it means
      all our floating-point types conform to IEEE. Hence, we simply handle
index 952380f43c26973c96ef5efa5ea49c09c742e513..68e1804b8831ad67c459b100d61275b1c0b6d808 100644 (file)
@@ -1,3 +1,8 @@
+2016-08-27  Steven G. Kargl <kargl@gcc.gnu.org>
+
+       PR fortran/77372
+       gfortran.dg/pr77372.f90: New test.
+
 2016-08-26  David Malcolm  <dmalcolm@redhat.com>
 
        * gcc.dg/spellcheck-fields-2.c (test): Move
diff --git a/gcc/testsuite/gfortran.dg/pr77372.f90 b/gcc/testsuite/gfortran.dg/pr77372.f90
new file mode 100644 (file)
index 0000000..8609d16
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do compile }
+program p
+   use ieee_arithmetic
+   real(kind=ieee_selected_real_kind(10_1)) :: z1
+   real(kind=ieee_selected_real_kind(10_2)) :: z2
+   real(kind=ieee_selected_real_kind(10_4)) :: z4
+end