From patchwork Tue Jul 17 12:17:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 945005 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-481719-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="QoGrH+mS"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="gl7/PB+y"; 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 41VK6K1Myvz9s3Z for ; Tue, 17 Jul 2018 22:17:27 +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=aEmES75VLvAm7X5PSOenA0s5WQYWQSEPYGmN0KrXpB8nqi63VU NPKEH5mAHtow5w1IK+8ptthTi3RMukBsZf0i5Oscrecmpt7nAAw4ZCHnoNHsnTjV ZAOZbiN1kcE8BhpiWyqeR7oLih6lWHkaXRkkv1izrSqJBstnExYD7sAp4= 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=qeUi9jGAfYLVLiw36W0KjRpjdrM=; b=QoGrH+mSyJHjrhpnRxSQ 9ojUePcheBv1t8LEKlq76NHZIcaed3DQX0p+5fMrS3pdDli3OgGkPFfmTGc56XM1 vy0kWG50Jweenzrpnm4jjCKlz2IfDLnjpB+0YHvVkVZSjVSmldQbcsSVfU9YWEiY tUx/D9kkNCmyEaZn5cB44yQ= Received: (qmail 87700 invoked by alias); 17 Jul 2018 12:17:19 -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 87670 invoked by uid 89); 17 Jul 2018 12:17:18 -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=assemble, ABC, exercise 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, 17 Jul 2018 12:17:15 +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 w6HCExWX143457; Tue, 17 Jul 2018 12:17:12 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=8Sc4ilwehh4yJY/2yVsbrba5EJn2JTsqyLGGZKCb6n8=; b=gl7/PB+ysnsTxwTpmfpOOQlYkO2wRTX7PJVJtSNRjE/YhLd+0etWhmdNl6pX+4pyyvrY iaanUbyIestXzUfsG5gFq7OL+SMgkHxpGUQ35G1ozOuf+kfglvUZf2EatKa/lTrwoKpR Vx/niqxCMHKSOQyvT3YIbTqjpSDi9LPomVipE2KlHOY4FnjPDVj/+BjPnN1NhQP+SDHK kZUDF3hYkXtvKV16SrsftPlesVTw3AYntvT9Y+sEP9injOYV1rSTv8GY2KFm5RPoDsQ+ 1khJ8bZDDiXY18HmkajTU7R6u4+7RR/tqSo9yW+F8eLU4qzu6IZ1499A29d/JsGTEPcJ Fg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2k7a3t8dut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Jul 2018 12:17:12 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w6HCHBOs014078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Jul 2018 12:17:11 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w6HCHAS5013972; Tue, 17 Jul 2018 12:17:10 GMT Received: from [192.168.1.4] (/79.27.215.86) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 17 Jul 2018 12:17:09 +0000 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] Another permerror related tweak Message-ID: <4c47d535-ce39-1a2b-6d62-1fde456b12d2@oracle.com> Date: Tue, 17 Jul 2018 14:17:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi again, here I noticed a pair of consecutive permerrors (instead of permerror + inform) and also that the first one isn't exploiting DECL_SOURCE_LOCATION (which makes a real difference at least in a couple of cases which I'm explicitly testing below). Tested x86_64-linux. Thanks, Paolo. ///////////////// /cp 2018-07-17 Paolo Carlini * class.c (note_name_declared_in_class): Prefer permerror + inform to a pair of permerrors; use DECL_SOURCE_LOCATION. /testsuite 2018-07-17 Paolo Carlini * g++.dg/ext/uow-3.C: Adjust. * g++.dg/ext/uow-4.C: Likewise. * g++.dg/lookup/name-clash11.C: Likewise. * g++.dg/lookup/name-clash7.C: Likewise. * g++.dg/lookup/redecl1.C: Likewise. * g++.dg/warn/changes-meaning.C: Likewise. * g++.old-deja/g++.jason/scoping8.C: Likewise. * g++.old-deja/g++.law/nest1.C: Likewise. Index: cp/class.c =================================================================== --- cp/class.c (revision 262803) +++ cp/class.c (working copy) @@ -8285,10 +8285,12 @@ note_name_declared_in_class (tree name, tree decl) A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. */ - permerror (input_location, "declaration of %q#D", decl); - permerror (location_of ((tree) n->value), - "changes meaning of %qD from %q#D", - OVL_NAME (decl), (tree) n->value); + if (permerror (DECL_SOURCE_LOCATION (decl), + "declaration of %q#D changes meaning of %qD", + decl, OVL_NAME (decl))) + inform (location_of ((tree) n->value), + "%qD declared here as %q#D", + OVL_NAME (decl), (tree) n->value); } } Index: testsuite/g++.dg/ext/uow-3.C =================================================================== --- testsuite/g++.dg/ext/uow-3.C (revision 262803) +++ testsuite/g++.dg/ext/uow-3.C (working copy) @@ -1,8 +1,8 @@ /* { dg-do compile } */ /* { dg-options "-Wall" } */ -typedef int UOW; /* { dg-error "" } */ +typedef int UOW; /* { dg-message "declared here" } */ struct ABC { - UOW UOW; /* { dg-error "" } */ + UOW UOW; /* { dg-error "changes meaning" } */ }; Index: testsuite/g++.dg/ext/uow-4.C =================================================================== --- testsuite/g++.dg/ext/uow-4.C (revision 262803) +++ testsuite/g++.dg/ext/uow-4.C (working copy) @@ -3,9 +3,9 @@ extern "C" { -typedef int UOW; /* { dg-error "" } */ +typedef int UOW; /* { dg-message "declared here" } */ struct ABC { - UOW UOW; /* { dg-error "" } */ + UOW UOW; /* { dg-error "changes meaning" } */ }; } Index: testsuite/g++.dg/lookup/name-clash11.C =================================================================== --- testsuite/g++.dg/lookup/name-clash11.C (revision 262803) +++ testsuite/g++.dg/lookup/name-clash11.C (working copy) @@ -13,11 +13,11 @@ void test_bitset () { - int x; // { dg-warning "changes meaning" } + int x; // { dg-message "declared here" } { struct S { - int x: sizeof x; // { dg-warning "declaration" } + int x: sizeof x; // { dg-warning "changes meaning" } }; } } @@ -25,11 +25,11 @@ void test_bitset () void test_enum () { // Also exercise (not covered by c++/69023): - int y; // { dg-warning "changes meaning" } + int y; // { dg-message "declared here" } { struct S { enum E { - y = sizeof y // { dg-warning "declaration" } + y = sizeof y // { dg-warning "9:declaration of .y. changes meaning" } }; // Verify the enumerator has the correct value. @@ -40,7 +40,7 @@ void test_enum () void test_alignas () { - enum { A = 16 }; // { dg-warning "changes meaning" } + enum { A = 16 }; // { dg-message "declared here" } { struct S { #if __cplusplus >= 201103L @@ -48,7 +48,7 @@ void test_alignas () #else __attribute__ ((aligned (A))) #endif - int A; // { dg-warning "declaration" } + int A; // { dg-warning "changes meaning" } // Verify the member has the correct alignment. void test () { ASSERT (__alignof__ (this->A) == 16); } @@ -58,10 +58,10 @@ void test_alignas () void test_array () { - enum { A = 16 }; // { dg-warning "changes meaning" } + enum { A = 16 }; // { dg-message "declared here" } { struct S { - int A [A]; // { dg-warning "declaration" } + int A [A]; // { dg-warning "changes meaning" } // Verify the member has the correct alignment. void test () { ASSERT (sizeof (this->A) == 16 * sizeof (int)); } @@ -71,10 +71,10 @@ void test_array () void test_vector () { - enum { A = 16 }; // { dg-warning "changes meaning" } + enum { A = 16 }; // { dg-message "declared here" } { struct S { - int A __attribute__ ((vector_size (A))); // { dg-warning "declaration" } + int A __attribute__ ((vector_size (A))); // { dg-warning "changes meaning" } // Verify the member has the correct size. void test () { ASSERT (sizeof (this->A) == 16); } Index: testsuite/g++.dg/lookup/name-clash7.C =================================================================== --- testsuite/g++.dg/lookup/name-clash7.C (revision 262803) +++ testsuite/g++.dg/lookup/name-clash7.C (working copy) @@ -1,6 +1,6 @@ // PR c++/28513 -class foo { // { dg-error "changes meaning" } +class foo { // { dg-message "declared here" } public: typedef int bar; }; @@ -7,5 +7,5 @@ class baz { public: - foo::bar foo; // { dg-error "declaration" } + foo::bar foo; // { dg-error "changes meaning" } }; Index: testsuite/g++.dg/lookup/redecl1.C =================================================================== --- testsuite/g++.dg/lookup/redecl1.C (revision 262803) +++ testsuite/g++.dg/lookup/redecl1.C (working copy) @@ -1,7 +1,7 @@ // PR c++/14668 -class A {}; // { dg-error "" } +class A {}; // { dg-message "declared here" } class B { - static A *A; // { dg-error "" } + static A *A; // { dg-error "changes meaning" } }; A *B::A = 0; Index: testsuite/g++.dg/warn/changes-meaning.C =================================================================== --- testsuite/g++.dg/warn/changes-meaning.C (revision 262803) +++ testsuite/g++.dg/warn/changes-meaning.C (working copy) @@ -1,11 +1,11 @@ /* { dg-do compile } */ /* { dg-options "-fpermissive" } */ -template class auto_ptr {}; /* { dg-warning "changes meaning" } */ +template class auto_ptr {}; /* { dg-message "declared here" } */ template class counted_ptr { public: - auto_ptr<_Tp> auto_ptr(); /* { dg-warning "" } */ + auto_ptr<_Tp> auto_ptr(); /* { dg-warning "17:declaration of .auto_ptr\\<_Tp\\>" } */ }; Index: testsuite/g++.old-deja/g++.jason/scoping8.C =================================================================== --- testsuite/g++.old-deja/g++.jason/scoping8.C (revision 262803) +++ testsuite/g++.old-deja/g++.jason/scoping8.C (working copy) @@ -1,8 +1,8 @@ // { dg-do assemble } // Bug: g++ allows two different meanings of a name in the same scope. -typedef int foo; // { dg-error "" } +typedef int foo; // { dg-message "declared here" } struct A { A (foo); - int foo (); // { dg-error "" } foo already used in scope + int foo (); // { dg-error "changes meaning" } }; Index: testsuite/g++.old-deja/g++.law/nest1.C =================================================================== --- testsuite/g++.old-deja/g++.law/nest1.C (revision 262803) +++ testsuite/g++.old-deja/g++.law/nest1.C (working copy) @@ -6,10 +6,10 @@ // Subject: Local type names bug in g++ 2.3.3 // Message-ID: <1992Dec30.203807.17504@murdoch.acc.Virginia.EDU> -typedef char* T; // { dg-error "" } previous declaration +typedef char* T; // { dg-message "declared here" } struct Y { T a; - typedef long T; // error. See ARM p189-191 for details// { dg-error "" } + typedef long T; // { dg-error "changes meaning" } T b; };