https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67615

--- Comment #4 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #3)
> This patch to resolve.c catches the problem.  Watch for
> cut-n-paste corruption of tabs.
> 
> @@ -10377,12 +10381,11 @@ gfc_resolve_code (gfc_code *code, gfc_na
>           }
>  
>         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);
>  
> +         if (t && (code->expr1->rank > 0 || !gfc_numeric_ts
> (&code->expr1->ts)))
> +           gfc_error ("Arithmetic IF statement at %L requires a scalar "
> +                      "numeric expression", &code->expr1->where);
> +         
>           resolve_branch (code->label1, code);
>           resolve_branch (code->label2, code);
>           resolve_branch (code->label3, code);
> 
> Whoops.  Needs for for BT_COMPLEX.

Better patch

@@ -10377,12 +10381,13 @@ gfc_resolve_code (gfc_code *code, gfc_na
          }

        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);

+         if (t && (code->expr1->rank > 0
+                   || !(code->expr1->ts.type == BT_REAL
+                        || code->expr1->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);

Reply via email to