Patchwork [C++] Allow p->~T() when T is a vector

login
register
mail settings
Submitter Marc Glisse
Date Aug. 2, 2012, 8:23 p.m.
Message ID <alpine.DEB.2.02.1208022217410.19081@stedding.saclay.inria.fr>
Download mbox | patch
Permalink /patch/174809/
State New
Headers show

Comments

Marc Glisse - Aug. 2, 2012, 8:23 p.m.
On Thu, 2 Aug 2012, Jason Merrill wrote:

> On 08/02/2012 07:42 AM, Marc Glisse wrote:
>> +	    if (SCALAR_TYPE_P (object_type)
>> +		|| TREE_CODE (object_type) == VECTOR_TYPE)
>
> You can use "scalarish_type_p" for this test.  OK with that change.

That function was static, so I had to change that. I will thus commit the 
attached tomorrow:

gcc/cp/ChangeLog
2012-08-02  Marc Glisse  <marc.glisse@inria.fr>

 	* pt.c (tsubst_copy_and_build): Handle VECTOR_TYPE like scalars.
 	* cp-tree.h (scalarish_type_p): Declare.
 	* tree.c (scalarish_type_p): Make non-static.

gcc/testsuite/ChangeLog
2012-08-02  Marc Glisse  <marc.glisse@inria.fr>

 	* g++.dg/ext/vector17.C: New testcase.

Patch

Index: testsuite/g++.dg/ext/vector17.C

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

+++ testsuite/g++.dg/ext/vector17.C	(revision 0)

@@ -0,0 +1,12 @@ 

+/* { dg-do compile } */

+typedef double __attribute__((vector_size(1024) )) vec;

+

+template <class T>

+void f (T *p)

+{

+  p->~T();

+}

+void g (vec *p)

+{

+  f(p);

+}


Property changes on: testsuite/g++.dg/ext/vector17.C
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision URL
Added: svn:eol-style
   + native

Index: cp/tree.c

===================================================================
--- cp/tree.c	(revision 190086)

+++ cp/tree.c	(working copy)

@@ -2811,21 +2811,21 @@  is_dummy_object (const_tree ob)

 {
   if (TREE_CODE (ob) == INDIRECT_REF)
     ob = TREE_OPERAND (ob, 0);
   return (TREE_CODE (ob) == NOP_EXPR
 	  && TREE_OPERAND (ob, 0) == void_zero_node);
 }
 
 /* Returns 1 iff type T is something we want to treat as a scalar type for
    the purpose of deciding whether it is trivial/POD/standard-layout.  */
 
-static bool

+bool

 scalarish_type_p (const_tree t)
 {
   if (t == error_mark_node)
     return 1;
 
   return (SCALAR_TYPE_P (t)
 	  || TREE_CODE (t) == VECTOR_TYPE);
 }
 
 /* Returns true iff T requires non-trivial default initialization.  */
Index: cp/cp-tree.h

===================================================================
--- cp/cp-tree.h	(revision 190086)

+++ cp/cp-tree.h	(working copy)

@@ -5690,20 +5690,21 @@  extern tree stabilize_expr			(tree, tree

 extern void stabilize_call			(tree, tree *);
 extern void stabilize_aggr_init			(tree, tree *);
 extern bool stabilize_init			(tree, tree *);
 extern tree add_stmt_to_compound		(tree, tree);
 extern void init_tree				(void);
 extern bool pod_type_p				(const_tree);
 extern bool layout_pod_type_p			(const_tree);
 extern bool std_layout_type_p			(const_tree);
 extern bool trivial_type_p			(const_tree);
 extern bool trivially_copyable_p		(const_tree);
+extern bool scalarish_type_p			(const_tree);

 extern bool type_has_nontrivial_default_init	(const_tree);
 extern bool type_has_nontrivial_copy_init	(const_tree);
 extern bool class_tmpl_impl_spec_p		(const_tree);
 extern int zero_init_p				(const_tree);
 extern tree strip_typedefs			(tree);
 extern tree strip_typedefs_expr			(tree);
 extern tree copy_binfo				(tree, tree, tree,
 						 tree *, int);
 extern int member_p				(const_tree);
 extern cp_lvalue_kind real_lvalue_p		(const_tree);
Index: cp/pt.c

===================================================================
--- cp/pt.c	(revision 190086)

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

@@ -13844,21 +13844,21 @@  tsubst_copy_and_build (tree t,

 				    args, complain, in_decl);
 	else
 	  member = tsubst_copy (member, args, complain, in_decl);
 	if (member == error_mark_node)
 	  return error_mark_node;
 
 	if (type_dependent_expression_p (object))
 	  /* We can't do much here.  */;
 	else if (!CLASS_TYPE_P (object_type))
 	  {
-	    if (SCALAR_TYPE_P (object_type))

+	    if (scalarish_type_p (object_type))

 	      {
 		tree s = NULL_TREE;
 		tree dtor = member;
 
 		if (TREE_CODE (dtor) == SCOPE_REF)
 		  {
 		    s = TREE_OPERAND (dtor, 0);
 		    dtor = TREE_OPERAND (dtor, 1);
 		  }
 		if (TREE_CODE (dtor) == BIT_NOT_EXPR)