public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: Mikael Morin <mikael@gcc.gnu.org>,
	fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 0/3] fortran: fix length one character dummy args [PR110419]
Date: Sun, 13 Aug 2023 23:16:34 +0200	[thread overview]
Message-ID: <69ae66ca-df06-4169-88cb-96290d28aeac@gmx.de> (raw)
In-Reply-To: <20230809202122.695376-1-mikael@gcc.gnu.org>

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


  parent reply	other threads:[~2023-08-13 21:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 20:21 Mikael Morin
2023-08-09 20:21 ` [PATCH 1/3] fortran: New predicate gfc_length_one_character_type_p Mikael Morin
2023-08-09 20:21 ` [PATCH 2/3] fortran: Fix length one character dummy arg type [PR110419] Mikael Morin
2023-08-09 20:21 ` [PATCH 3/3] testsuite: Use distinct explicit error codes in value_9.f90 Mikael Morin
2023-08-13 21:16 ` Harald Anlauf [this message]
2023-08-14 19:47   ` [PATCH 0/3] fortran: fix length one character dummy args [PR110419] Mikael Morin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69ae66ca-df06-4169-88cb-96290d28aeac@gmx.de \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mikael@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).