Don't assume that the LHS and RHS of a member pointer expression is a DeclRefExpr. Fixes PR5177.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83986 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anders Carlsson 2009-10-13 17:41:28 +00:00
Родитель e647d93be5
Коммит 3eea635041
2 изменённых файлов: 23 добавлений и 5 удалений

Просмотреть файл

@ -278,10 +278,11 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
RValue
CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E) {
const BinaryOperator *BO = cast<BinaryOperator>(E->getCallee());
const DeclRefExpr *BaseExpr = cast<DeclRefExpr>(BO->getLHS());
const DeclRefExpr *MemFn = cast<DeclRefExpr>(BO->getRHS());
const Expr *BaseExpr = BO->getLHS();
const Expr *MemFnExpr = BO->getRHS();
const MemberPointerType *MPT = MemFn->getType()->getAs<MemberPointerType>();
const MemberPointerType *MPT =
MemFnExpr->getType()->getAs<MemberPointerType>();
const FunctionProtoType *FPT =
MPT->getPointeeType()->getAs<FunctionProtoType>();
const CXXRecordDecl *RD =
@ -296,8 +297,8 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E) {
// Get the member function pointer.
llvm::Value *MemFnPtr =
CreateTempAlloca(ConvertType(MemFn->getType()), "mem.fn");
EmitAggExpr(MemFn, MemFnPtr, /*VolatileDest=*/false);
CreateTempAlloca(ConvertType(MemFnExpr->getType()), "mem.fn");
EmitAggExpr(MemFnExpr, MemFnPtr, /*VolatileDest=*/false);
// Emit the 'this' pointer.
llvm::Value *This;

Просмотреть файл

@ -54,3 +54,20 @@ void f3(A *a, A &ar) {
(a->*pa)();
(ar.*pa)();
}
// PR5177
namespace PR5177 {
struct A {
bool foo(int*) const;
} a;
struct B1 {
bool (A::*pmf)(int*) const;
const A* pa;
B1() : pmf(&A::foo), pa(&a) {}
bool operator()() const { return (pa->*pmf)(new int); }
};
void bar(B1 b2) { while (b2()) ; }
}