diff mbox

[Fortran] PR 51758 - fix ICE with null() in elemental procedures

Message ID 4F0AFB01.4020204@sfr.fr
State New
Headers show

Commit Message

Mikael Morin Jan. 9, 2012, 2:34 p.m. UTC
Sorry Tobias, I was about to post a patch about this when I saw your 
message.

The issue is that the code handling NULL() doesn't consume the gfc_ss 
struct created for it. Your fix, which advances to the next one anyway 
would work just well, but I think it is slightly cleaner to not create 
the struct in the first place, as it is unused.

I'm currently regtesting the following patch. The testcase is the same 
as your. OK for 4.7/4.6?


2012-01-09  Mikael Morin  <mikael@gcc.gnu.org>

	* trans-array.c (gfc_walk_elemental_function_args):
	Skip over NULL() actual arguments.

Comments

Tobias Burnus Jan. 9, 2012, 2:45 p.m. UTC | #1
On 01/09/2012 03:34 PM, Mikael Morin wrote:
> The issue is that the code handling NULL() doesn't consume the gfc_ss 
> struct created for it. Your fix, which advances to the next one anyway 
> would work just well, but I think it is slightly cleaner to not create 
> the struct in the first place, as it is unused.
>
> I'm currently regtesting the following patch. The testcase is the same 
> as your. OK for 4.7/4.6?

OK.

For the test case, either take mine or don't forget to enable all "if() 
abort"s and to change in the last "! print *,a" the "a" into a "b".

+      if (!arg->expr
+	  || arg->expr->expr_type == EXPR_NULL)
  	continue;

(I'd prefer to have no line break before the "||".)

Tobias
Mikael Morin July 14, 2012, 1:16 p.m. UTC | #2
On 09/01/2012 15:45, Tobias Burnus wrote:
> On 01/09/2012 03:34 PM, Mikael Morin wrote:
>> The issue is that the code handling NULL() doesn't consume the gfc_ss
>> struct created for it. Your fix, which advances to the next one anyway
>> would work just well, but I think it is slightly cleaner to not create
>> the struct in the first place, as it is unused.
>>
>> I'm currently regtesting the following patch. The testcase is the same
>> as your. OK for 4.7/4.6?
> 
> OK.
> 
> For the test case, either take mine or don't forget to enable all "if()
> abort"s and to change in the last "! print *,a" the "a" into a "b".
> 
> +      if (!arg->expr
> +      || arg->expr->expr_type == EXPR_NULL)
>      continue;
> 
> (I'd prefer to have no line break before the "||".)
> 
> Tobias

As this patch was approved for 4.6, I will now backport it and then
close the bug, unless someone complains.

Mikael
diff mbox

Patch

diff --git a/trans-array.c b/trans-array.c
index b9902b9..ca6519b 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -8369,7 +8369,8 @@  gfc_walk_elemental_function_args (gfc_ss * ss, gfc_actual_arglist *arg,
   scalar = 1;
   for (; arg; arg = arg->next)
     {
-      if (!arg->expr)
+      if (!arg->expr
+	  || arg->expr->expr_type == EXPR_NULL)
 	continue;
 
       newss = gfc_walk_subexpr (head, arg->expr);