summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-26 16:40:18 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-26 16:40:18 +0000
commit1d042091d39c3bb796ae2cc3c47b7d5692431e40 (patch)
tree8233eec91ea53fd43133d76d27a184acd35fdedd /clang/lib
parent71711a673be016f8bad262e652507e3bd95983c8 (diff)
downloadbcm5719-llvm-1d042091d39c3bb796ae2cc3c47b7d5692431e40.tar.gz
bcm5719-llvm-1d042091d39c3bb796ae2cc3c47b7d5692431e40.zip
Reference qualifiers for *this: implement C++0x [expr.mptr.oper]p6,
the restrictions on .* and ->* for ref-qualified pointer-to-member functions. llvm-svn: 124294
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index cb02be546e0..062d4f697ab 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2557,6 +2557,32 @@ QualType Sema::CheckPointerToMemberOperands(Expr *&lex, Expr *&rex,
QualType Result = MemPtr->getPointeeType();
Result = Context.getCVRQualifiedType(Result, LType.getCVRQualifiers());
+ // C++0x [expr.mptr.oper]p6:
+ // In a .* expression whose object expression is an rvalue, the program is
+ // ill-formed if the second operand is a pointer to member function with
+ // ref-qualifier &. In a ->* expression or in a .* expression whose object
+ // expression is an lvalue, the program is ill-formed if the second operand
+ // is a pointer to member function with ref-qualifier &&.
+ if (const FunctionProtoType *Proto = Result->getAs<FunctionProtoType>()) {
+ switch (Proto->getRefQualifier()) {
+ case RQ_None:
+ // Do nothing
+ break;
+
+ case RQ_LValue:
+ if (!isIndirect && !lex->Classify(Context).isLValue())
+ Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+ << RType << 1 << lex->getSourceRange();
+ break;
+
+ case RQ_RValue:
+ if (isIndirect || !lex->Classify(Context).isRValue())
+ Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+ << RType << 0 << lex->getSourceRange();
+ break;
+ }
+ }
+
// C++ [expr.mptr.oper]p6:
// The result of a .* expression whose second operand is a pointer
// to a data member is of the same value category as its
OpenPOWER on IntegriCloud