]> granicus.if.org Git - clang/commitdiff
Make sure that value-initialized pointers to data members are initialized correctly.
authorAnders Carlsson <andersca@mac.com>
Fri, 14 May 2010 15:05:19 +0000 (15:05 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 14 May 2010 15:05:19 +0000 (15:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103771 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprScalar.cpp
test/CodeGenCXX/pointers-to-data-members.cpp

index 9849688023821ffaaab589ffc6dbad5ae582ddf2..f6d383704cdd706d1f026b5e947ff8789f5124e1 100644 (file)
@@ -186,7 +186,7 @@ public:
   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.
index d96eb03b8d82eb849853967eb4b59f6ef53aacf9..5ccf06e302e3f57d5452f2b306ca053f03a6276a 100644 (file)
@@ -85,3 +85,20 @@ namespace Comparisons {
     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() {}
+
+}