Patchwork PR 58834: __builtin_shuffle in a template

login
register
mail settings
Submitter Marc Glisse
Date Oct. 31, 2013, 11:03 p.m.
Message ID <alpine.DEB.2.02.1310312350470.7246@stedding.saclay.inria.fr>
Download mbox | patch
Permalink /patch/287680/
State New
Headers show

Comments

Marc Glisse - Oct. 31, 2013, 11:03 p.m.
Hello,

__builtin_shuffle with 2 arguments is represented as having 3 arguments, 
the second being 0, which isn't supported here.

Bootstrap+testsuite on x86_64-unknown-linux-gnu.

2013-11-01  Marc Glisse  <marc.glisse@inria.fr>

 	PR c++/58834
gcc/cp/
 	* pt.c (value_dependent_expression_p): Handle null argument.

gcc/testsuite/
 	* g++.dg/ext/pr58834.C: New file.
Jason Merrill - Nov. 1, 2013, 2:29 p.m.
On 10/31/2013 07:03 PM, Marc Glisse wrote:
>      * pt.c (value_dependent_expression_p): Handle null argument.

What is calling this with a null argument?  The recursive call near the 
end of the function checks for null there.

Jason
Marc Glisse - Nov. 1, 2013, 3:13 p.m.
On Fri, 1 Nov 2013, Jason Merrill wrote:

> On 10/31/2013 07:03 PM, Marc Glisse wrote:
>>      * pt.c (value_dependent_expression_p): Handle null argument.
>
> What is calling this with a null argument?  The recursive call near the end 
> of the function checks for null there.

See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58834 for details. It is 
build_x_vec_perm_expr that calls it with a null argument (when we call 
__builtin_shuffle with 2 arguments, it adds a NULL argument in second 
position). I can make it not call value_dependent_expression_p with a null 
argument, but it seems more general to let value_dependent_expression_p 
handle 0 like a number of other functions already do.
Jason Merrill - Nov. 1, 2013, 3:14 p.m.
On 11/01/2013 11:13 AM, Marc Glisse wrote:
> position). I can make it not call value_dependent_expression_p with a
> null argument, but it seems more general to let
> value_dependent_expression_p handle 0 like a number of other functions
> already do.

OK.  But the change is to type_..., not value_..., so please correct the 
ChangeLog entry.

Jason
Marc Glisse - Nov. 1, 2013, 3:19 p.m.
On Fri, 1 Nov 2013, Jason Merrill wrote:

> On 11/01/2013 11:13 AM, Marc Glisse wrote:
>> position). I can make it not call value_dependent_expression_p with a
>> null argument, but it seems more general to let
>> value_dependent_expression_p handle 0 like a number of other functions
>> already do.
>
> OK.  But the change is to type_..., not value_..., so please correct the 
> ChangeLog entry.

Oops, I didn't check closely enough the output of diff -p.
Thanks.

Patch

Index: gcc/cp/pt.c

===================================================================
--- gcc/cp/pt.c	(revision 204279)

+++ gcc/cp/pt.c	(working copy)

@@ -20499,21 +20499,21 @@  value_dependent_expression_p (tree expre

    considered dependent.  Other parts of the compiler arrange for an
    expression with type-dependent subexpressions to have no type, so
    this function doesn't have to be fully recursive.  */
 
 bool
 type_dependent_expression_p (tree expression)
 {
   if (!processing_template_decl)
     return false;
 
-  if (expression == error_mark_node)

+  if (expression == NULL_TREE || expression == error_mark_node)

     return false;
 
   /* An unresolved name is always dependent.  */
   if (identifier_p (expression) || TREE_CODE (expression) == USING_DECL)
     return true;
 
   /* Some expression forms are never type-dependent.  */
   if (TREE_CODE (expression) == PSEUDO_DTOR_EXPR
       || TREE_CODE (expression) == SIZEOF_EXPR
       || TREE_CODE (expression) == ALIGNOF_EXPR
Index: gcc/testsuite/g++.dg/ext/pr58834.C

===================================================================
--- gcc/testsuite/g++.dg/ext/pr58834.C	(revision 0)

+++ gcc/testsuite/g++.dg/ext/pr58834.C	(working copy)

@@ -0,0 +1,5 @@ 

+template<typename> void foo()

+{

+  int i __attribute__((vector_size(2*sizeof(int))));

+  (void) __builtin_shuffle(i, i);

+}