From patchwork Thu Mar 7 19:25:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1053226 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-497515-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PF99FLkz"; 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 44FgZY6CX1z9s4Y for ; Fri, 8 Mar 2019 06:25:24 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=hgrZnB8de5lNctvniUU6NtVb5oWSw H4hQycPrl0/yw1cQLIlBQxzNWARJIuURfesyFz1mIQh2CVwx5IViRkOaQFlWl8aM txVtKXGFpVGcBocVJaZY5ts9BEgYTjT6nn+WxReMJc18jD9iZHb6i/ItZOaV6v9K v+4dwDC5ENKAaI= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=iL2nbZ28BJ1bdcCmiaLSPDx1z8E=; b=PF9 9FLkzFVIdcfrH4jtVGA5LrHJMsTa0ni6NIXAciOSTwhqUsuA7UACneH4NR4J3HRj a5xActZj0jOmfXfrCLMJ3ptOcG3PsSVI84wK63ZL08bgIAse/IGSTJp4xNb6z7Jo bNs0NBSpzM1YaxcHuO5lY6A5rBQirSio+f05L9Ts= Received: (qmail 78744 invoked by alias); 7 Mar 2019 19:25:17 -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 78730 invoked by uid 89); 7 Mar 2019 19:25:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=UD:call.c, call.c, callc X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Mar 2019 19:25:15 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B27830718DE for ; Thu, 7 Mar 2019 19:25:14 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-64.ams2.redhat.com [10.36.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 244215D719; Thu, 7 Mar 2019 19:25:13 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x27JPB7p029548; Thu, 7 Mar 2019 20:25:12 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x27JP95B029547; Thu, 7 Mar 2019 20:25:09 +0100 Date: Thu, 7 Mar 2019 20:25:09 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix up joust diagnostics (PR c++/89622) Message-ID: <20190307192509.GA7611@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi! If no diagnostics is emitted by this pedwarn, whether because of -Wno-system-headers and location from system headers, or because of -w etc., we still emit the follow-up messages as if the pedwarn emitted something. The following patch makes it conditional on pedwarn returning true (i.e. that something has been actually printed). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-03-07 Jakub Jelinek PR c++/89622 * call.c (joust): Call print_z_candidate only if pedwarn returned true. * g++.dg/warn/pr89622.C: New test. Jakub --- gcc/cp/call.c.jj 2019-03-06 19:45:40.369751609 +0100 +++ gcc/cp/call.c 2019-03-07 14:51:20.062959019 +0100 @@ -10954,12 +10954,14 @@ tweak: if (warn) { auto_diagnostic_group d; - pedwarn (input_location, 0, - "ISO C++ says that these are ambiguous, even " - "though the worst conversion for the first is better than " - "the worst conversion for the second:"); - print_z_candidate (input_location, _("candidate 1:"), w); - print_z_candidate (input_location, _("candidate 2:"), l); + if (pedwarn (input_location, 0, + "ISO C++ says that these are ambiguous, even " + "though the worst conversion for the first is " + "better than the worst conversion for the second:")) + { + print_z_candidate (input_location, _("candidate 1:"), w); + print_z_candidate (input_location, _("candidate 2:"), l); + } } else add_warning (w, l); --- gcc/testsuite/g++.dg/warn/pr89622.C.jj 2019-03-07 14:51:57.691344552 +0100 +++ gcc/testsuite/g++.dg/warn/pr89622.C 2019-03-07 14:48:24.167831364 +0100 @@ -0,0 +1,27 @@ +// PR c++/89622 +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-system-headers -w" } +// { dg-bogus "says that these are ambiguous" "" { target *-*-* } 0 } +// { dg-bogus "candidate 1" "" { target *-*-* } 0 } +// { dg-bogus "candidate 2" "" { target *-*-* } 0 } + +# 3 "pr89622.h" 3 +template +struct X +{ + X() { } + template X(int, U&&) { } + template X(char, const X&) { } +}; + +template +X wrap_X(X x) +{ + return X('a', x); +} + +int main() +{ + X x; + wrap_X(x); +}