From patchwork Tue Nov 9 03:47:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 70492 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 AF4FBB711E for ; Tue, 9 Nov 2010 14:47:16 +1100 (EST) Received: (qmail 13503 invoked by alias); 9 Nov 2010 03:47:14 -0000 Received: (qmail 13490 invoked by uid 22791); 9 Nov 2010 03:47:13 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Nov 2010 03:47:09 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA93l7K5010018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 8 Nov 2010 22:47:07 -0500 Received: from [127.0.0.1] (ovpn-113-31.phx2.redhat.com [10.3.113.31]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA93l6rJ009209 for ; Mon, 8 Nov 2010 22:47:06 -0500 Message-ID: <4CD8C439.9000305@redhat.com> Date: Mon, 08 Nov 2010 21:47:05 -0600 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101104 Lightning/1.0b1 Shredder/3.0.11pre MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/46335 (C++0x ICE with T() default argument) 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 As part of the constexpr work I've started setting TREE_CONSTANT on a TARGET_EXPR wrapped around a constant CONSTRUCTOR; this confused bot_manip, which assumed that there couldn't be anything interesting within a TREE_CONSTANT expression. Tested x86_64-pc-linux-gnu, applied to trunk. commit abf9d4a2b6eabe2b6d3a2cff5be58ef3708e843b Author: Jason Merrill Date: Mon Nov 8 18:40:07 2010 -0600 PR c++/46335 * tree.c (bot_manip): Check TREE_SIDE_EFFECTS as well. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5440e10..462e35f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1763,11 +1763,10 @@ bot_manip (tree* tp, int* walk_subtrees, void* data) splay_tree target_remap = ((splay_tree) data); tree t = *tp; - if (!TYPE_P (t) && TREE_CONSTANT (t)) + if (!TYPE_P (t) && TREE_CONSTANT (t) && !TREE_SIDE_EFFECTS (t)) { /* There can't be any TARGET_EXPRs or their slot variables below - this point. We used to check !TREE_SIDE_EFFECTS, but then we - failed to copy an ADDR_EXPR of the slot VAR_DECL. */ + this point. */ *walk_subtrees = 0; return NULL_TREE; } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C new file mode 100644 index 0000000..1413b24 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C @@ -0,0 +1,12 @@ +// PR c++/46335 +// { dg-options -std=c++0x } + +struct T { }; +struct A { + A(const T &tr =T()) {} +}; +struct B { + A k; +}; +B kk_; +A fk_;