From: Anders Carlsson Date: Sat, 7 Nov 2009 23:16:50 +0000 (+0000) Subject: Handle member expressions where the member declaration is actually a static variable... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=589f9e3f7845c2a1bf97ae4357aec5b457a5ea19;p=clang Handle member expressions where the member declaration is actually a static variable. Fixes PR5392. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86414 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 323710a104..e489b85291 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1155,6 +1155,9 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { return LV; } + if (VarDecl *VD = dyn_cast(ND)) + return EmitGlobalVarDeclLValue(*this, E, VD); + assert(false && "Unhandled member declaration!"); return LValue(); } diff --git a/test/CodeGenCXX/member-expressions.cpp b/test/CodeGenCXX/member-expressions.cpp new file mode 100644 index 0000000000..f90b807339 --- /dev/null +++ b/test/CodeGenCXX/member-expressions.cpp @@ -0,0 +1,19 @@ +// RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s + +// PR5392 +namespace PR5392 { +struct A +{ + static int a; +}; + +A a1; +void f() +{ + // CHECK: store i32 10, i32* @_ZN6PR53921A1aE + a1.a = 10; + // CHECK: store i32 20, i32* @_ZN6PR53921A1aE + A().a = 20; +} + +}