From patchwork Thu Aug 2 20:23:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 174809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 7AE552C0096 for ; Fri, 3 Aug 2012 06:23:42 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1344543823; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=bTvUrwj4KqJPUkselDVdwxbF6LA=; b=OaNdGGac+I2FXFf 5WKA+iMv/Z+ncSXX+xlNN8MFs3THLpAESrh0Jn5Ovsn9HNaVhz5jIs1UoHZWbT1W UXR2HvIfXJWwQmPcWMXMcpirehzZ819U/+U7fb8gEnxu+Tdm073O+cZJylHM8pNy zfdcuIHGF5YHZjgxfa5FYx4/2REA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Wf9IMqPiqfP3huIrp9ehWu9r8ZeFbBRWMGmXnD7iOx5i9ivnTU1/dsp65s/cna HsWK2Ya9Ce6W0V3LBv4gcP7yuhqybPTQHArKBMLnkJ3xF60n7OwUwBAynkMbGygS HP/O3qjkH5E7Zkc+Sr6y7Tjd6PyrJ96Dz/GrJyuK+tqaU=; Received: (qmail 17620 invoked by alias); 2 Aug 2012 20:23:28 -0000 Received: (qmail 17598 invoked by uid 22791); 2 Aug 2012 20:23:25 -0000 X-SWARE-Spam-Status: No, hits=-7.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail1-relais-roc.national.inria.fr (HELO mail1-relais-roc.national.inria.fr) (192.134.164.82) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Aug 2012 20:23:04 +0000 Received: from stedding.saclay.inria.fr ([193.55.250.194]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 02 Aug 2012 22:23:02 +0200 Received: from glisse (helo=localhost) by stedding.saclay.inria.fr with local-esmtp (Exim 4.80) (envelope-from ) id 1Sx1vB-0004y9-Sk; Thu, 02 Aug 2012 22:23:01 +0200 Date: Thu, 2 Aug 2012 22:23:01 +0200 (CEST) From: Marc Glisse To: Jason Merrill cc: gcc-patches@gcc.gnu.org Subject: Re: [C++ patch] Allow p->~T() when T is a vector In-Reply-To: <501A8FC4.7060107@redhat.com> Message-ID: References: <501A8FC4.7060107@redhat.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * 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 * g++.dg/ext/vector17.C: New testcase. 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 +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)