From 2d2de608f89e9e753457ee7faa2876ac8e93a377 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Fri, 25 Sep 2015 22:30:26 +0000 Subject: [PATCH] re PR fortran/67614 (ICE on using arithmetic if with null) 2015-09-25 Steven G. Kargl PR fortran/67614 * resolve.c (gfc_resolve_code): Prevent ICE for invalid EXPR_NULL. 2015-09-25 Steven G. Kargl PR fortran/67614 * gfortran.dg/pr67614.f90: New test. From-SVN: r228156 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/resolve.c | 6 +++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr67614.f90 | 12 ++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr67614.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1e3a7a13e2b..0d39cd8391c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-09-25 Steven G. Kargl + + PR fortran/67614 + * resolve.c (gfc_resolve_code): Prevent ICE for invalid EXPR_NULL. + 2015-09-25 Steven G. Kargl PR fortran/67525 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 59cf03402fe..c4083905776 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -10380,10 +10380,14 @@ gfc_resolve_code (gfc_code *code, gfc_namespace *ns) { gfc_expr *e = code->expr1; + gfc_resolve_expr (e); + if (e->expr_type == EXPR_NULL) + gfc_error ("Invalid NULL at %L", &e->where); + if (t && (e->rank > 0 || !(e->ts.type == BT_REAL || e->ts.type == BT_INTEGER))) gfc_error ("Arithmetic IF statement at %L requires a scalar " - "REAL or INTEGER expression", &code->expr1->where); + "REAL or INTEGER expression", &e->where); resolve_branch (code->label1, code); resolve_branch (code->label2, code); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a98e70164c0..74c0823a5bd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-09-25 Steven G. Kargl + + PR fortran/67614 + * gfortran.dg/pr67614.f90: New test. + 2015-09-25 Steven G. Kargl PR fortran/67525 diff --git a/gcc/testsuite/gfortran.dg/pr67614.f90 b/gcc/testsuite/gfortran.dg/pr67614.f90 new file mode 100644 index 00000000000..ed07385970d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr67614.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-std=legacy" } +! PR fortran/67614 +! +program foo + implicit none + integer, pointer :: z + if (null(z)) 10, 20, 30 ! { dg-error "Invalid NULL" } +10 continue +20 continue +30 continue +end program foo -- 2.30.2