From patchwork Wed Dec 12 14:56:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1012041 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-492247-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="FDn0jIr7"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="dE1F2XEY"; 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 43FKdq5T7Rz9s47 for ; Thu, 13 Dec 2018 01:56:47 +1100 (AEDT) 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=Nu18wx0pmbGegdS4b8mO2kWx5UCTzS7UxJ/q5JuRFtTtZPbI2g DGfTMHVw2Le8e5esGGgakxexBUbZ9fl1s7xVEo+XcD9W6bZUHqucMo+LBpqPgni0 Xeiy+nnFFLVIlghE7ITqegcaNgbsh2OOhLG2y1wdEKHEn5/IHw12vMx+M= 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=IX7o8cgoY9ZvtM1UsysKIyV1c0Y=; b=FDn0jIr7JsMmoKeQTFPS ya5um9gbefAW+HF6u3IYWKEoRMgthgZRmlI621Md9igiLlcq3BV+PFRakbQ01WxK tsCcQJwzi8446HCHIMM/xZNjTODXBau0etksS/wiVvHIw265a5a63bwvtdHmc9T1 YsoQnOQPE0xo9HayJNbdqAk= Received: (qmail 85352 invoked by alias); 12 Dec 2018 14:56:37 -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 84922 invoked by uid 89); 12 Dec 2018 14:56:37 -0000 Authentication-Results: sourceware.org; auth=none 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=H*Ad:D*oracle.com, Hx-languages-length:1495 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; Wed, 12 Dec 2018 14:56:35 +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 wBCErWMn149002; Wed, 12 Dec 2018 14:56:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=1qFCPnKUJ8sQmGu+A1jcoZ5FlttXvRrBV+j7byP5qLE=; b=dE1F2XEYjHSS37eiPvxIm2eHgYyoqipaFgxrREplo3U7TbwkXcoZqoHq7qZy7epWIkmG /95i/FU7tFiYWzBGSUPsDQoYwYQTn4Pg5FqNy/w5EOhFB/R/8EUJuOIqN4dlf7mnuiTP EaBRjBUgR8pHjWqIx2HCyCosWGZ4vSLyRP0p/EgdmQIckCLVy0aX2epigMi3T8Ju+IUr QpnTURhphka8rBIT0tHC/80KZ3jVfYFzdSbKz9tiv7wdQ0fPp2r1HcW550P92eJh2vO3 97Ladvz7TP57Ex7I6Ngod2lD2V+MvcNezHnOosqOY+SdrG4IdR37gL1U+fKc1XMgxmE8 oA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2pawwp26sr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Dec 2018 14:56:33 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wBCEuWtJ030475 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Dec 2018 14:56:33 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wBCEuWJs013469; Wed, 12 Dec 2018 14:56:32 GMT Received: from [192.168.1.4] (/80.181.224.14) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 12 Dec 2018 06:56:31 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Fix location of grokdeclarator error message about static data member definition Message-ID: <3d234751-fcf4-acff-f1e1-f3211c62aba6@oracle.com> Date: Wed, 12 Dec 2018 15:56:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, it seems we can easily improve the location of this - not so uncommon in novice code - error to point to the 'static' keyword. Tested x86_64-linux. Thanks, Paolo. ///////////////////// /cp 2018-12-12 Paolo Carlini * decl.c (grokdeclarator): Fix location of error message about static data member definition. /testsuite 2018-12-12 Paolo Carlini * g++.dg/other/static5.C: New. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 267051) +++ cp/decl.c (working copy) @@ -12724,7 +12724,8 @@ grokdeclarator (const cp_declarator *declarator, DECL_CONTEXT (decl) = ctype; if (staticp == 1) { - permerror (input_location, "% may not be used when defining " + permerror (declspecs->locations[ds_storage_class], + "% may not be used when defining " "(as opposed to declaring) a static data member"); staticp = 0; storage_class = sc_none; Index: testsuite/g++.dg/other/static5.C =================================================================== --- testsuite/g++.dg/other/static5.C (nonexistent) +++ testsuite/g++.dg/other/static5.C (working copy) @@ -0,0 +1,8 @@ +struct S +{ + static int i; + const static double d; +}; + +static int S::i; // { dg-error "1:.static. may not be used" } +const static double S::d = 1.0; // { dg-error "7:.static. may not be used" }