From patchwork Tue Jan 8 13:13:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1021899 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-493625-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="c/WtUR6g"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="OCn60JIn"; 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 43Yt534Zlqz9sNM for ; Wed, 9 Jan 2019 00:14:14 +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=mcWmUkFhaAzqAHVSlRsGI3UYi/PmwAgn4tr0w8LUW2oNZX3JjL VHIjUsWY9pAbf6y8fHvrqqdG6uzYTtzvyBzwJAtndvx2BABRrK6NvUirJCpatcvX Z2CkIweuSdXHyDY+hrUqKPzfxQU2MQyBGn/IynfOlismd0s3+SPZVUpKE= 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=XqiM/komP1MPtVaHoobSGpekIBo=; b=c/WtUR6gn2YogepuDVKc aqHe68fpBoyY0MMom7D6KHpyaJ3PhiZHyiVjB0xbyeopn8E/3UT/LaEAjk2LIr8w qRkJyqmuDbyIsLeohknFfmIB6vBzoQxydYtBwBZKVXztB1pTk8t5TwFm0wwT1ELF Z5r/pgIW0YA+ItJZu8f/y8E= Received: (qmail 73256 invoked by alias); 8 Jan 2019 13:14: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 73231 invoked by uid 89); 8 Jan 2019 13:14:04 -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=Hx-languages-length:2557 X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Jan 2019 13:14:02 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x08DE0IP169234; Tue, 8 Jan 2019 13:14:00 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=FF2y6THI29aZexrykEGfWge1nW8u1wP8K8fvoPSQbbw=; b=OCn60JInx3VdbGQnqYLV+cYkhQcqbx7vgsrVCe0zc3uj65hUoCMUQoPAotnBcERYT6yk MVCLKO4T1zyTFjYvf+IO5PsH4YYgMn2lT3kncX43P38i2pKmdvWU14KJed0noZKIgMBU XbYj5umPL6uDJIkW8GxsBaCFs4B9lYs/50UmHv1669sZ8wP8cwGBUUuqex5+a8jviCBu RrHebjhctapXl7PEMyeK7YOoGUc87YUEbEyBhp0W4Nh61jQm3UTOl4aXb+7yjJS9bpiJ mxiVsQNlC4asH26gONuivieA/L1nSNCOAzR1zs2HoPn9+cd8HJuD9+63oc/5V1tqx6qk Yg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2ptm0u3erq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Jan 2019 13:14:00 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x08DDxkT016745 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Jan 2019 13:13:59 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x08DDwP7005509; Tue, 8 Jan 2019 13:13:58 GMT Received: from [192.168.1.4] (/80.181.224.14) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 08 Jan 2019 05:13:58 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Fix three additional locations Message-ID: <4c8fc01d-e961-f267-339a-75d002d8116a@oracle.com> Date: Tue, 8 Jan 2019 14:13:55 +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, a few additional easy to fix cases where we thought that a plain error was good enough. Tested x86_64-linux. Thanks, Paolo. //////////////////// /cp 2019-01-08 Paolo Carlini * decl.c (grok_reference_init): Improve error location. (grokdeclarator): Likewise, improve two locations. /testsuite 2019-01-08 Paolo Carlini * g++.dg/diagnostic/constexpr2.C: New. * g++.dg/diagnostic/ref3.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 267675) +++ cp/decl.c (working copy) @@ -5357,7 +5357,8 @@ grok_reference_init (tree decl, tree type, tree in if ((DECL_LANG_SPECIFIC (decl) == 0 || DECL_IN_AGGR_P (decl) == 0) && ! DECL_THIS_EXTERN (decl)) - error ("%qD declared as reference but not initialized", decl); + error_at (DECL_SOURCE_LOCATION (decl), + "%qD declared as reference but not initialized", decl); return NULL_TREE; } @@ -12517,8 +12518,9 @@ grokdeclarator (const cp_declarator *declarator, unqualified_id); else if (constexpr_p && !initialized) { - error ("% static data member %qD must have an " - "initializer", decl); + error_at (DECL_SOURCE_LOCATION (decl), + "% static data member %qD must " + "have an initializer", decl); constexpr_p = false; } @@ -12756,8 +12758,9 @@ grokdeclarator (const cp_declarator *declarator, } else if (constexpr_p && DECL_EXTERNAL (decl)) { - error ("declaration of % variable %qD " - "is not a definition", decl); + error_at (DECL_SOURCE_LOCATION (decl), + "declaration of % variable %qD " + "is not a definition", decl); constexpr_p = false; } Index: testsuite/g++.dg/diagnostic/constexpr2.C =================================================================== --- testsuite/g++.dg/diagnostic/constexpr2.C (nonexistent) +++ testsuite/g++.dg/diagnostic/constexpr2.C (working copy) @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } + +extern constexpr int i __attribute__((unused)); // { dg-error "22:declaration of .constexpr. variable .i." } + +struct S +{ + constexpr static int i __attribute__((unused)); // { dg-error "24:.constexpr. static data member .i." } +}; Index: testsuite/g++.dg/diagnostic/ref3.C =================================================================== --- testsuite/g++.dg/diagnostic/ref3.C (nonexistent) +++ testsuite/g++.dg/diagnostic/ref3.C (working copy) @@ -0,0 +1 @@ +int& i __attribute__((unused)); // { dg-error "6:.i. declared as reference" }