From: Jakub Jelinek Date: Fri, 8 Mar 2019 07:42:51 +0000 (+0100) Subject: re PR c++/89622 (G++ prints notes, but no warning or error) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=560a46a5914a3cc55ade0cb0fe3d8e36d85d01cd;p=gcc.git re PR c++/89622 (G++ prints notes, but no warning or error) PR c++/89622 * call.c (joust): Call print_z_candidate only if pedwarn returned true. * g++.dg/warn/pr89622.C: New test. From-SVN: r269481 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ae5735d30d2..9bdb4936053 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-03-08 Jakub Jelinek + + PR c++/89622 + * call.c (joust): Call print_z_candidate only if pedwarn returned + true. + 2019-03-07 Jason Merrill PR c++/88123 - lambda and using-directive. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d9294a06c44..c50d9c8b3d1 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 46920d65169..777c1b29937 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-08 Jakub Jelinek + + PR c++/89622 + * g++.dg/warn/pr89622.C: New test. + 2019-03-07 Jakub Jelinek PR target/80003 diff --git a/gcc/testsuite/g++.dg/warn/pr89622.C b/gcc/testsuite/g++.dg/warn/pr89622.C new file mode 100644 index 00000000000..247fe0981fa --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr89622.C @@ -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); +}