if (DiagnoseUnexpandedParameterPack(FullExpr))
return ExprError();
+ // 13.4.1 ... An overloaded function name shall not be used without arguments
+ // in contexts other than those listed [i.e list of targets].
+ //
+ // void foo(); void foo(int);
+ // template<class T> void fooT(); template<class T> void fooT(int);
+
+ // Therefore these should error:
+ // foo;
+ // 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);
+ return ExprError();
+ }
+ }
+
+
IgnoredValueConversions(FullExpr);
CheckImplicitConversions(FullExpr);
+
return MaybeCreateExprWithCleanups(FullExpr);
}
} // End namespace
+namespace DontAllowUnresolvedOverloadedExpressionInAnUnusedExpression
+{
+ void one() { }
+ template<class T> void oneT() { }
+
+ void two() { } //expected-note 2{{candidate}}
+ void two(int) { } //expected-note 2{{candidate}}
+ template<class T> void twoT() { } //expected-note 2{{candidate}}
+ template<class T> void twoT(T) { } //expected-note 2{{candidate}}
+
+ void check()
+ {
+ one; // expected-warning {{expression result unused}}
+ two; // expected-error{{address of overloaded function}}
+ oneT<int>; // expected-warning {{expression result unused}}
+ twoT<int>; // expected-error {{address of overloaded function}}
+ }
+
+ // check the template function case
+ template<class T> void check()
+ {
+ one; // expected-warning {{expression result unused}}
+ two; // expected-error{{address of overloaded function}}
+ oneT<int>; // expected-warning {{expression result unused}}
+ twoT<int>; // expected-error {{address of overloaded function}}
+
+ }
+
+}
+
template<typename T>
void twoT() { }
template<typename T, typename U>
int main()
{
+
{ static_cast<void>(one); }
{ (void)(one); }
{ static_cast<void>(oneT<int>); }