aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCXXCast.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-14 23:11:21 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-14 23:11:21 +0000
commit1a8cf73a825ef35917eede448817237b5fd47b05 (patch)
treed4bc9b1bdc3a7bab3e0f95fd2570dd72a8283aa4 /lib/Sema/SemaCXXCast.cpp
parent4cd8494d9a2f99cbf38147bca80be18cdff83734 (diff)
Always diagnose and complain about problems in
ResolveAddressOfOverloadedFunction when asked to complain. Previously, we had some weird handshake where ResolveAddressOfOverloadedFunction expected its caller to handle some of the diagnostics but not others, and yet there was no way for the caller to know which case we were in. Eliminate this madness, fixing <rdar://problem/7765884>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101312 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXCast.cpp')
-rw-r--r--lib/Sema/SemaCXXCast.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index 11c8e6ddab..37df2a6000 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/lib/Sema/SemaCXXCast.cpp
@@ -809,15 +809,17 @@ TryStaticMemberPointerUpcast(Sema &Self, Expr *&SrcExpr, QualType SrcType,
bool WasOverloadedFunction = false;
DeclAccessPair FoundOverload;
- if (FunctionDecl *Fn
- = Self.ResolveAddressOfOverloadedFunction(SrcExpr, DestType, false,
- FoundOverload)) {
- CXXMethodDecl *M = cast<CXXMethodDecl>(Fn);
- SrcType = Self.Context.getMemberPointerType(Fn->getType(),
- Self.Context.getTypeDeclType(M->getParent()).getTypePtr());
- WasOverloadedFunction = true;
+ if (SrcExpr->getType() == Self.Context.OverloadTy) {
+ if (FunctionDecl *Fn
+ = Self.ResolveAddressOfOverloadedFunction(SrcExpr, DestType, false,
+ FoundOverload)) {
+ CXXMethodDecl *M = cast<CXXMethodDecl>(Fn);
+ SrcType = Self.Context.getMemberPointerType(Fn->getType(),
+ Self.Context.getTypeDeclType(M->getParent()).getTypePtr());
+ WasOverloadedFunction = true;
+ }
}
-
+
const MemberPointerType *SrcMemPtr = SrcType->getAs<MemberPointerType>();
if (!SrcMemPtr) {
msg = diag::err_bad_static_cast_member_pointer_nonmp;