From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 3B6BF3858434 for ; Sun, 13 Aug 2023 21:16:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B6BF3858434 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1qVIS2-0008Lb-Fl for gcc-patches@gcc.gnu.org; Sun, 13 Aug 2023 23:16:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-patches@gcc.gnu.org From: Harald Anlauf Subject: Re: [PATCH 0/3] fortran: fix length one character dummy args [PR110419] Date: Sun, 13 Aug 2023 23:16:34 +0200 Message-ID: <69ae66ca-df06-4169-88cb-96290d28aeac@gmx.de> References: <20230809202122.695376-1-mikael@gcc.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla Thunderbird Content-Language: en-US In-Reply-To: <20230809202122.695376-1-mikael@gcc.gnu.org> Cc: fortran@gcc.gnu.org X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20230813211634.g-biXk8olWDWo6-ppOWgVh7RHt5Zac_4O0ENCVFZLKM@z> Hi Mikael, Am 09.08.23 um 22:21 schrieb Mikael Morin via Gcc-patches: > Hello, > > I propose with this patchset a fix for the test value_9.f90 which has been > failing on 32 bits powerpc since it was added a few weeks back (see PR110360 > and PR110419). > > The problem is an argument type mismatch between a procedure declaration, > and the argument value for a call of that same procedure, in the specific > case of length one character dummy arguments with the value attribute. > Admittedly, our argument passing conventions [1] for those are currently > unspecified. > > Before PR110360, character dummy arguments with value attribute were > arrays passed by value, but the actual argument was still passed as > reference. PR110360 changed that to pass length one dummies as bare > character (i.e. scalar integer), like in the bind(c) case (but with length > argument still present). However, the argument type in the function declaration > wasn't changed at the same time, so the test was failing on big-endian 32 bits > targets. Surprisingly, on most targets the middle-end, back-end and runtime > are happy to get a scalar value passed where a length one array is expected. > > This can be fixed, either by reverting back to arguments represented as > arrays passed by value with calls fixed, or by keeping the new > representation with single characters for arguments and fixing the procedure > types accordingly. > > I haven't really tried the first way, this is using the second one. > The first patch is a preliminary refactoring. The main change is the > second patch. It modifies the types of length one character dummy argsuments > with value attribute in the procedure declarations, so that they are scalar > integer types, consistently with how arguments are passed for calls. > The third patch is a change of error codes in the testcase. > > I have regression tested this on x86_64-unknown-linux-gnu, and > powerpc64-unknown-linux-gnu (both -m32 and -m64). > OK for master? this looks good to me. There was only one thing I was uncertain what the right way is: you chose to use mpz_cmp_ui in the length check in the new helper function gfc_length_one_character_type_p, while in many other places the length check uses mpz_cmp_si. Admittedly, a negative (effective/declared) character length can never occur, except maybe at intermediate times during resolution before this is fixed up in accordance with the standard. So this is probably more a cosmetic decision, and you can decide to use either variant. Thanks for the patch! Harald > [1] https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html > > > Mikael Morin (3): > fortran: New predicate gfc_length_one_character_type_p > fortran: Fix length one character dummy arg type [PR110419] > testsuite: Use distinct explicit error codes in value_9.f90 > > gcc/fortran/check.cc | 7 +- > gcc/fortran/decl.cc | 4 +- > gcc/fortran/gfortran.h | 15 +++ > gcc/fortran/trans-expr.cc | 39 ++++--- > gcc/fortran/trans-types.cc | 5 +- > gcc/testsuite/gfortran.dg/bind_c_usage_13.f03 | 8 +- > gcc/testsuite/gfortran.dg/value_9.f90 | 108 +++++++++--------- > 7 files changed, 103 insertions(+), 83 deletions(-) >