+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
}
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:
+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.
--- /dev/null
+! { 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