From patchwork Fri Jun 1 21:03:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 924335 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-478936-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VhN1vJQP"; dkim-atps=neutral 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 40yGzB2rszz9s15 for ; Sat, 2 Jun 2018 07:04:06 +1000 (AEST) 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=cey/APxhLTfnt7mr13Ynma4yrrTgoKyY2VeKLCmt0hXyeR9CD+ ejM9ajj1pZtZuYJVrCZKL5vuDoEvUzNDe7gJUlVB2Z0fSHED4nwOgKYTC3uYatkd cetDd3XohgqgvDoYhZYJmd7BQ5i6iz8kWssIQt79SJtyecp5w6HbJ2jtE= 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=8GpeZHLJuuhTUsjvcbMEIyoTu30=; b=VhN1vJQPleaSoF5QCSL5 MPE2QsKO/bH5KGIPU158l2+hDfu/gndGWNT+sWTRno2M+h3QnbXiDZtkZkf0IY00 kFan2aRnJ6TtZZsvixW8TM4LioEmh+Ro6iiUHRg0VGq0AT9LAs5A0a+xm+asJbxe 4Lawy/1Okq2sB45w+106cSg= Received: (qmail 16244 invoked by alias); 1 Jun 2018 21:03:59 -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 16222 invoked by uid 89); 1 Jun 2018 21:03:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=cb, CB, tiny, declc X-HELO: aserp2130.oracle.com Received: from aserp2130.oracle.com (HELO aserp2130.oracle.com) (141.146.126.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 01 Jun 2018 21:03:56 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w51KoiPP036018; Fri, 1 Jun 2018 21:03:54 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2janje65ap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Jun 2018 21:03:54 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w51L3rSW018011 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Jun 2018 21:03:53 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w51L3qZj011348; Fri, 1 Jun 2018 21:03:53 GMT Received: from [192.168.1.4] (/79.47.197.34) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Jun 2018 21:03:52 +0000 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Fix some locations Message-ID: Date: Fri, 1 Jun 2018 23:03:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8911 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806010239 X-IsSubscribed: yes Hi, while working on some bugs I noticed that in a few places in decl.c we could do better in terms of locations within the current infrastructure, some simple, straightforward improvements. I'm attaching below a tiny first patch, more to follow, I hope. For example, a function which could be improved in many places is grok_ctor_properties and, before going ahead, I'd like to ask about something I noticed yesterday:   /* There can be no default arguments.  */   for (tree arg = argtypes; arg != void_list_node; arg = TREE_CHAIN (arg))     if (TREE_PURPOSE (arg))       {         TREE_PURPOSE (arg) = NULL_TREE;         if (operator_code == POSTINCREMENT_EXPR             || operator_code == POSTDECREMENT_EXPR)           pedwarn (input_location, OPT_Wpedantic,                    "%qD cannot have default arguments", decl);         else           {             error ("%qD cannot have default arguments", decl);             return false;           }       } the special casing seems weird, so far I haven't been able to find anything in the standard about it and all the other compilers I have at hand (Oracle, Intel, Clang) don't seem to have it. Shall we keep it or not? Maybe with an additional comment explaining the rationale? The affected testcases would be parse/defarg11.C and g++.jason/operator.C. Thanks, Paolo. /////////////////// /cp 2018-06-01 Paolo Carlini * decl.c (grokfndecl): Use the location_t argument in two more places. /testsuite 2018-06-01 Paolo Carlini * g++.dg/template/friend64.C: New. * g++.old-deja/g++.other/friend4.C: Test the location too. * g++.old-deja/g++.pt/crash23.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 261078) +++ cp/decl.c (working copy) @@ -8674,8 +8674,9 @@ grokfndecl (tree ctype, if (friendp && TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR) { if (funcdef_flag) - error ("defining explicit specialization %qD in friend declaration", - orig_declarator); + error_at (location, + "defining explicit specialization %qD in friend declaration", + orig_declarator); else { tree fns = TREE_OPERAND (orig_declarator, 0); @@ -8684,9 +8685,10 @@ grokfndecl (tree ctype, if (PROCESSING_REAL_TEMPLATE_DECL_P ()) { /* Something like `template friend void f()'. */ - error ("invalid use of template-id %qD in declaration " - "of primary template", - orig_declarator); + error_at (location, + "invalid use of template-id %qD in declaration " + "of primary template", + orig_declarator); return NULL_TREE; } Index: testsuite/g++.dg/template/friend64.C =================================================================== --- testsuite/g++.dg/template/friend64.C (nonexistent) +++ testsuite/g++.dg/template/friend64.C (working copy) @@ -0,0 +1,6 @@ +template void foo (int); + +template +class Q { + friend void foo (int) { } // { dg-error "15:defining explicit specialization" } +}; Index: testsuite/g++.old-deja/g++.other/friend4.C =================================================================== --- testsuite/g++.old-deja/g++.other/friend4.C (revision 261078) +++ testsuite/g++.old-deja/g++.other/friend4.C (working copy) @@ -11,7 +11,7 @@ template void foo(); template class bar { int i; // { dg-message "" } private - template friend void foo(); // { dg-error "" } bogus declaration + template friend void foo(); // { dg-error "34:invalid use of template-id" } }; template void foo() { bar baz; baz.i = 1; // { dg-error "" } foo cannot access bar::i Index: testsuite/g++.old-deja/g++.pt/crash23.C =================================================================== --- testsuite/g++.old-deja/g++.pt/crash23.C (revision 261078) +++ testsuite/g++.old-deja/g++.pt/crash23.C (working copy) @@ -4,7 +4,7 @@ template void foo(); template class bar { public: int i; - template friend void foo(); // { dg-error "" } template-id + template friend void foo(); // { dg-error "34:invalid use of template-id" } }; template void foo() { bar baz; baz.i = 1;