From patchwork Wed Jan 9 15:46:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1022490 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-493721-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="UrxRjdMb"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="eF09/8on"; 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 43ZYR14S2Dz9sCh for ; Thu, 10 Jan 2019 02:47:08 +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=dtyXEdMfkL7lfMb1RKaaW2qKrDs2UmdB0XJ8pd1cuW3XPxGqOv tCVFBpVH2aRfti7gSrwKqI5HhFAbedhwaXdL8av73A65ApDAQu2kHU0bP5+xzpCc HQCR/P6qTgPAA8gAG+g4ziuARfB+fs8rQosofwkgdtg3sarHhkUDPRC60= 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=0c4w0uKvitB/0VyrJTVNUMeKtlo=; b=UrxRjdMbQEhG8dfIspX0 9PEcrkKS/e94lHH8+6kDjO/LYgHyZsEjKSm78Rif1Xwmm3SLwWX0Mp9fQEIeijVA sRK99IW0X8vMC8UcZjwzwxzoDfW66F+LPtjcBN2vQU9uD5ptG9gbgsnU3m3omeIw xO/I272KCJ9or3V9wR5tgA8= Received: (qmail 121923 invoked by alias); 9 Jan 2019 15:47:01 -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 121913 invoked by uid 89); 9 Jan 2019 15:47:00 -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=nonexistent, sk:paoloc, paolocarlinioraclecom, sk:paolo.c 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, 09 Jan 2019 15:46:58 +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 x09FhVWd180270; Wed, 9 Jan 2019 15:46:56 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=valaTJuaIbKFRhAEVjaXo9uUKBJWktWZO6o7N8hOLXw=; b=eF09/8on0wL12OFu8wVONWl8IPHHG0cvz06XY2mXOkhH+FP1N+v7FE3rTr9X1MnloNkl +yyjaJgv2bpKf7WxOPBippjdG+uH3eTdUgZ9sbgXQ6nDldxXDjU8cRVmDbZMaJWT7ISA yS0BhAxPunjDgetYoZp1LL1kLRufApjXnHAqVTu4xxDq6YPGywqV6x0faluVMtRgkoCR Mnyvy21RYJhywsT8UJclmPOWYGWBboV1Ob40NCp1k/dK8pnDarzqm4dTLlqBBqFNuKEe +0z4FQSKFzdn8hglwJuBPMcIIHXlID9XBrfu93kPWhFstBn5oPF4pgzGI/qvn9iUSIrE VQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2ptj3e2amy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jan 2019 15:46:56 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x09FkpcA020571 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Jan 2019 15:46:51 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x09Fkp3l019612; Wed, 9 Jan 2019 15:46:51 GMT Received: from [192.168.1.4] (/80.181.224.14) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 09 Jan 2019 07:46:50 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Fix three locations Message-ID: Date: Wed, 9 Jan 2019 16:46:48 +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, three additional fixes along the usual lines. In the grokdeclarator changes I'm not touching the actual printing of the name, but another option would be using %qD and decl here too, thus, for cases like parse/crash43.C, where everything lives inside a namespace, we would print 'N::i'. instead of simply 'i'. Tested x86_64-linux, plus I checked by hand with a cross-compiler the dllimport bit. Thanks, Paolo. //////////////////////// /cp 2019-01-09 Paolo Carlini * decl.c (start_decl): Improve error location. (grokdeclarator): Likewise, improve two locations. /testsuite 2019-01-09 Paolo Carlini * g++.dg/diagnostic/extern-initialized.C: New. * g++.dg/ext/dllimport-initialized.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 267756) +++ cp/decl.c (working copy) @@ -5096,7 +5096,8 @@ start_decl (const cp_declarator *declarator, a definition. */ if (initialized && DECL_DLLIMPORT_P (decl)) { - error ("definition of %q#D is marked %", decl); + error_at (DECL_SOURCE_LOCATION (decl), + "definition of %q#D is marked %", decl); DECL_DLLIMPORT_P (decl) = 0; } @@ -12791,11 +12792,13 @@ grokdeclarator (const cp_declarator *declarator, /* It's common practice (and completely valid) to have a const be initialized and declared extern. */ if (!(type_quals & TYPE_QUAL_CONST)) - warning (0, "%qs initialized and declared %", name); + warning_at (DECL_SOURCE_LOCATION (decl), 0, + "%qs initialized and declared %", name); } else { - error ("%qs has both % and initializer", name); + error_at (DECL_SOURCE_LOCATION (decl), + "%qs has both % and initializer", name); return error_mark_node; } } Index: testsuite/g++.dg/diagnostic/extern-initialized.C =================================================================== --- testsuite/g++.dg/diagnostic/extern-initialized.C (nonexistent) +++ testsuite/g++.dg/diagnostic/extern-initialized.C (working copy) @@ -0,0 +1,6 @@ +extern int i __attribute__((unused)) = 0; // { dg-warning "12:.i. initialized and declared .extern." } + +void foo() +{ + extern int i __attribute__((unused)) = 0; // { dg-error "14:.i. has both .extern. and initializer" } +} Index: testsuite/g++.dg/ext/dllimport-initialized.C =================================================================== --- testsuite/g++.dg/ext/dllimport-initialized.C (nonexistent) +++ testsuite/g++.dg/ext/dllimport-initialized.C (working copy) @@ -0,0 +1,3 @@ +// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw* x86_64-*-mingw* } } + +__attribute__((dllimport)) int i __attribute__((unused)) = 0; // { dg-error "32:definition of .int i. is marked .dllimport." }