re PR c++/81167 (ICE on valid C++ code in deferred_printed_type, at cp/error.c:118)
authorJakub Jelinek <jakub@redhat.com>
Fri, 19 Jan 2018 22:37:37 +0000 (23:37 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 19 Jan 2018 22:37:37 +0000 (23:37 +0100)
PR c++/81167
* call.c (joust): Use TREE_TYPE (source) if source is
a POINTER_TYPE_P rather than if ! DECL_CONSTRUCTOR_P (w->fn).

* g++.dg/cpp0x/pr81167.C: New test.

From-SVN: r256905

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

index eb39b4023910af2df6d081f3cf20b951e6236d14..5bad14dadd0940e52cbeb36cc95745602945c445 100644 (file)
@@ -1,5 +1,9 @@
 2018-01-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/81167
+       * call.c (joust): Use TREE_TYPE (source) if source is
+       a POINTER_TYPE_P rather than if ! DECL_CONSTRUCTOR_P (w->fn).
+
        PR c++/83919
        * typeck.c (convert_for_assignment): Suppress warn_ignored_qualifiers
        for direct enum init.
index e08622ce9c20f358961b1efce319dd54982cd9f7..46d5ef5e7c0bfc06855a297f7bbfc660962b2594 100644 (file)
@@ -10090,7 +10090,7 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn,
       else if (warn)
        {
          tree source = source_type (w->convs[0]);
-         if (! DECL_CONSTRUCTOR_P (w->fn))
+         if (POINTER_TYPE_P (source))
            source = TREE_TYPE (source);
          if (warning (OPT_Wconversion, "choosing %qD over %qD", w->fn, l->fn)
              && warning (OPT_Wconversion, "  for conversion from %qH to %qI",
index d6ea61f593805711d616dafbc957c28d2a2c050d..ceb16e567729af2557336cc0511ae9bf33ac3061 100644 (file)
@@ -1,5 +1,8 @@
 2018-01-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/81167
+       * g++.dg/cpp0x/pr81167.C: New test.
+
        PR c++/83919
        * g++.dg/cpp0x/pr83919.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr81167.C b/gcc/testsuite/g++.dg/cpp0x/pr81167.C
new file mode 100644 (file)
index 0000000..d0c9d23
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/81167
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wconversion" }
+
+struct bar;
+
+struct foo
+{
+  foo () {}
+  foo (const bar &) {}
+};
+
+struct bar
+{
+  operator foo () && { return foo (); }
+};
+
+void test ()
+{
+  foo f = bar ();
+// { dg-warning "choosing 'bar::operator foo\\(\\) &&' over 'foo::foo\\(const bar&\\)'" "" { target *-*-* } .-1 }
+// { dg-warning "for conversion from 'bar' to 'foo'" "" { target *-*-* } .-2 }
+// { dg-message "because conversion sequence for the argument is better" "" { target *-*-* } .-3 }
+}