From patchwork Fri May 25 22:37:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 161434 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 D475EB6EEC for ; Sat, 26 May 2012 08:39:14 +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=1338590355; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=VJ8/PgInQNkhP1qHelggR3eewwE=; b=RYOeJ8f8MGzsnFVvRrTgYoAWRgZ5ghNgo3FQ8zvIlJcf+CjgpZQ14WqyyrQP56 LgFueXXlk7Qpc8+xR1OaKfBEg1F2cJfVXjjbAM9vOETJ7DLx1yz+t7h10DHUVRJe vcK8CCaCodEvDnsahE+XzCtIUsRC0ywnSrUldeL5/wnNw= 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:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=e09R0rjSDthMqjb6Wni/7mbd52jJw1daiAw5OXlsjVzmQR5Ni1VLyw9MWvTWsB cs+pHoZnPaoyc06m/LPbZoaoK0hDQi9T07wFDBvEW02A0wfAW6QXguJOgPFarBWF DuFm4Go/CKgejKf+u4UG/j47JA7MFaw+TXZk8497qCu4Y=; Received: (qmail 30891 invoked by alias); 25 May 2012 22:39:07 -0000 Received: (qmail 30882 invoked by uid 22791); 25 May 2012 22:39:06 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 May 2012 22:38:53 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q4PMcpBN023091 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 25 May 2012 22:38:51 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q4PMcowZ007907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 25 May 2012 22:38:50 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q4PMcoh6007830; Fri, 25 May 2012 17:38:50 -0500 Received: from [192.168.1.4] (/79.33.216.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 25 May 2012 15:38:49 -0700 Message-ID: <4FC009B1.8060005@oracle.com> Date: Sat, 26 May 2012 00:37:37 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 32054 References: <4FBEF51A.7040209@oracle.com> <4FBFB275.2030303@redhat.com> In-Reply-To: <4FBFB275.2030303@redhat.com> X-IsSubscribed: yes 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 Hi, On 05/25/2012 06:25 PM, Jason Merrill wrote: > On 05/24/2012 10:57 PM, Paolo Carlini wrote: >> + error_at (decl_spec_token_start->location, >> + "a storage class is not allowed"); > > Let's give more explanation here so that the user knows that the > problem is a storage class on an anonymous union/struct in class scope. Good, then I propose the below, using the form "anonymous aggregate", because - I didn't know - we are already using it in error messages elsewhere, in decl.c too. Thanks, Paolo. //////////////////// Index: testsuite/g++.dg/other/anon-union3.C =================================================================== --- testsuite/g++.dg/other/anon-union3.C (revision 0) +++ testsuite/g++.dg/other/anon-union3.C (revision 0) @@ -0,0 +1,25 @@ +// PR c++/32054 + +class C +{ + auto union // { dg-error "storage class" "" { target c++98 } } + { + int a; + }; // { dg-error "multiple|specified" "" { target c++11 } } + register union // { dg-error "storage class" } + { + int b; + }; + static union // { dg-error "storage class" } + { + int c; + }; + extern union // { dg-error "storage class" } + { + int d; + }; + mutable union // { dg-error "storage class" } + { + int e; + }; +}; Index: cp/parser.c =================================================================== --- cp/parser.c (revision 187868) +++ cp/parser.c (working copy) @@ -18910,6 +18910,12 @@ cp_parser_member_declaration (cp_parser* parser) particular type), as opposed to a nested class. */ else if (ANON_AGGR_TYPE_P (type)) { + /* C++11 9.5/6. */ + if (decl_specifiers.storage_class != sc_none) + error_at (decl_spec_token_start->location, + "a storage class on an anonymous aggregate " + "in class scope is not allowed"); + /* Remove constructors and such from TYPE, now that we know it is an anonymous aggregate. */ fixup_anonymous_aggr (type);