functions, e.g., (&f)(0). Fixes <rdar://problem/
9803316>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141877
91177308-0d34-0410-b5e6-
96231b3b80d8
}
}
- // Ignore overloads where the address is taken, because apparently
- // overload resolution doesn't apply in these cases. In theory,
- // this can make us miss a few cases, but whatever.
- if (FR.IsAddressOfOperand)
+ // Ignore overloads that are the pointer-to-member.
+ if (FR.IsAddressOfOperand && FR.HasFormOfMemberPointer)
return false;
return true;
if (Fn->getType() == Context.OverloadTy) {
OverloadExpr::FindResult find = OverloadExpr::find(Fn);
- // We aren't supposed to apply this logic if there's an '&' involved.
- if (!find.IsAddressOfOperand) {
+ // We aren't supposed to apply this logic for if there's an '&' involved.
+ if (!(find.IsAddressOfOperand && find.HasFormOfMemberPointer)) {
OverloadExpr *ovl = find.Expression;
if (isa<UnresolvedLookupExpr>(ovl)) {
UnresolvedLookupExpr *ULE = cast<UnresolvedLookupExpr>(ovl);
namespace PR8181
{
- void f() { } // expected-note{{possible target for call}}
+ bool f() { } // expected-note{{possible target for call}}
void f(char) { } // expected-note{{possible target for call}}
- bool b = !&f; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
-
+ bool b = !&f; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
}
void f(); // expected-note{{possible target for call}}
void f(int); // expected-note{{possible target for call}}
void g() {
- sizeof(&f); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+ sizeof(&f); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} \
+ // expected-warning{{expression result unused}}
}
template<typename T> void f_template(); // expected-note{{possible target for call}}
f(n); // expected-error{{call to 'f' is ambiguous}}
}
}
+
+namespace rdar9803316 {
+ void foo(float);
+ int &foo(int);
+
+ void bar() {
+ int &ir = (&foo)(0);
+ }
+}