diff options
author | Anders Carlsson <andersca@mac.com> | 2010-05-14 15:05:19 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-05-14 15:05:19 +0000 |
commit | 3cb18bcefe39756f3b079fa1a62b4c9cbf6a592f (patch) | |
tree | 666b1c2a096288ea98a1ef5bcfd64764bbaddf34 | |
parent | 5431299f6e1e1d14b39b924fe24bf04035f4ae42 (diff) |
Make sure that value-initialized pointers to data members are initialized correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103771 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 2 | ||||
-rw-r--r-- | test/CodeGenCXX/pointers-to-data-members.cpp | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 9849688023..f6d383704c 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -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. diff --git a/test/CodeGenCXX/pointers-to-data-members.cpp b/test/CodeGenCXX/pointers-to-data-members.cpp index d96eb03b8d..5ccf06e302 100644 --- a/test/CodeGenCXX/pointers-to-data-members.cpp +++ b/test/CodeGenCXX/pointers-to-data-members.cpp @@ -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() {} + +} |