* [patch, fortran] PR30371: KILL subroutine accepts array arguments.
@ 2007-01-05 1:16 Brooks Moses
2007-01-05 1:31 ` Steve Kargl
0 siblings, 1 reply; 7+ messages in thread
From: Brooks Moses @ 2007-01-05 1:16 UTC (permalink / raw)
To: gcc-patches; +Cc: fortran
[-- Attachment #1: Type: text/plain, Size: 634 bytes --]
The KILL() subroutine accepts arrays for the first two arguments, but
then appears (to me) to erroneously treat them as scalars. I presume
that this is in error and have filed PR30371; the attached patch adds
appropriate checks to gfc_check_kill_sub() to confirm that all of the
arguments are scalar.
-----------------------------------------------------------------
2007-01-03 Brooks Moses <brooks.moses@codesourcery.com>
* check.c (gfc_check_kill_sub): Add checks for non-scalar
arguments.
-----------------------------------------------------------------
Tested on trunk on i686-pc-linux-gnu. Ok to commit?
- Brooks
[-- Attachment #2: killscalar.diff --]
[-- Type: text/x-patch, Size: 485 bytes --]
Index: check.c
===================================================================
--- check.c (revision 120442)
+++ check.c (working copy)
@@ -1327,9 +1327,15 @@
if (type_check (pid, 0, BT_INTEGER) == FAILURE)
return FAILURE;
+ if (scalar_check (pid, 0) == FAILURE)
+ return FAILURE;
+
if (type_check (sig, 1, BT_INTEGER) == FAILURE)
return FAILURE;
+ if (scalar_check (sig, 1) == FAILURE)
+ return FAILURE;
+
if (status == NULL)
return SUCCESS;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch, fortran] PR30371: KILL subroutine accepts array arguments.
2007-01-05 1:16 [patch, fortran] PR30371: KILL subroutine accepts array arguments Brooks Moses
@ 2007-01-05 1:31 ` Steve Kargl
2007-01-05 1:40 ` Brooks Moses
0 siblings, 1 reply; 7+ messages in thread
From: Steve Kargl @ 2007-01-05 1:31 UTC (permalink / raw)
To: Brooks Moses; +Cc: fortran, gcc-patches
On Thu, Jan 04, 2007 at 05:12:27PM -0800, Brooks Moses wrote:
> The KILL() subroutine accepts arrays for the first two arguments, but
> then appears (to me) to erroneously treat them as scalars. I presume
> that this is in error and have filed PR30371; the attached patch adds
> appropriate checks to gfc_check_kill_sub() to confirm that all of the
> arguments are scalar.
>
> -----------------------------------------------------------------
> 2007-01-03 Brooks Moses <brooks.moses@codesourcery.com>
>
> * check.c (gfc_check_kill_sub): Add checks for non-scalar
> arguments.
>
OK.
Do we also need to the scalar checks in gfc_check_kill?
A quick glance at the code suggests that we do.
--
Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch, fortran] PR30371: KILL subroutine accepts array arguments.
2007-01-05 1:31 ` Steve Kargl
@ 2007-01-05 1:40 ` Brooks Moses
2007-01-05 5:46 ` Steve Kargl
2007-01-05 6:13 ` Brooks Moses
0 siblings, 2 replies; 7+ messages in thread
From: Brooks Moses @ 2007-01-05 1:40 UTC (permalink / raw)
To: gcc-patches; +Cc: fortran
Steve Kargl wrote:
> On Thu, Jan 04, 2007 at 05:12:27PM -0800, Brooks Moses wrote:
>> The KILL() subroutine accepts arrays for the first two arguments, but
>> then appears (to me) to erroneously treat them as scalars. I presume
>> that this is in error and have filed PR30371; the attached patch adds
>> appropriate checks to gfc_check_kill_sub() to confirm that all of the
>> arguments are scalar.
>>
>> -----------------------------------------------------------------
>> 2007-01-03 Brooks Moses <brooks.moses@codesourcery.com>
>>
>> * check.c (gfc_check_kill_sub): Add checks for non-scalar
>> arguments.
>>
>
> OK.
>
> Do we also need to the scalar checks in gfc_check_kill?
> A quick glance at the code suggests that we do.
I'm not sure. The KILL() function is flagged as ELEMENTAL in
intrinsic.c, and I'm not familiar enough with how elemental functions
are handled to know if that will do the right thing or not.
- Brooks
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch, fortran] PR30371: KILL subroutine accepts array arguments.
2007-01-05 1:40 ` Brooks Moses
@ 2007-01-05 5:46 ` Steve Kargl
2007-01-05 6:13 ` Brooks Moses
1 sibling, 0 replies; 7+ messages in thread
From: Steve Kargl @ 2007-01-05 5:46 UTC (permalink / raw)
To: Brooks Moses; +Cc: fortran, gcc-patches
On Thu, Jan 04, 2007 at 05:38:18PM -0800, Brooks Moses wrote:
> Steve Kargl wrote:
> >On Thu, Jan 04, 2007 at 05:12:27PM -0800, Brooks Moses wrote:
> >>The KILL() subroutine accepts arrays for the first two arguments, but
> >>then appears (to me) to erroneously treat them as scalars. I presume
> >>that this is in error and have filed PR30371; the attached patch adds
> >>appropriate checks to gfc_check_kill_sub() to confirm that all of the
> >>arguments are scalar.
> >>
> >>-----------------------------------------------------------------
> >>2007-01-03 Brooks Moses <brooks.moses@codesourcery.com>
> >>
> >> * check.c (gfc_check_kill_sub): Add checks for non-scalar
> >> arguments.
> >
> >OK.
> >
> >Do we also need to the scalar checks in gfc_check_kill?
> >A quick glance at the code suggests that we do.
>
> I'm not sure. The KILL() function is flagged as ELEMENTAL in
> intrinsic.c, and I'm not familiar enough with how elemental functions
> are handled to know if that will do the right thing or not.
>
I think the ELEMENTAL marking is incorrect because kill() is
only present due to backwards compatibility with g77. g77.info
says the arguments are scalar. The implementation in kill.c
suggests that these should also be scalar.
--
Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch, fortran] PR30371: KILL subroutine accepts array arguments.
2007-01-05 1:40 ` Brooks Moses
2007-01-05 5:46 ` Steve Kargl
@ 2007-01-05 6:13 ` Brooks Moses
2007-01-05 6:23 ` Steve Kargl
1 sibling, 1 reply; 7+ messages in thread
From: Brooks Moses @ 2007-01-05 6:13 UTC (permalink / raw)
To: gcc-patches; +Cc: fortran
Brooks Moses wrote:
> Steve Kargl wrote:
>> Do we also need to the scalar checks in gfc_check_kill?
>> A quick glance at the code suggests that we do.
>
> I'm not sure. The KILL() function is flagged as ELEMENTAL in
> intrinsic.c, and I'm not familiar enough with how elemental functions
> are handled to know if that will do the right thing or not.
Well, something does the wrong thing, anyway:
debian-gfortran:~/test> cat kill9.f90
program kill9
integer i1, i2, stat(2)
stat = kill( (/i1, i2/), (/9, 9/) )
end
debian-gfortran:~/test> ../bin-trunk/bin/gfortran kill9.f90 -o kill9
kill9.f90: In function 'MAIN__':
kill9.f90:1: internal compiler error: in gfc_conv_intrinsic_funcall, at
fortran/trans-intrinsic.c:1452
Ideally, since KILL is documented as an elemental function, this ought
to work. Though we could just make it non-elemental and put in checks,
as the simple way out.
- Brooks
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch, fortran] PR30371: KILL subroutine accepts array arguments.
2007-01-05 6:13 ` Brooks Moses
@ 2007-01-05 6:23 ` Steve Kargl
2007-01-05 8:19 ` FX Coudert
0 siblings, 1 reply; 7+ messages in thread
From: Steve Kargl @ 2007-01-05 6:23 UTC (permalink / raw)
To: Brooks Moses; +Cc: fortran, gcc-patches
On Thu, Jan 04, 2007 at 10:13:31PM -0800, Brooks Moses wrote:
> Brooks Moses wrote:
> >Steve Kargl wrote:
> >>Do we also need to the scalar checks in gfc_check_kill?
> >>A quick glance at the code suggests that we do.
> >
> >I'm not sure. The KILL() function is flagged as ELEMENTAL in
> >intrinsic.c, and I'm not familiar enough with how elemental functions
> >are handled to know if that will do the right thing or not.
>
> Well, something does the wrong thing, anyway:
>
> debian-gfortran:~/test> cat kill9.f90
> program kill9
> integer i1, i2, stat(2)
> stat = kill( (/i1, i2/), (/9, 9/) )
> end
>
> debian-gfortran:~/test> ../bin-trunk/bin/gfortran kill9.f90 -o kill9
> kill9.f90: In function 'MAIN__':
> kill9.f90:1: internal compiler error: in gfc_conv_intrinsic_funcall, at
> fortran/trans-intrinsic.c:1452
>
> Ideally, since KILL is documented as an elemental function, this ought
> to work. Though we could just make it non-elemental and put in checks,
> as the simple way out.
>
I vote for making nonelemental. This is what g77 had. Otherwise,
we'll need implement better name resolution in iresolve.c and
implement the array versions of kill(). Seems like a lot of work
for little return.
--
Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch, fortran] PR30371: KILL subroutine accepts array arguments.
2007-01-05 6:23 ` Steve Kargl
@ 2007-01-05 8:19 ` FX Coudert
0 siblings, 0 replies; 7+ messages in thread
From: FX Coudert @ 2007-01-05 8:19 UTC (permalink / raw)
To: Steve Kargl; +Cc: Brooks Moses, fortran, gcc-patches
> I vote for making nonelemental.
I also do. When I checked the elemental and valid_as_actual_arg
fields for all intrinsics in intrinsic.c, I must have overlooked this
one, otherwise I would have corrected it at that time.
FX
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-01-05 8:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-05 1:16 [patch, fortran] PR30371: KILL subroutine accepts array arguments Brooks Moses
2007-01-05 1:31 ` Steve Kargl
2007-01-05 1:40 ` Brooks Moses
2007-01-05 5:46 ` Steve Kargl
2007-01-05 6:13 ` Brooks Moses
2007-01-05 6:23 ` Steve Kargl
2007-01-05 8:19 ` FX Coudert
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).