From 741b52b54f3b7332b3199a5bd3af12acf0901c13 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Sat, 27 Aug 2016 15:38:55 +0000 Subject: [PATCH] re PR fortran/77372 (ICE in simplify_ieee_selected_real_kind, at fortran/simplify.c:7049) 2016-08-27 Steven G. Kargl PR fortran/77372 simplify.c (simplify_ieee_selected_real_kind): Check for NULL pointers. 2016-08-27 Steven G. Kargl PR fortran/77372 gfortran.dg/pr77372.f90: New test. From-SVN: r239795 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/simplify.c | 14 +++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr77372.f90 | 7 +++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr77372.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6def5b45ba2..f15e93617ad 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-08-27 Steven G. Kargl + + PR fortran/77372 + simplify.c (simplify_ieee_selected_real_kind): Check for NULL pointers. + 2016-08-25 Steven g. Kargl PR fortran/77351 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 8096a926161..6e6566d9245 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 952380f43c2..68e1804b883 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-08-27 Steven G. Kargl + + PR fortran/77372 + gfortran.dg/pr77372.f90: New test. + 2016-08-26 David Malcolm * 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 index 00000000000..8609d1654e3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77372.f90 @@ -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 -- 2.30.2