From patchwork Thu Jun 9 14:19:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 99750 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 9F2DFB6FE2 for ; Fri, 10 Jun 2011 00:19:03 +1000 (EST) Received: (qmail 30711 invoked by alias); 9 Jun 2011 14:19:02 -0000 Received: (qmail 30703 invoked by uid 22791); 9 Jun 2011 14:19:01 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from smtp207.alice.it (HELO smtp207.alice.it) (82.57.200.103) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Jun 2011 14:18:44 +0000 Received: from [192.168.1.4] (79.43.213.74) by smtp207.alice.it (8.5.124.08) id 4DE640D500BE463C; Thu, 9 Jun 2011 16:18:40 +0200 Message-ID: <4DF0D668.4060107@oracle.com> Date: Thu, 09 Jun 2011 16:19:20 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 29003 References: <4DF09B6B.4060709@oracle.com> <4DF0D368.4020206@redhat.com> In-Reply-To: <4DF0D368.4020206@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 On 06/09/2011 04:06 PM, Jason Merrill wrote: > On 06/09/2011 06:07 AM, Paolo Carlini wrote: >> I tested on x86_64-linux the below patchlet for a long standing >> accepts-invalid. Is it ok for mainline? Or do we want a different error >> message? A somehow tighter check? > > The error message needs to say something about typedef being the > problem. Maybe follow the pattern of the previous error, and say > > error ("declaration of %qD as %", dname); Right. Updated and retested. Is this variant Ok? Thanks, Paolo. /////////////////////// Index: testsuite/g++.dg/parse/error38.C =================================================================== --- testsuite/g++.dg/parse/error38.C (revision 0) +++ testsuite/g++.dg/parse/error38.C (revision 0) @@ -0,0 +1,3 @@ +// PR c++/29003 + +typedef int operator !(); // { dg-error "declaration" } Index: cp/decl.c =================================================================== --- cp/decl.c (revision 174838) +++ cp/decl.c (working copy) @@ -8441,6 +8441,13 @@ grokdeclarator (const cp_declarator *declarator, return error_mark_node; } + if (dname && IDENTIFIER_OPNAME_P (dname) + && declspecs->specs[(int)ds_typedef]) + { + error ("declaration of %qD as %", dname); + return error_mark_node; + } + /* Anything declared one level down from the top level must be one of the parameters of a function (because the body is at least two levels down). */