From patchwork Sun Jul 8 20:42:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 941056 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-481194-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="sfSKBtG/"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="Fi5GAtnx"; 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 41P0lQ5F9nz9s00 for ; Mon, 9 Jul 2018 06:42:39 +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=lpmulyZrvPM03PcGZgyzIFEKToUTwmnk2A5BFhQbjShBP53rua HBjXXvHSZ4U/NHzMJW9o8+NvKwVOtPd/OozFi6DJc9Xz3yBQtKActZtRXN43xTKw /AOE83+T82oF5NJe7kNjPoGweY1YYZ1wmtk3kFmot/4JIB55WXqi+ez0A= 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=U9XDkz0GvYfr/Fo/BiQodhB9nKk=; b=sfSKBtG/Pl10nEMku4J3 /1jKxoEc+EmXLC5xKXrEit08FHnJsYaFWEVKPCFjC+YrIqwcVefyG+RduDtSJfEu ZaBIa6mBBU2hN6GVamXgWAVCkUtLSGmxWXsKS04n0RoxjAQurAw+seRsh0/oa1QU Mek1iICCD5NIKrJvWHBixzo= Received: (qmail 122281 invoked by alias); 8 Jul 2018 20:42:32 -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 122266 invoked by uid 89); 8 Jul 2018 20:42:31 -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=integer_type, H*r:Gateway, friend 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; Sun, 08 Jul 2018 20:42:29 +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 w68Kdgrw010646; Sun, 8 Jul 2018 20:42:27 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=3+fiNL8baRsW5XBmKAJ39FpyTj4UoLK9e3R81eT/P1w=; b=Fi5GAtnxUIyMFjcJ1uGzPSVkL8jaxAE1r6pJZ9ZAxC9Tw+EGGapS72LWQJejHwAY2MLK i0v/zpf3vec/bZiaWCyhfnnrPIGZdTnSqqnlB1xEqF/whcF+vLV/20z5c47scCR8VWCf PKlnJ8RhVt/7o4GLbIwh2Pssa6Su3bcNJjM+C13VWpqweTpb38d74OHC3Bxvz5iMUrUd cLUYHM96WsM7MRuKbokciDXjzSdeGVrsZWmrlPRSBzB5PuZXsb18hu+B/+HYthvBkpyq x01SkohfOyueW2pEjPla4KzHngZPKUnonbHdbURpO1YziKlpyJ8izdtCh1ZiseueUi35 vg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2k2p75j0r4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 08 Jul 2018 20:42:27 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w68KgQ4v009229 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 8 Jul 2018 20:42:26 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w68KgPbs018168; Sun, 8 Jul 2018 20:42:25 GMT Received: from [192.168.1.4] (/79.53.235.113) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 08 Jul 2018 13:42:24 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , David Malcolm From: Paolo Carlini Subject: [C++ Patch] Use rich_location::add_range in three more places Message-ID: Date: Sun, 8 Jul 2018 22:42:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, noticed three additional error messages where an additional range seems appropriate. Tested x86_64-linux. Thanks, Paolo. ////////////////// /cp 2018-07-08 Paolo Carlini * decl.c (grokdeclarator): Use rich_location::add_range in three more places; include gcc-rich-location.h. /testsuite 2018-07-08 Paolo Carlini * g++.dg/diagnostic/long-short.C: New. * g++.dg/diagnostic/signed-unsigned.C: Likewise. * g++.dg/diagnostic/virtual-friend.C: Likewise. * g++.old-deja/g++.brendan/crash11.C: Adjust. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 262469) +++ cp/decl.c (working copy) @@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see #include "builtins.h" #include "gimplify.h" #include "asan.h" +#include "gcc-rich-location.h" /* Possible cases of bad specifiers type used by bad_specifiers. */ enum bad_spec_place { @@ -10580,9 +10581,18 @@ grokdeclarator (const cp_declarator *declarator, int ok = 0; if (signed_p && unsigned_p) - error_at (loc, "% and % specified together"); + { + gcc_rich_location richloc (declspecs->locations[ds_signed]); + richloc.add_range (declspecs->locations[ds_unsigned], false); + error_at (&richloc, + "% and % specified together"); + } else if (long_p && short_p) - error_at (loc, "% and % specified together"); + { + gcc_rich_location richloc (declspecs->locations[ds_long]); + richloc.add_range (declspecs->locations[ds_short], false); + error_at (&richloc, "% and % specified together"); + } else if (TREE_CODE (type) != INTEGER_TYPE || type == char16_type_node || type == char32_type_node || ((long_p || short_p) @@ -10723,7 +10733,7 @@ grokdeclarator (const cp_declarator *declarator, { if (staticp == 2) { - rich_location richloc (line_table, declspecs->locations[ds_virtual]); + gcc_rich_location richloc (declspecs->locations[ds_virtual]); richloc.add_range (declspecs->locations[ds_storage_class], false); error_at (&richloc, "member %qD cannot be declared both % " "and %", dname); @@ -10732,7 +10742,7 @@ grokdeclarator (const cp_declarator *declarator, } if (constexpr_p) { - rich_location richloc (line_table, declspecs->locations[ds_virtual]); + gcc_rich_location richloc (declspecs->locations[ds_virtual]); richloc.add_range (declspecs->locations[ds_constexpr], false); error_at (&richloc, "member %qD cannot be declared both % " "and %", dname); @@ -11270,8 +11280,9 @@ grokdeclarator (const cp_declarator *declarator, if (virtualp) { /* Cannot be both friend and virtual. */ - error_at (declspecs->locations[ds_friend], - "virtual functions cannot be friends"); + gcc_rich_location richloc (declspecs->locations[ds_virtual]); + richloc.add_range (declspecs->locations[ds_friend], false); + error_at (&richloc, "virtual functions cannot be friends"); friendp = 0; } if (decl_context == NORMAL) Index: testsuite/g++.dg/diagnostic/long-short.C =================================================================== --- testsuite/g++.dg/diagnostic/long-short.C (nonexistent) +++ testsuite/g++.dg/diagnostic/long-short.C (working copy) @@ -0,0 +1,12 @@ +// { dg-options "-fdiagnostics-show-caret" } + +long short int a; // { dg-error "1:.long. and .short. specified together" } +/* { dg-begin-multiline-output "" } + long short int a; + ^~~~ ~~~~~ + { dg-end-multiline-output "" } */ +short long int b; // { dg-error "7:.long. and .short. specified together" } +/* { dg-begin-multiline-output "" } + short long int b; + ~~~~~ ^~~~ + { dg-end-multiline-output "" } */ Index: testsuite/g++.dg/diagnostic/signed-unsigned.C =================================================================== --- testsuite/g++.dg/diagnostic/signed-unsigned.C (nonexistent) +++ testsuite/g++.dg/diagnostic/signed-unsigned.C (working copy) @@ -0,0 +1,12 @@ +// { dg-options "-fdiagnostics-show-caret" } + +signed unsigned int a; // { dg-error "1:.signed. and .unsigned. specified together" } +/* { dg-begin-multiline-output "" } + signed unsigned int a; + ^~~~~~ ~~~~~~~~ + { dg-end-multiline-output "" } */ +unsigned signed int b; // { dg-error "10:.signed. and .unsigned. specified together" } +/* { dg-begin-multiline-output "" } + unsigned signed int b; + ~~~~~~~~ ^~~~~~ + { dg-end-multiline-output "" } */ Index: testsuite/g++.dg/diagnostic/virtual-friend.C =================================================================== --- testsuite/g++.dg/diagnostic/virtual-friend.C (nonexistent) +++ testsuite/g++.dg/diagnostic/virtual-friend.C (working copy) @@ -0,0 +1,16 @@ +// { dg-options "-fdiagnostics-show-caret" } +// { dg-do compile { target c++11 } } + +struct S +{ + virtual friend void foo(); // { dg-error "3:virtual functions cannot be friends" } +/* { dg-begin-multiline-output "" } + virtual friend void foo(); + ^~~~~~~ ~~~~~~ + { dg-end-multiline-output "" } */ + friend virtual void bar(); // { dg-error "10:virtual functions cannot be friends" } +/* { dg-begin-multiline-output "" } + friend virtual void bar(); + ~~~~~~ ^~~~~~~ + { dg-end-multiline-output "" } */ +}; Index: testsuite/g++.old-deja/g++.brendan/crash11.C =================================================================== --- testsuite/g++.old-deja/g++.brendan/crash11.C (revision 262451) +++ testsuite/g++.old-deja/g++.brendan/crash11.C (working copy) @@ -9,13 +9,13 @@ class A { int h; A() { i=10; j=20; } virtual void f1() { printf("i=%d j=%d\n",i,j); } - friend virtual void f2() { printf("i=%d j=%d\n",i,j); } // { dg-error "2:virtual functions cannot be friends" } + friend virtual void f2() { printf("i=%d j=%d\n",i,j); } // { dg-error "9:virtual functions cannot be friends" } }; class B : public A { public: virtual void f1() { printf("i=%d j=%d\n",i,j); }// { dg-error "" } member.*// ERROR - member.* - friend virtual void f2() { printf("i=%d j=%d\n",i,j); } // { dg-error "2:virtual functions cannot be friends" } + friend virtual void f2() { printf("i=%d j=%d\n",i,j); } // { dg-error "9:virtual functions cannot be friends" } // { dg-error "private" "" { target *-*-* } .-1 } };