From patchwork Thu Dec 9 21:35:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 74993 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 D45B2B70A5 for ; Fri, 10 Dec 2010 08:35:30 +1100 (EST) Received: (qmail 27545 invoked by alias); 9 Dec 2010 21:35:27 -0000 Received: (qmail 27426 invoked by uid 22791); 9 Dec 2010 21:35:26 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_SV, 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; Thu, 09 Dec 2010 21:35:21 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB9LZF9c016206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 9 Dec 2010 16:35:19 -0500 Received: from [127.0.0.1] (ovpn-113-131.phx2.redhat.com [10.3.113.131]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB9LZEo4027466; Thu, 9 Dec 2010 16:35:14 -0500 Message-ID: <4D014B92.50606@redhat.com> Date: Thu, 09 Dec 2010 16:35:14 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20101202 Lightning/1.0b1 Shredder/3.0.11pre MIME-Version: 1.0 To: Dodji Seketeli CC: gcc-patches List Subject: Re: C++ PATCH for c++/46736 (missing diagnostic for invalid =default) References: <4CFFE382.4010002@redhat.com> In-Reply-To: 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 12/09/2010 08:42 AM, Dodji Seketeli wrote: > Not very important but it looks like this patch does not correspond to > the subject. Oops, here's the real patch. commit 21f80a31bf2440b3b8a62f20fa6298be6cb769b6 Author: jason Date: Wed Dec 8 20:00:27 2010 +0000 PR c++/46736 * decl.c (cp_finish_decl): Complain about an implicitly deleted method defaulted outside the class. * method.c (maybe_explain_implicit_delete): Don't check DECL_INITIAL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167601 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5b4dfb7..b72b588 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6094,7 +6094,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, { /* An out-of-class default definition is defined at the point where it is explicitly defaulted. */ - if (DECL_INITIAL (decl) == error_mark_node) + if (DECL_DELETED_FN (decl)) + maybe_explain_implicit_delete (decl); + else if (DECL_INITIAL (decl) == error_mark_node) synthesize_method (decl); } else diff --git a/gcc/cp/method.c b/gcc/cp/method.c index ed75a64..dc72355 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1318,8 +1318,7 @@ maybe_explain_implicit_delete (tree decl) /* If decl is a clone, get the primary variant. */ decl = DECL_ORIGIN (decl); gcc_assert (DECL_DELETED_FN (decl)); - if (DECL_DEFAULTED_FN (decl) - && DECL_INITIAL (decl) == NULL_TREE) + if (DECL_DEFAULTED_FN (decl)) { /* Not marked GTY; it doesn't need to be GC'd or written to PCH. */ static htab_t explained_htab; diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted21.C b/gcc/testsuite/g++.dg/cpp0x/defaulted21.C new file mode 100644 index 0000000..3e74033 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted21.C @@ -0,0 +1,20 @@ +// PR c++/46736 +// { dg-options -std=c++0x } + +struct U { + U(); + U(U const&); +}; + +struct X { + U const u; + X(); + X(X&&); +}; + +X::X(X&&)=default; // { dg-error "implicitly deleted" } +// { dg-error "does not have a move constructor" "" { target *-*-* } 15 } + +X f() { + return X(); +}