* [C++ PATCH] Fix up joust diagnostics (PR c++/89622)
@ 2019-03-07 19:29 Jakub Jelinek
2019-03-08 4:43 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2019-03-07 19:29 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
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 <jakub@redhat.com>
PR c++/89622
* call.c (joust): Call print_z_candidate only if pedwarn returned
true.
* g++.dg/warn/pr89622.C: New test.
--- 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<typename T>
+struct X
+{
+ X() { }
+ template<typename U> X(int, U&&) { }
+ template<typename U> X(char, const X<U>&) { }
+};
+
+template<typename T>
+X<T> wrap_X(X<T> x)
+{
+ return X<T>('a', x);
+}
+
+int main()
+{
+ X<void> x;
+ wrap_X(x);
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ PATCH] Fix up joust diagnostics (PR c++/89622)
2019-03-07 19:29 [C++ PATCH] Fix up joust diagnostics (PR c++/89622) Jakub Jelinek
@ 2019-03-08 4:43 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2019-03-08 4:43 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 3/7/19 2:25 PM, Jakub Jelinek wrote:
> 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 <jakub@redhat.com>
>
> PR c++/89622
> * call.c (joust): Call print_z_candidate only if pedwarn returned
> true.
OK.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-08 4:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 19:29 [C++ PATCH] Fix up joust diagnostics (PR c++/89622) Jakub Jelinek
2019-03-08 4:43 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).