diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-12 16:11:24 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-12 16:11:24 +0000 |
commit | 1d7049a6eddcc1a4bd33c6a595d4ad2ae8c1cece (patch) | |
tree | 9ce770958fea31cd9dc8f2893d421d9e922ab68c /lib/Sema/SemaExprCXX.cpp | |
parent | 28058d179ae40edc66135458849f1073c841bc74 (diff) |
In Objective-C++, actually compute the base type of a member access
expression for an Objective-C object or pointer type, so that we don't
attempt to treat the member name as a template. Fixes
<rdar://problem/10672501>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index da7ba1a2b3..ee25591529 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -4294,21 +4294,26 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, } } - if (BaseType->isPointerType()) + if (BaseType->isPointerType() || BaseType->isObjCObjectPointerType()) BaseType = BaseType->getPointeeType(); } - // We could end up with various non-record types here, such as extended - // vector types or Objective-C interfaces. Just return early and let - // ActOnMemberReferenceExpr do the work. - if (!BaseType->isRecordType()) { - // C++ [basic.lookup.classref]p2: - // [...] If the type of the object expression is of pointer to scalar - // type, the unqualified-id is looked up in the context of the complete - // postfix-expression. - // - // This also indicates that we should be parsing a - // pseudo-destructor-name. + // Objective-C properties allow "." access on Objective-C pointer types, + // so adjust the base type to the object type itself. + if (BaseType->isObjCObjectPointerType()) + BaseType = BaseType->getPointeeType(); + + // C++ [basic.lookup.classref]p2: + // [...] If the type of the object expression is of pointer to scalar + // type, the unqualified-id is looked up in the context of the complete + // postfix-expression. + // + // This also indicates that we could be parsing a pseudo-destructor-name. + // Note that Objective-C class and object types can be pseudo-destructor + // expressions or normal member (ivar or property) access expressions. + if (BaseType->isObjCObjectOrInterfaceType()) { + MayBePseudoDestructor = true; + } else if (!BaseType->isRecordType()) { ObjectType = ParsedType(); MayBePseudoDestructor = true; return Owned(Base); |