[cfe-commits] r103771 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/pointers-to-data-members.cpp

Anders Carlsson andersca at mac.com
Fri May 14 08:05:19 PDT 2010


Author: andersca
Date: Fri May 14 10:05:19 2010
New Revision: 103771

URL: http://llvm.org/viewvc/llvm-project?rev=103771&view=rev
Log:
Make sure that value-initialized pointers to data members are initialized correctly.

Modified:
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=103771&r1=103770&r2=103771&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri May 14 10:05:19 2010
@@ -186,7 +186,7 @@
   Value *VisitInitListExpr(InitListExpr *E);
 
   Value *VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E) {
-    return llvm::Constant::getNullValue(ConvertType(E->getType()));
+    return CGF.CGM.EmitNullConstant(E->getType());
   }
   Value *VisitCastExpr(CastExpr *E) {
     // Make sure to evaluate VLA bounds now so that we have them for later.

Modified: cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp?rev=103771&r1=103770&r2=103771&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp Fri May 14 10:05:19 2010
@@ -85,3 +85,20 @@
     if (0 == a) { }
   }
 }
+
+namespace ValueInit {
+
+struct A {
+  int A::*a;
+
+  char c;
+
+  A();
+};
+
+// CHECK: define void @_ZN9ValueInit1AC2Ev
+// CHECK: store i64 -1, i64*
+// CHECK: ret void
+A::A() : a() {}
+
+}





More information about the cfe-commits mailing list