def err_ovl_no_viable_function_in_init : Error<
"no matching constructor for initialization of %0">;
def err_ovl_ambiguous_init : Error<"call to constructor of %0 is ambiguous">;
+def err_ref_init_ambiguous : Error<
+ "reference initialization of type %0 with initializer of type %1 is ambiguous">;
def err_ovl_deleted_init : Error<
"call to %select{unavailable|deleted}0 constructor of %1">;
def err_ovl_ambiguous_oper : Error<
break;
case OR_Ambiguous:
- assert(false && "Ambiguous reference binding conversions not implemented.");
+ if (ICS) {
+ for (OverloadCandidateSet::iterator Cand = CandidateSet.begin();
+ Cand != CandidateSet.end(); ++Cand)
+ if (Cand->Viable)
+ ICS->ConversionFunctionSet.push_back(Cand->Function);
+ break;
+ }
+ Diag(DeclLoc, diag::err_ref_init_ambiguous) << DeclType << Init->getType()
+ << Init->getSourceRange();
+ PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
return true;
case OR_No_Viable_Function:
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
+
+enum E2 { };
+
+struct A {
+ operator E2&(); // expected-note 3 {{candidate function}}
+};
+
+struct B {
+ operator E2&(); // expected-note 3 {{candidate function}}
+};
+
+struct C : B, A {
+};
+
+void test(C c) {
+ const E2 &e2 = c; // expected-error {{reference initialization of type 'enum E2 const &' with initializer of type 'struct C' is ambiguous}}
+}
+
+void foo(const E2 &);
+
+const E2 & re(C c) {
+ foo(c); // expected-error {{reference initialization of type 'enum E2 const &' with initializer of type 'struct C' is ambiguous}}
+
+ return c; // expected-error {{reference initialization of type 'enum E2 const &' with initializer of type 'struct C' is ambiguous}}
+}
+
+