This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Thu, Aug 2, 2012 at 1:42 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> Hello,
>
> this patch allows p->~T() when T is (after substitution) a vector, which is
> necessary for use in std::vector for instance.

Why not include VECTOR_TYPE in ARITHMETIC_TYPE_P?

> gcc/cp/ChangeLog
> 2012-08-02  Marc Glisse  <marc.glisse@inria.fr>
>
>         * pt.c (tsubst_copy_and_build): Handle VECTOR_TYPE like scalars.
>
> gcc/testsuite/ChangeLog
> 2012-08-02  Marc Glisse  <marc.glisse@inria.fr>
>
>         * g++.dg/ext/vector17.C: New testcase.
>
> --
> Marc Glisse
> 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:eol-style
>    + native
> Added: svn:keywords
>    + Author Date Id Revision URL
>
> Index: cp/pt.c
> ===================================================================
> --- cp/pt.c     (revision 190071)
> +++ cp/pt.c     (working copy)
> @@ -13844,21 +13844,22 @@ 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 (SCALAR_TYPE_P (object_type)
> +               || TREE_CODE (object_type) == VECTOR_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)
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]