diff mbox

PATCH: PR c/59309: FAIL: c-c++-common/cilk-plus/CK/spawnee_inline.c -g -fcilkplus (test for excess errors)

Message ID 20131128160539.GA21530@intel.com
State New
Headers show

Commit Message

H.J. Lu Nov. 28, 2013, 4:05 p.m. UTC
Hi,

For function without arguments, gimplify_cilk_spawn checks

*arg_array == NULL_TREE

But arg_array is a TREE vector of zero elements.  This patch updates
gimplify_cilk_spawn to properly handle function without arguments.
Tested on Linux/x86-64 with GCC bootstraped using -fsanitize=address.
OK to install?

Thanks.


H.J.
----
2013-11-28   H.J. Lu  <hongjiu.lu@intel.com>

	PR c/59309
	* cilk.c (gimplify_cilk_spawn): Properly handle function without
	arguments.

Comments

Iyer, Balaji V Nov. 28, 2013, 4:50 p.m. UTC | #1
> -----Original Message-----
> From: Lu, Hongjiu
> Sent: Thursday, November 28, 2013 11:06 AM
> To: gcc-patches@gcc.gnu.org
> Cc: Iyer, Balaji V
> Subject: PATCH: PR c/59309: FAIL: c-c++-common/cilk-
> plus/CK/spawnee_inline.c -g -fcilkplus (test for excess errors)
> 
> Hi,
> 
> For function without arguments, gimplify_cilk_spawn checks
> 
> *arg_array == NULL_TREE
> 
> But arg_array is a TREE vector of zero elements.  This patch updates
> gimplify_cilk_spawn to properly handle function without arguments.
> Tested on Linux/x86-64 with GCC bootstraped using -fsanitize=address.
> OK to install?
> 
> Thanks.
> 
> 
> H.J.
> ----
> 2013-11-28   H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	PR c/59309
> 	* cilk.c (gimplify_cilk_spawn): Properly handle function without
> 	arguments.
> 
> diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c index c85b5f2..99d9c7e
> 100644
> --- a/gcc/c-family/cilk.c
> +++ b/gcc/c-family/cilk.c
> @@ -757,7 +757,10 @@ gimplify_cilk_spawn (tree *spawn_p, gimple_seq
> *before ATTRIBUTE_UNUSED,
> 
>    /* This should give the number of parameters.  */
>    total_args = list_length (new_args);
> -  arg_array = XNEWVEC (tree, total_args);
> +  if (total_args)
> +    arg_array = XNEWVEC (tree, total_args);  else
> +    arg_array = NULL;
> 
>    ii_args = new_args;
>    for (ii = 0; ii < total_args; ii++)
> @@ -771,7 +774,7 @@ gimplify_cilk_spawn (tree *spawn_p, gimple_seq
> *before ATTRIBUTE_UNUSED,
> 
>    call1 = cilk_call_setjmp (cfun->cilk_frame_decl);
> 
> -  if (*arg_array == NULL_TREE)
> +  if (arg_array == NULL || *arg_array == NULL_TREE)
>      call2 = build_call_expr (function, 0);
>    else
>      call2 = build_call_expr_loc_array (EXPR_LOCATION (*spawn_p), function,

Looks good to me.

-Balaji V. Iyer
diff mbox

Patch

diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
index c85b5f2..99d9c7e 100644
--- a/gcc/c-family/cilk.c
+++ b/gcc/c-family/cilk.c
@@ -757,7 +757,10 @@  gimplify_cilk_spawn (tree *spawn_p, gimple_seq *before ATTRIBUTE_UNUSED,
 
   /* This should give the number of parameters.  */
   total_args = list_length (new_args);
-  arg_array = XNEWVEC (tree, total_args);
+  if (total_args)
+    arg_array = XNEWVEC (tree, total_args);
+  else
+    arg_array = NULL;
 
   ii_args = new_args;
   for (ii = 0; ii < total_args; ii++)
@@ -771,7 +774,7 @@  gimplify_cilk_spawn (tree *spawn_p, gimple_seq *before ATTRIBUTE_UNUSED,
 
   call1 = cilk_call_setjmp (cfun->cilk_frame_decl);
 
-  if (*arg_array == NULL_TREE)
+  if (arg_array == NULL || *arg_array == NULL_TREE)
     call2 = build_call_expr (function, 0);
   else 
     call2 = build_call_expr_loc_array (EXPR_LOCATION (*spawn_p), function,