]> granicus.if.org Git - clang/commitdiff
Handle member expressions where the member declaration is actually a static variable...
authorAnders Carlsson <andersca@mac.com>
Sat, 7 Nov 2009 23:16:50 +0000 (23:16 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 7 Nov 2009 23:16:50 +0000 (23:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86414 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGenCXX/member-expressions.cpp [new file with mode: 0644]

index 323710a1043ee07124ab5b57e7dab70424ebf16a..e489b852910a1d64f5c16cc677041a505a65667b 100644 (file)
@@ -1155,6 +1155,9 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
     return LV;
   }
   
+  if (VarDecl *VD = dyn_cast<VarDecl>(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 (file)
index 0000000..f90b807
--- /dev/null
@@ -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;
+}
+
+}