summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-10 20:28:16 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-10 20:28:16 +0000
commit5335e796aebf8ae6b08f8a8c664759c706e10653 (patch)
tree832c72a05021ceac05d31c3b5ab119b91f39e5dc
parentef7557ec6752b817aad8ceeaf9242aa0f5dbb720 (diff)
downloadgcc-5335e796aebf8ae6b08f8a8c664759c706e10653.tar.gz
PR c++/51079, DR 495
* call.c (joust): Check the second conversion sequence before checking templates. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181270 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c31
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/template/conv12.C25
4 files changed, 50 insertions, 15 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 33bfa33403d..4492b3b6233 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2011-11-10 Jason Merrill <jason@redhat.com>
+
+ PR c++/51079, DR 495
+ * call.c (joust): Check the second conversion sequence
+ before checking templates.
+
2011-11-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50837
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 578905e41e6..e81950ce537 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8109,6 +8109,22 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn)
if (winner)
return winner;
+ /* DR 495 moved this tiebreaker above the template ones. */
+ /* or, if not that,
+ the context is an initialization by user-defined conversion (see
+ _dcl.init_ and _over.match.user_) and the standard conversion
+ sequence from the return type of F1 to the destination type (i.e.,
+ the type of the entity being initialized) is a better conversion
+ sequence than the standard conversion sequence from the return type
+ of F2 to the destination type. */
+
+ if (cand1->second_conv)
+ {
+ winner = compare_ics (cand1->second_conv, cand2->second_conv);
+ if (winner)
+ return winner;
+ }
+
/* or, if not that,
F1 is a non-template function and F2 is a template function
specialization. */
@@ -8137,21 +8153,6 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn)
return winner;
}
- /* or, if not that,
- the context is an initialization by user-defined conversion (see
- _dcl.init_ and _over.match.user_) and the standard conversion
- sequence from the return type of F1 to the destination type (i.e.,
- the type of the entity being initialized) is a better conversion
- sequence than the standard conversion sequence from the return type
- of F2 to the destination type. */
-
- if (cand1->second_conv)
- {
- winner = compare_ics (cand1->second_conv, cand2->second_conv);
- if (winner)
- return winner;
- }
-
/* Check whether we can discard a builtin candidate, either because we
have two identical ones or matching builtin and non-builtin candidates.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f3315cb84ba..e57b535ad05 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2011-11-10 Jason Merrill <jason@redhat.com>
+ PR c++/51079
+ * g++.dg/template/conv12.C: New.
+
PR debug/50983
* gcc.dg/debug/dwarf2/asm-line1.c: New.
diff --git a/gcc/testsuite/g++.dg/template/conv12.C b/gcc/testsuite/g++.dg/template/conv12.C
new file mode 100644
index 00000000000..e6af05481d7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/conv12.C
@@ -0,0 +1,25 @@
+// PR c++/51079
+
+#if __cplusplus > 199711L
+struct C1
+{
+ template <class T>
+ operator T() = delete; // { dg-message "declared here" "" { target c++11 } }
+ operator bool() { return false; }
+} c1;
+
+int ic1 = c1; // { dg-error "deleted" "" { target c++11 } }
+int ac1 = c1 + c1; // { dg-error "deleted" "" { target c++11 } }
+#endif
+
+struct C2
+{
+private:
+ template <class T>
+ operator T(); // { dg-error "private" }
+public:
+ operator bool() { return false; }
+} c2;
+
+int ic2 = c2; // { dg-error "" }
+int ac2 = c2 + c2; // { dg-error "" }