diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2015-09-21 18:09:13 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2015-09-21 18:09:13 +0000 |
commit | e2eb0806eaed00661cf7bc5b5d60798aa37dc712 (patch) | |
tree | 61b47e6af47388b34ff18374cf6bc163e53d53aa /gcc | |
parent | d7b00a16de70d84dce94a1f760265497f3408a7b (diff) | |
download | gcc-e2eb0806eaed00661cf7bc5b5d60798aa37dc712.zip gcc-e2eb0806eaed00661cf7bc5b5d60798aa37dc712.tar.gz gcc-e2eb0806eaed00661cf7bc5b5d60798aa37dc712.tar.bz2 |
re PR fortran/67615 (ICE on using arithmetic if with array instead of scalar)
2015-09-21 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/67615
* resolve.c (gfc_resolve_code): Check for scalar expression in
arithmetic-if.
2015-09-21 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/67615
* gfortran.dg/pr67615.f90: new test.
From-SVN: r227981
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr67615.f90 | 33 |
4 files changed, 55 insertions, 8 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ee6db56..a3b4442 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2015-09-21 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/67615 + * resolve.c (gfc_resolve_code): Check for scalar expression in + arithmetic-if. + 2015-09-17 Paul Thomas <pault@gcc.gnu.org> PR fortran/52846 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index a304158..da8aaa1 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -10377,15 +10377,18 @@ gfc_resolve_code (gfc_code *code, gfc_namespace *ns) } case EXEC_ARITHMETIC_IF: - if (t - && code->expr1->ts.type != BT_INTEGER - && code->expr1->ts.type != BT_REAL) - gfc_error ("Arithmetic IF statement at %L requires a numeric " - "expression", &code->expr1->where); + { + gfc_expr *e = code->expr1; - resolve_branch (code->label1, code); - resolve_branch (code->label2, code); - resolve_branch (code->label3, code); + 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); + + resolve_branch (code->label1, code); + resolve_branch (code->label2, code); + resolve_branch (code->label3, code); + } break; case EXEC_IF: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7afd523..8e642a8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-09-21 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/67615 + * gfortran.dg/pr67615.f90: new test. + 2015-09-21 Jeff Law <law@redhat.com> * gcc.target/h8300/andsi3_ashift_n_lower.c: New test. diff --git a/gcc/testsuite/gfortran.dg/pr67615.f90 b/gcc/testsuite/gfortran.dg/pr67615.f90 new file mode 100644 index 0000000..fb95958 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr67615.f90 @@ -0,0 +1,33 @@ +! { dg-do compile } +! { dg-options "-std=legacy" } +! PR fortran/67615 +! +program foo + + implicit none + + integer i(2), j + real x + complex z + + j = 2 + if (j) 10, 20, 30 + + x = -1 + if (x) 10, 20, 30 + + z = (1,2) + if (z) 10, 20, 30 ! { dg-error "Arithmetic IF statement" } + + i = [1, 2] + if (i) 10, 20, 30 ! { dg-error "Arithmetic IF statement" } + + if ( [1] ) 10, 20, 30 ! { dg-error "Arithmetic IF statement" } + if ( [1, -1] ) 10, 20, 30 ! { dg-error "Arithmetic IF statement" } + if ( [real :: 1, -1] ) 10, 20, 30 ! { dg-error "Arithmetic IF statement" } + +10 stop +20 stop +30 stop + +end program foo |