From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.smtpout.orange.fr (smtp-12.smtpout.orange.fr [80.12.242.12]) by sourceware.org (Postfix) with ESMTPS id 0AF5E3858CDB for ; Fri, 7 Oct 2022 19:47:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0AF5E3858CDB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orange.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=orange.fr Received: from [192.168.1.17] ([86.215.174.255]) by smtp.orange.fr with ESMTPA id gtJUocPkcLFqbgtJUo1BFo; Fri, 07 Oct 2022 21:47:20 +0200 X-ME-Helo: [192.168.1.17] X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Fri, 07 Oct 2022 21:47:20 +0200 X-ME-IP: 86.215.174.255 Message-ID: <30b93c16-9be9-d2b1-b6c8-c34f4ab8cfff@orange.fr> Date: Fri, 7 Oct 2022 21:47:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH, v2] Fortran: error recovery for invalid types in array constructors [PR107000] Content-Language: fr, en-US To: Harald Anlauf Cc: gcc-patches , fortran References: <1bf3b7b5-39ac-0c94-256c-f739a4746a7b@orange.fr> <97dd508f-83b0-5ed0-8cb5-f4f7c8fe08e6@orange.fr> <05a23138-adcd-2526-698c-1fa846f1810b@orange.fr> <05f415c0-80bc-c04e-a142-1251bf82bb1d@gmx.de> From: Mikael Morin In-Reply-To: <05f415c0-80bc-c04e-a142-1251bf82bb1d@gmx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FROM,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Le 07/10/2022 à 20:46, Harald Anlauf a écrit : > > OK, that is because reduce_binary dispatches the reduce_binary_*. > We could move the check from reduce_binary_aa to the beginning of > reduce_binary, as with the following change on top of the patch: > > diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc > index 2c57c796270..91e70655ad3 100644 > --- a/gcc/fortran/arith.cc > +++ b/gcc/fortran/arith.cc > @@ -1426,10 +1426,6 @@ reduce_binary_aa (arith (*eval) (gfc_expr *, > gfc_expr *, gfc_expr **), >    if (!gfc_check_conformance (op1, op2, _("elemental binary operation"))) >      return ARITH_INCOMMENSURATE; > > -  if ((op1->expr_type == EXPR_OP && op1->ts.type == BT_UNKNOWN) > -      || (op2->expr_type == EXPR_OP && op2->ts.type == BT_UNKNOWN)) > -    return ARITH_INVALID_TYPE; > - >    head = gfc_constructor_copy (op1->value.constructor); >    for (c = gfc_constructor_first (head), >         d = gfc_constructor_first (op2->value.constructor); > @@ -1467,6 +1463,10 @@ static arith >  reduce_binary (arith (*eval) (gfc_expr *, gfc_expr *, gfc_expr **), >                gfc_expr *op1, gfc_expr *op2, gfc_expr **result) >  { > +  if ((op1->expr_type == EXPR_OP && op1->ts.type == BT_UNKNOWN) > +      || (op2->expr_type == EXPR_OP && op2->ts.type == BT_UNKNOWN)) > +    return ARITH_INVALID_TYPE; > + >    if (op1->expr_type == EXPR_CONSTANT && op2->expr_type == EXPR_CONSTANT) >      return eval (op1, op2, result); > > However, we cannot remove the checks from reduce_binary_ac > or reduce_binary_ca, as the lengthy testcase proves... > > Do you like the above better? > Yes, definitely, but some less important weirdness remains; the scalar vs array function catches scalar vs invalid scalar cases. Let me have a look.