summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-08-24 22:52:39 +0000
committerJohn McCall <rjmccall@apple.com>2010-08-24 22:52:39 +0000
commit24d189484b4438e8fb6f772cebc91e3f07eac820 (patch)
treee83c1291922cb1762b8445b7d3a12b132bae4bab /clang/lib/Sema/SemaExpr.cpp
parent401b39a736e7c139710f5fc7edcd672026139d6b (diff)
downloadbcm5719-llvm-24d189484b4438e8fb6f772cebc91e3f07eac820.tar.gz
bcm5719-llvm-24d189484b4438e8fb6f772cebc91e3f07eac820.zip
When trying to resolve the address of an overloaded expression,
only form pointers-to-member if the expression has the appropriate form. This avoids assertions later on on invalid code, but also allows us to properly resolve mixed-staticity overloads. llvm-svn: 111987
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 6acef58f2c2..30d294cd752 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1063,10 +1063,10 @@ static ObjCIvarDecl *SynthesizeProvisionalIvar(Sema &SemaRef,
}
ExprResult Sema::ActOnIdExpression(Scope *S,
- CXXScopeSpec &SS,
- UnqualifiedId &Id,
- bool HasTrailingLParen,
- bool isAddressOfOperand) {
+ CXXScopeSpec &SS,
+ UnqualifiedId &Id,
+ bool HasTrailingLParen,
+ bool isAddressOfOperand) {
assert(!(isAddressOfOperand && HasTrailingLParen) &&
"cannot be direct & operand and have a trailing lparen");
@@ -1223,12 +1223,16 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
}
// Check whether this might be a C++ implicit instance member access.
- // C++ [expr.prim.general]p6:
- // Within the definition of a non-static member function, an
- // identifier that names a non-static member is transformed to a
- // class member access expression.
- // But note that &SomeClass::foo is grammatically distinct, even
- // though we don't parse it that way.
+ // C++ [class.mfct.non-static]p3:
+ // When an id-expression that is not part of a class member access
+ // syntax and not used to form a pointer to member is used in the
+ // body of a non-static member function of class X, if name lookup
+ // resolves the name in the id-expression to a non-static non-type
+ // member of some class C, the id-expression is transformed into a
+ // class member access expression using (*this) as the
+ // postfix-expression to the left of the . operator.
+ // So if we found a class member with an expression of form other
+ // than &A::foo, we have to try to build an implicit member expr.
if (!R.empty() && (*R.begin())->isCXXClassMember()) {
bool isAbstractMemberPointer = (isAddressOfOperand && !SS.isEmpty());
if (!isAbstractMemberPointer)
OpenPOWER on IntegriCloud