From patchwork Fri Jun 2 08:35:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 770184 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 3wfHbC3tBLz9sDG for ; Fri, 2 Jun 2017 18:35:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="sEuNNilg"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=mW7ou7zOy3+TayzujEBxR6hNCqLdyI6Sn+UZFhqeyAKp70uWtb MfFHSz4JdBbIH4rBS5tV3NCA5O2YIQ6EghzTP1ukajOlkAMpUiSUb8s+GP6S+zT2 FytJNGhF4+R1c0kLtvets7pkDWBieh/yE5zMeK/toImMqyiSZdyOWLTzA= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=tfbYp/qER+S2DIzXE1kcsNZJGwY=; b=sEuNNilgXjeH8iz58s+1 nTaiUW9mqhMWd7/rDkLD8MLR2bcPUStOlo/TuHq0CWhS/sOy8gb48TF8e3nMgsyS aFnlmziLBbHDvYw4ftmajIbjGT/iZDZNPTqw72v/YByG9bb0JvLwyvp+Gqq8Qy/z ziwuhPVxyH9mG4u9WgE4ryc= Received: (qmail 27951 invoked by alias); 2 Jun 2017 08:35:05 -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 27938 invoked by uid 89); 2 Jun 2017 08:35:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=manuel, Manuel X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Jun 2017 08:35:02 +0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v528Z3ci003337 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 2 Jun 2017 08:35:04 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v528Z34t011525 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 2 Jun 2017 08:35:03 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v528Z2do013532; Fri, 2 Jun 2017 08:35:02 GMT Received: from [192.168.1.4] (/79.13.225.104) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Jun 2017 01:35:02 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 62315 ("do not print typename in diagnostic if the original code does not have it") Message-ID: <689cbd6e-7974-4aa9-9361-9f04f920d9a8@oracle.com> Date: Fri, 2 Jun 2017 10:35:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, a while ago Manuel noticed that printing 'typename' in error messages about missing 'typename' can be confusing. That seems easy to fix, in fact we already handle correctly a similar situation in grokdeclarator. Tested x86_64-linux. Thanks, Paolo. ////////////////// /cp 2017-06-02 Paolo Carlini PR c++/62315 * parser.c (cp_parser_diagnose_invalid_type_name): Don't print 'typename' in error messages about missing 'typename'. /testsuite 2017-06-02 Paolo Carlini PR c++/62315 * g++.dg/parse/typedef2.C: Specify a dg-error string. Index: testsuite/g++.dg/parse/typedef2.C =================================================================== --- testsuite/g++.dg/parse/typedef2.C (revision 248783) +++ testsuite/g++.dg/parse/typedef2.C (working copy) @@ -1,3 +1,2 @@ template struct B { typedef typename T::X X; }; -template struct A { typedef B::X::Y Z; }; // { dg-error "" } - +template struct A { typedef B::X::Y Z; }; // { dg-error "before 'B::X::Y' because 'B::X'" } Index: cp/parser.c =================================================================== --- cp/parser.c (revision 248783) +++ cp/parser.c (working copy) @@ -3270,9 +3270,21 @@ cp_parser_diagnose_invalid_type_name (cp_parser *p } else if (TYPE_P (parser->scope) && dependent_scope_p (parser->scope)) - error_at (location, "need % before %<%T::%E%> because " - "%qT is a dependent scope", - parser->scope, id, parser->scope); + { + if (TREE_CODE (parser->scope) == TYPENAME_TYPE) + error_at (location, + "need % before %<%T::%D::%E%> because " + "%<%T::%D%> is a dependent scope", + TYPE_CONTEXT (parser->scope), + TYPENAME_TYPE_FULLNAME (parser->scope), + id, + TYPE_CONTEXT (parser->scope), + TYPENAME_TYPE_FULLNAME (parser->scope)); + else + error_at (location, "need % before %<%T::%E%> because " + "%qT is a dependent scope", + parser->scope, id, parser->scope); + } else if (TYPE_P (parser->scope)) { if (!COMPLETE_TYPE_P (parser->scope))