From patchwork Wed Oct 5 09:23:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 58769 From: morin-mikael@orange.fr (Mikael Morin) Date: Wed, 5 Oct 2022 11:23:15 +0200 Subject: [PATCH] Fortran: error recovery for invalid types in array constructors [PR107000] In-Reply-To: <1bf3b7b5-39ac-0c94-256c-f739a4746a7b@orange.fr> References: <1bf3b7b5-39ac-0c94-256c-f739a4746a7b@orange.fr> Message-ID: Le 05/10/2022 ? 10:51, Mikael Morin a ?crit?: > > Unfortunately, it doesn't fix the bogus incommensurate arrays errors. > The following does. if (rc != ARITH_OK) There is one last thing that I'm dissatisfied with. The handling of unknown types should be moved to reduce_binary, because the dispatching in reduce_binary doesn't handle EXPR_OP, so even if either or both operands are scalar, they are handled by the (array vs array) reduce_binary_aa function. That's confusing. diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc index e6e35ef3c42..2c57c796270 100644 --- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -1443,7 +1443,7 @@ reduce_binary_aa (arith (*eval) (gfc_expr *, gfc_expr *, gfc_expr **), gfc_replace_expr (c->expr, r); } - if (c || d) + if (rc == ARITH_OK && (c || d)) rc = ARITH_INCOMMENSURATE;