This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] PR34079 - BIND(C) and characters - unneeded character length passed
- From: FX Coudert <fxcoudert at gmail dot com>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, "Christopher D. Rickett" <crickett at lanl dot gov>
- Date: Sat, 17 Nov 2007 00:21:52 +0000
- Subject: Re: [Patch, Fortran] PR34079 - BIND(C) and characters - unneeded character length passed
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; bh=iX4hPf/N6Z8XzbhbfIGFKhXLCMylnTFWdROt9EAuWPY=; b=nY52AIVJqhJXnvJQ7EWSGLTefTMYUOnC7QK+LFHibnepfNqFwHyLu5zanWsYjhRHw3fxiFY6f8EJcYtYPKWfeUjxQxLmAec/tY189XYmAoOD3jL9hcr4GqlTMWo8E2sN+xiaD1F7w3tSQUi5LPKGhRwTVG8MmB/YSTFcSgar4cE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=Mh79XFEGcojlGO7ejZ03rAHg/YLV9ixTLMKTrnlca7B/pkSMfhOY4AEQPfEXU6UaojHrT81KRv/0dtaE8s9lAUuvp/65pB04UUslB6A0pEcpbhB/IZLy4rtrZHBRF2cK1bhwbNIW4E5Y5y6reCKTDygaRDbplQnupvvCSu7SOwA=
- References: <473C608B.9000202@net-b.de>
:REVIEWMAIL:
Hi Tobias,
This patch simply does not generate the extra argument(s) when
calling a
BIND(C) procedure.
We also need to not consider these extra arguments when creating code
for procedures, and also for function results (and probably also when
creating the DECLs for these functions, which is handled in a
different place IIRC). For example, with your patch, the following code:
subroutine foo(x) bind(c)
character(len=1) :: x
print *, x
end subroutine foo
function bar(x) bind(c)
character(len=1) :: x, bar
bar = x
end function bar
program test
interface
subroutine foo(x) bind(c)
character(len=1) :: x
end subroutine foo
function bar(x) bind(c)
character(len=1) :: x, bar
end function bar
end interface
character(len=1) :: x
call foo(" ")
x = " "
print *, bar(x)
end program test
generates the following code (excerpts from the tree dump):
foo (x, _x) /* there shouldn't be a _x here */
{
[...]
}
bar (__result, .__result, x, _x) /* there should be neither _x
nor .__result here */
{
(*__result)[1]{lb: 1 sz: 1} = (*x)[1]{lb: 1 sz: 1};
}
test ()
{
foo (&" "[1]{lb: 1 sz: 1}); /* this one is correct, per your
patch; I don't know if the DECL for the function is correct, though;
I need to check. */
[...]
bar ((char[1:1] *) &str.3, 1, &x[1]{lb: 1 sz: 1}); /* this one is
half correct, because there's still an extra 1 as second argument */
}
I'll try to give more pointers to where this should be fixed, when I
have time (I have looked at this code multiple times, while trying to
get unique DECLs per function, including correct list of arg types).
There might also be other subtleties, but I wanted to give you this
heads-up as soon as possible.
FX
PS: I was truly amazed at the regexps in your testcases! that's great
(and probably hard) work