From patchwork Mon Jul 8 23:32:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 257614 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 82B082C0178 for ; Tue, 9 Jul 2013 09:32:25 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=lBAIv0GpqDmt2QPS1 hQZkCuZerm+KJAbjIFdY0ZnV10utu+ZoO3aoSWtopGmLYoahtZ6obHcv4FTnCGmq qxtnkBBvms5UhPPnAAz31vmoRsVabI9cEpv6Ivdy4IlfE7Dy5Rwk8gTNUSieNTzV 30UKtMxEK6i1tv3PgNQ/1t7RjQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=Oo2jRVMZWiLHF/YEq5ynboI SWeI=; b=OS1dOvtVWseLuBSlL0RdQm9IqoUc0JR0Ox29n/P3m/O9Ml4DmIWao26 bqHhqTowyCXrX2+JJz7p5hvKWh8nsJSuZcPZvT8YXKBR4nvcLscNkD6Va7N3WHOb /8ph9SVGfIGHaEy7M13bLOCs1mF7Rw0PCGm9xkHLyU1CQWmFvgug= Received: (qmail 28182 invoked by alias); 8 Jul 2013 23:32:18 -0000 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 Received: (qmail 28172 invoked by uid 89); 8 Jul 2013 23:32:18 -0000 X-Spam-SWARE-Status: No, score=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 08 Jul 2013 23:32:17 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r68NWFsm008740 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 8 Jul 2013 23:32:16 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r68NWEQ7024131 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 8 Jul 2013 23:32:15 GMT Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r68NWElc027403; Mon, 8 Jul 2013 23:32:14 GMT Received: from poldo4.casa (/79.25.196.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 08 Jul 2013 16:32:14 -0700 Message-ID: <51DB4BFB.6010402@oracle.com> Date: Tue, 09 Jul 2013 01:32:11 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 51786 References: <51D9982C.2040502@oracle.com> <51DAE4AA.9060809@redhat.com> <5d947fff-e131-4a1a-a721-74859015e444@email.android.com> <51DAFE62.4050000@redhat.com> In-Reply-To: <51DAFE62.4050000@redhat.com> X-Virus-Found: No On 07/08/2013 08:01 PM, Jason Merrill wrote: > On 07/08/2013 01:49 PM, Paolo Carlini wrote: >> Ah I see. I take your indication as meaning class *or enum* > Yes. Thanks. Thus, as agreed, I tested the below. Ok? Paolo. /////////////////////////// Index: cp/parser.c =================================================================== --- cp/parser.c (revision 200780) +++ cp/parser.c (working copy) @@ -11009,11 +11009,21 @@ cp_parser_simple_declaration (cp_parser* parser, /* Issue an error message if no declarators are present, and the decl-specifier-seq does not itself declare a class or - enumeration. */ + enumeration: [dcl.dcl]/3. */ if (!saw_declarator) { if (cp_parser_declares_only_class_p (parser)) - shadow_tag (&decl_specifiers); + { + if (!declares_class_or_enum + && decl_specifiers.type + && (CLASS_TYPE_P (decl_specifiers.type) + || TREE_CODE (decl_specifiers.type) == ENUMERAL_TYPE)) + /* Ensure an error is issued anyway when finish_decltype_type, + called via cp_parser_decl_specifier_seq, returns a class or + an enumeration (c++/51786). */ + decl_specifiers.type = NULL_TREE; + shadow_tag (&decl_specifiers); + } /* Perform any deferred access checks. */ perform_deferred_access_checks (tf_warning_or_error); } Index: testsuite/g++.dg/cpp0x/pr51786.C =================================================================== --- testsuite/g++.dg/cpp0x/pr51786.C (revision 0) +++ testsuite/g++.dg/cpp0x/pr51786.C (working copy) @@ -0,0 +1,8 @@ +// PR c++/51786 +// { dg-do compile { target c++11 } } + +enum E {}; +struct A {}; + +void foo() { decltype(E{}); } // { dg-error "does not declare anything" } +void bar() { decltype(A{}); } // { dg-error "does not declare anything" }