diff mbox

[fortran] Fix elemental optional dummy argument handling

Message ID 554CB4EC.5020606@sfr.fr
State New
Headers show

Commit Message

Mikael Morin May 8, 2015, 1:06 p.m. UTC
Hello,

I found a (unrelated) bug while playing with Andre's PR65894 patch.
The dummy argument can get out of sync with the actual argument when
there is an (optional) argument missing.
I plan to commit the attached fix as obvious later today (after testing).

Mikael
2015-05-08  Mikael Morin  <mikael@gcc.gnu.org>

	* trans-array.c (gfc_walk_elemental_function_args):
	Don't skip the advance to the next dummy argument when skipping
	absent optional args.
diff mbox

Patch

diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index a17f431..00334b1 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -9092,7 +9092,7 @@  gfc_walk_elemental_function_args (gfc_ss * ss, gfc_actual_arglist *arg,
   for (; arg; arg = arg->next)
     {
       if (!arg->expr || arg->expr->expr_type == EXPR_NULL)
-	continue;
+	goto loop_continue;
 
       newss = gfc_walk_subexpr (head, arg->expr);
       if (newss == head)
@@ -9122,6 +9122,7 @@  gfc_walk_elemental_function_args (gfc_ss * ss, gfc_actual_arglist *arg,
             tail = tail->next;
         }
 
+loop_continue:
       if (dummy_arg != NULL)
 	dummy_arg = dummy_arg->next;
     }