From patchwork Wed May 25 19:36:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 97404 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 64AF0B6F8F for ; Thu, 26 May 2011 05:36:29 +1000 (EST) Received: (qmail 4310 invoked by alias); 25 May 2011 19:36:27 -0000 Received: (qmail 4213 invoked by uid 22791); 25 May 2011 19:36:27 -0000 X-SWARE-Spam-Status: No, hits=-6.3 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; Wed, 25 May 2011 19:36:08 +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.14.4/8.14.4) with ESMTP id p4PJa7Pj005658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 May 2011 15:36:07 -0400 Received: from [127.0.0.1] (ovpn-113-23.phx2.redhat.com [10.3.113.23]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4PJa6Vu008007 for ; Wed, 25 May 2011 15:36:07 -0400 Message-ID: <4DDD5A26.7090302@redhat.com> Date: Wed, 25 May 2011 15:36:06 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/46696 (error with defaulted op= and arrays) 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 Another case where we now need to check DECL_DEFAULTED_FN rather than DECL_ARTIFICIAL. Tested x86_64-pc-linux-gnu, applying to trunk. commit 3ac89bd9f5f81b4d3ff293b337e7e9163d3402dd Author: Jason Merrill Date: Wed May 25 12:05:03 2011 -0400 PR c++/46696 * typeck.c (cp_build_modify_expr): Check DECL_DEFAULTED_FN. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 69b25d3..5fbb765 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6748,7 +6748,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, /* Allow array assignment in compiler-generated code. */ else if (!current_function_decl - || !DECL_ARTIFICIAL (current_function_decl)) + || !DECL_DEFAULTED_FN (current_function_decl)) { /* This routine is used for both initialization and assignment. Make sure the diagnostic message differentiates the context. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted29.C b/gcc/testsuite/g++.dg/cpp0x/defaulted29.C new file mode 100644 index 0000000..5fcf5b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted29.C @@ -0,0 +1,20 @@ +// PR c++/46696 +// { dg-options -std=c++0x } + +struct A +{ + A& operator= (A const&); +}; + +struct B +{ + A ar[1]; + B& operator= (B const&) = default; +}; + +int main() +{ + B x; + B y; + y = x; +}