forked from OSchip/llvm-project
We always need to emit the base expression of a member expression, even when the member decl refers to an enum. Thanks to Eli for pointing this out!
llvm-svn: 89775
This commit is contained in:
parent
b7408b95ed
commit
b9f96a3286
|
@ -169,9 +169,16 @@ public:
|
|||
Value *VisitShuffleVectorExpr(ShuffleVectorExpr *E);
|
||||
Value *VisitMemberExpr(MemberExpr *E) {
|
||||
if (const EnumConstantDecl *EC =
|
||||
dyn_cast<EnumConstantDecl>(E->getMemberDecl()))
|
||||
dyn_cast<EnumConstantDecl>(E->getMemberDecl())) {
|
||||
|
||||
// We still need to emit the base.
|
||||
if (E->isArrow())
|
||||
CGF.EmitScalarExpr(E->getBase());
|
||||
else
|
||||
CGF.EmitLValue(E->getBase());
|
||||
return llvm::ConstantInt::get(VMContext, EC->getInitVal());
|
||||
|
||||
}
|
||||
|
||||
return EmitLoadOfLValue(E);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,20 @@ void f()
|
|||
}
|
||||
|
||||
struct A {
|
||||
A();
|
||||
~A();
|
||||
enum E { Foo };
|
||||
};
|
||||
|
||||
A *g();
|
||||
|
||||
void f(A *a) {
|
||||
A::E e = a->Foo;
|
||||
A::E e1 = a->Foo;
|
||||
|
||||
// CHECK: call %struct.A* @_Z1gv()
|
||||
A::E e2 = g()->Foo;
|
||||
// CHECK: call void @_ZN1AC1Ev(
|
||||
// CHECK: call void @_ZN1AD1Ev(
|
||||
A::E e3 = A().Foo;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue