From patchwork Wed Jan 22 20:34:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 313408 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3CC182C00B5 for ; Thu, 23 Jan 2014 07:34:41 +1100 (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:subject:references :in-reply-to:content-type; q=dns; s=default; b=KQnyKk6mlCthht688 46LjtJajCHGFNjV1nrETB3JBqqb9d1LKjn1XkqDteUIhkTYqG5ldquCPtMvnx58t e+FzhqNWieAFn2k6IYvm8vOzAwBHnQdR9nv7l+AXOd5RYeg3HYnXvd0c1Kz7NPxf 3yx7k8F0t18tg9MpKAnfNRAAuI= 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:subject:references :in-reply-to:content-type; s=default; bh=WXB7TQf6JTC5YmrYXwhHg/N HH/8=; b=Cl9wlkAzoIDWSO/HdNAtqOx90941mEkJtt126VDiQuGxaEF3iMmu+p+ ba3Z2wQdCh/obF924pqxwlSiRln3vwOELnBA3bNOodCAbXZvscyDr6c1dO4u1DMy AHzToX8Ue496QT8DH4/2goSN1DQ772GWbKT6KtoVBPHwUmxAyYSY= Received: (qmail 17835 invoked by alias); 22 Jan 2014 20:34:25 -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 17774 invoked by uid 89); 22 Jan 2014 20:34:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, FSL_NEW_HELO_USER, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 22 Jan 2014 20:34:23 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s0MKYLM4027875 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 22 Jan 2014 20:34:22 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s0MKYLwi006210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 22 Jan 2014 20:34:21 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s0MKYKv8025042; Wed, 22 Jan 2014 20:34:20 GMT Received: from [192.168.1.4] (/79.33.221.196) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 22 Jan 2014 12:34:20 -0800 Message-ID: <52E02B4A.8090001@oracle.com> Date: Wed, 22 Jan 2014 21:34:18 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 58980 References: <52DE6C3E.4030708@oracle.com> <52DE8A5F.6050408@redhat.com> <52DFFC52.9070809@redhat.com> In-Reply-To: <52DFFC52.9070809@redhat.com> X-IsSubscribed: yes Hi, On 01/22/2014 06:13 PM, Jason Merrill wrote: > On 01/21/2014 09:55 AM, Jason Merrill wrote: >> I think I would prefer to change the "child" assert to be >> MAYBE_CLASS_TYPE_P rather than CLASS_TYPE_P. > On second thought, no, I think we do want to specifically handle > TYPENAME_TYPE. But I think we want a different error message; getting > a TYPENAME_TYPE here means that B has not been declared. The current > scope is irrelevant. So we want to check for TYPENAME_TYPE before we > think about checking prev_scope. Ok. In fact I entertained myself this kind of reasoning, a couple of days ago... I tested the below, which uses "by hand" %Es instead of %qT for more concise error messages (consistent with the non-template case). Thanks, Paolo. //////////////////// /cp 2014-01-22 Paolo Carlini PR c++/58980 * parser.c (cp_parser_enum_specifier): Handle TYPENAME_TYPE as nested_name_specifier. /testsuite 2014-01-22 Paolo Carlini PR c++/58980 * g++.dg/parse/enum11.C: New. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 206933) +++ cp/parser.c (working copy) @@ -15469,9 +15469,17 @@ cp_parser_enum_specifier (cp_parser* parser) error_at (type_start_token->location, "cannot add an enumerator " "list to a template instantiation"); + if (prev_scope && TREE_CODE (nested_name_specifier) == TYPENAME_TYPE) + { + error_at (type_start_token->location, + "%<%E::%E%> has not been declared", + prev_scope, nested_name_specifier); + type = error_mark_node; + } /* If that scope does not contain the scope in which the class was originally declared, the program is invalid. */ - if (prev_scope && !is_ancestor (prev_scope, nested_name_specifier)) + else if (prev_scope && !is_ancestor (prev_scope, + nested_name_specifier)) { if (at_namespace_scope_p ()) error_at (type_start_token->location, @@ -15480,7 +15488,8 @@ cp_parser_enum_specifier (cp_parser* parser) type, prev_scope, nested_name_specifier); else error_at (type_start_token->location, - "declaration of %qD in %qD which does not enclose %qD", + "declaration of %qD in %qD which does not " + "enclose %qD", type, prev_scope, nested_name_specifier); type = error_mark_node; } Index: testsuite/g++.dg/parse/enum11.C =================================================================== --- testsuite/g++.dg/parse/enum11.C (revision 0) +++ testsuite/g++.dg/parse/enum11.C (working copy) @@ -0,0 +1,6 @@ +// PR c++/58980 + +template struct A +{ + enum A::B::C {}; // { dg-error "has not been declared" } +};