re PR c++/89622 (G++ prints notes, but no warning or error)
authorJakub Jelinek <jakub@redhat.com>
Fri, 8 Mar 2019 07:42:51 +0000 (08:42 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 8 Mar 2019 07:42:51 +0000 (08:42 +0100)
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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr89622.C [new file with mode: 0644]

index ae5735d30d2f7f036ada1be968fea3da0c4b7835..9bdb4936053f3ead93e0d95a4bb62a3d45f7cd4c 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/89622
+       * call.c (joust): Call print_z_candidate only if pedwarn returned
+       true.
+
 2019-03-07  Jason Merrill  <jason@redhat.com>
 
        PR c++/88123 - lambda and using-directive.
index d9294a06c4443cbe1be43b508bd71c67e119f699..c50d9c8b3d19914158e8954e8b1270c4d699a9a5 100644 (file)
@@ -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);
index 46920d65169431c05e524d3d4e32f8bb0c4d5dc4..777c1b29937a9a5e0f6fe5c192c778a253c04ad0 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/89622
+       * g++.dg/warn/pr89622.C: New test.
+
 2019-03-07  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..247fe09
--- /dev/null
@@ -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);
+}