def err_ovl_no_oper :
Error<"type %0 does not provide a %select{subscript|call}1 operator">;
def err_ovl_unresolvable :
- Error<"cannot resolve overloaded function from context">;
+ Error<"cannot resolve overloaded function %0 from context">;
def err_ovl_no_viable_object_call : Error<
// If this is overload, check for a single overload.
assert(BT->getKind() == BuiltinType::Overload);
-
- if (FunctionDecl *Specialization
- = ResolveSingleFunctionTemplateSpecialization(E)) {
- // The access doesn't really matter in this case.
- DeclAccessPair Found = DeclAccessPair::make(Specialization,
- Specialization->getAccess());
- E = FixOverloadedFunctionReference(E, Found, Specialization);
- if (!E) return ExprError();
- return Owned(E);
- }
-
- Diag(Loc, diag::err_ovl_unresolvable) << E->getSourceRange();
- return ExprError();
+ return ResolveAndFixSingleFunctionTemplateSpecialization(E, false, true,
+ E->getSourceRange(),
+ QualType(),
+ diag::err_ovl_unresolvable);
}
// fooT<int>;
if (FullExpr->getType() == Context.OverloadTy) {
- if (!ResolveSingleFunctionTemplateSpecialization(FullExpr,
- /* Complain */ false)) {
- OverloadExpr* OvlExpr = OverloadExpr::find(FullExpr).Expression;
- Diag(FullExpr->getLocStart(), diag::err_addr_ovl_ambiguous)
- << OvlExpr->getName();
- NoteAllOverloadCandidates(OvlExpr);
+ ExprResult Fixed
+ = ResolveAndFixSingleFunctionTemplateSpecialization(FullExpr,
+ /*DoFunctionPointerConversion=*/false,
+ /*Complain=*/true,
+ FullExpr->getSourceRange(),
+ QualType(),
+ diag::err_addr_ovl_ambiguous);
+ if (Fixed.isInvalid())
return ExprError();
- }
+
+ FullExpr = Fixed.get();
}
DefaultFunctionArrayLvalueConversion(SingleFunctionExpression);
}
}
- if (!SingleFunctionExpression && Complain) {
- OverloadExpr* oe = OverloadExpr::find(SrcExpr).Expression;
- Diag(OpRangeForComplaining.getBegin(), DiagIDForComplaining)
- << oe->getName() << DestTypeForComplaining << OpRangeForComplaining
- << oe->getQualifierLoc().getSourceRange();
- NoteAllOverloadCandidates(SrcExpr);
+ if (!SingleFunctionExpression) {
+ if (Complain) {
+ OverloadExpr* oe = OverloadExpr::find(SrcExpr).Expression;
+ Diag(OpRangeForComplaining.getBegin(), DiagIDForComplaining)
+ << oe->getName() << DestTypeForComplaining << OpRangeForComplaining
+ << oe->getQualifierLoc().getSourceRange();
+ NoteAllOverloadCandidates(SrcExpr);
+ }
+ return ExprError();
}
+
return SingleFunctionExpression;
}
namespace PR8181
{
- void f() { }
- void f(char) { }
- bool b = !&f; //expected-error {{cannot resolve overloaded function from context}}
+ void f() { } // expected-note{{candidate function}}
+ void f(char) { } // expected-note{{candidate function}}
+ bool b = !&f; //expected-error {{cannot resolve overloaded function 'f' from context}}
}
int typeof0[is_same<__typeof__(f<int>), void (int)>::value? 1 : -1];
int typeof1[is_same<__typeof__(&f<int>), void (*)(int)>::value? 1 : -1];
-template <typename T> void g(T);
-template <typename T> void g(T, T);
+template <typename T> void g(T); // expected-note{{candidate function}}
+template <typename T> void g(T, T); // expected-note{{candidate function}}
int typeof2[is_same<__typeof__(g<float>), void (int)>::value? 1 : -1]; // \
- // expected-error{{cannot resolve overloaded function from context}}
+ // expected-error{{cannot resolve overloaded function 'g' from context}}
static_assert(sizeof(r) == 1, "bad size");
}
-void f();
-void f(int);
+void f(); // expected-note{{candidate function}}
+void f(int); // expected-note{{candidate function}}
void g() {
- sizeof(&f); // expected-error{{cannot resolve overloaded function from context}}
+ sizeof(&f); // expected-error{{cannot resolve overloaded function 'f' from context}}
}
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
-void f();
-void f(int);
-decltype(f) a; // expected-error{{cannot resolve overloaded function from context}}
+void f(); // expected-note{{candidate function}}
+void f(int); // expected-note{{candidate function}}
+decltype(f) a; // expected-error{{cannot resolve overloaded function 'f' from context}}
template<typename T> struct S {
- decltype(T::f) * f; // expected-error{{cannot resolve overloaded function from context}}
+ decltype(T::f) * f; // expected-error{{cannot resolve overloaded function 'f' from context}}
};
-struct K { void f(); void f(int); };
+struct K {
+ void f(); // expected-note{{candidate function}}
+ void f(int); // expected-note{{candidate function}}
+};
S<K> b; // expected-note{{in instantiation of template class 'S<K>' requested here}}
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int ovl(int);
-float ovl(float);
+int ovl(int); // expected-note 3{{candidate function}}
+float ovl(float); // expected-note 3{{candidate function}}
-template<typename T> T ovl(T);
+template<typename T> T ovl(T); // expected-note 3{{candidate function}}
void test(bool b) {
- (void)((void)0, ovl); // expected-error{{cannot resolve overloaded function from context}}
+ (void)((void)0, ovl); // expected-error{{cannot resolve overloaded function 'ovl' from context}}
// PR7863
- (void)(b? ovl : &ovl); // expected-error{{cannot resolve overloaded function from context}}
- (void)(b? ovl<float> : &ovl); // expected-error{{cannot resolve overloaded function from context}}
+ (void)(b? ovl : &ovl); // expected-error{{cannot resolve overloaded function 'ovl' from context}}
+ (void)(b? ovl<float> : &ovl); // expected-error{{cannot resolve overloaded function 'ovl' from context}}
(void)(b? ovl<float> : ovl<float>);
}
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
-//#include <typeinfo>
+
+namespace std {
+ class type_info {};
+}
+
void one() { }
-void two() { } // expected-note 3{{candidate}}
-void two(int) { } // expected-note 3{{candidate}}
+void two() { } // expected-note 2{{candidate}}
+void two(int) { } // expected-note 2{{candidate}}
-template<class T> void twoT() { } // expected-note 4{{candidate}}
-template<class T> void twoT(int) { } // expected-note 4{{candidate}}
+template<class T> void twoT() { } // expected-note 3{{candidate}}
+template<class T> void twoT(int) { } // expected-note 3{{candidate}}
template<class T> void oneT() { }
template<class T, class U> void oneT(U) { }
two; // expected-error {{address of overloaded}}
oneT<int>; // expected-warning {{expression result unused}}
twoT<int>; // expected-error {{address of overloaded}}
- typeid(oneT<int>); //expected-error {{you need to include <typeinfo>}}
+ typeid(oneT<int>); // expected-warning{{expression result unused}}
sizeof(oneT<int>); // expected-warning {{expression result unused}}
- sizeof(twoT<int>); //expected-error {{cannot resolve overloaded function from context}}
+ sizeof(twoT<int>); //expected-error {{cannot resolve overloaded function 'twoT' from context}}
decltype(oneT<int>)* fun = 0;
*one; // expected-warning {{expression result unused}}
*oneT<int>; // expected-warning {{expression result unused}}
- *two; //expected-error {{cannot resolve overloaded function from context}}
- *twoT<int>; //expected-error {{cannot resolve overloaded function from context}}
+ *two; //expected-error {{cannot resolve overloaded function 'two' from context}}
+ *twoT<int>; //expected-error {{cannot resolve overloaded function 'twoT' from context}}
!oneT<int>; // expected-warning {{expression result unused}}
+oneT<int>; // expected-warning {{expression result unused}}
-oneT<int>; //expected-error {{invalid argument type}}
(twoT<int>) == oneT<int>; //expected-error {{invalid operands to binary expression}}
bool b = oneT<int>;
void (*p)() = oneT<int>;
- test<oneT<int>> ti;
+ test<oneT<int> > ti;
void (*u)(int) = oneT<int>;
b = (void (*)()) twoT<int>;
oneT<int> == 0; // expected-warning {{expression result unused}}
}
+
+struct rdar9108698 {
+ template<typename> void f();
+};
+
+void test_rdar9108698(rdar9108698 x) {
+ x.f<int>; // expected-error{{a bound member function may only be called}}
+}