From patchwork Sun Mar 4 00:55:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 144472 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 45022B6EEA for ; Sun, 4 Mar 2012 11:56:09 +1100 (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=1331427369; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=/uTZXi2 1wr2PmK01FG15yCog3tQ=; b=nigIvbj6sA+jVp8N4EsXUXIE8ZNMWbmjrXa/LL5 VocG07cvtbrEmCeIhKPqH/NSd2B3a9RkUttk3WvJKLjnZzlAg9y6IFB22OIWJljs uTAdxGKu6MYR/6FEWl1TwRk5ZAyGAXWAZIrkEAx/jDlrHA223iyBai5jSXfgnU39 p3T4= 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:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ZeDN6w3GJo9VuYzio0Bg+JxzMXzjMRH9SUZ+pkZtIG3RF2lCntdUt17e3DOn7S jVFY+49VNd71O2y2YU1ShVniNHwSzfrRyy0MYiYDVQmJTyn103cMEPsYm9WBrET3 1qb1zX9yFuQSSjni9VCZbSbWByUbiwk00vHtQXzCeojrg=; Received: (qmail 17241 invoked by alias); 4 Mar 2012 00:56:05 -0000 Received: (qmail 17219 invoked by uid 22791); 4 Mar 2012 00:56:04 -0000 X-SWARE-Spam-Status: No, hits=-6.6 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; Sun, 04 Mar 2012 00:55:37 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q240tb5T006470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 3 Mar 2012 19:55:37 -0500 Received: from [10.3.113.56] (ovpn-113-56.phx2.redhat.com [10.3.113.56]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q240ta2D032261 for ; Sat, 3 Mar 2012 19:55:37 -0500 Message-ID: <4F52BD88.9070607@redhat.com> Date: Sat, 03 Mar 2012 19:55:36 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for NSDMI that depends on itself 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 While thinking about core issue 1351, I noticed that we weren't dealing very well with an NSDMI that depends on itself. This patch gives a helpful error message. Tested x86_64-pc-linux-gnu, applying to trunk. commit 46131bcba27d82f43a26daa12a8c8e95f7208696 Author: Jason Merrill Date: Mon Feb 20 06:15:24 2012 -0500 * init.c (perform_member_init): Cope with uninstantiated NSDMI. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 2355a04..1b2a1ef 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -540,6 +540,12 @@ perform_member_init (tree member, tree init) else { init = DECL_INITIAL (member); + if (init && TREE_CODE (init) == DEFAULT_ARG) + { + error ("constructor required before non-static data member " + "for %qD has been parsed", member); + init = NULL_TREE; + } /* Strip redundant TARGET_EXPR so we don't need to remap it, and so the aggregate init code below will see a CONSTRUCTOR. */ if (init && TREE_CODE (init) == TARGET_EXPR diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer6.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer6.C new file mode 100644 index 0000000..033c142 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer6.C @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } + +struct A // { dg-error "non-static data member" } +{ + int i = (A(), 42); // { dg-message "required here" } +}; + +A a;