summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-02 21:14:47 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-02 21:14:47 +0000
commit35dca26835572bb7e5e0e46a5ba745814d702691 (patch)
tree1c544b43db870bac30a2949691ee36e970629db6 /clang
parent3a964ebdc4e44e6adc1e0c4e7671db59a789b7bc (diff)
downloadbcm5719-llvm-35dca26835572bb7e5e0e46a5ba745814d702691.tar.gz
bcm5719-llvm-35dca26835572bb7e5e0e46a5ba745814d702691.zip
Fix an assertion when initializing a union using a member initializer. (We weren't casting from the union type to the initializer type correctly).
llvm-svn: 80837
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp3
-rw-r--r--clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp12
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 9e59a0a5a2f..c8e3d88e00e 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -1658,7 +1658,8 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) {
else {
// Initializing an anonymous union data member.
FieldDecl *anonMember = Member->getAnonUnionMember();
- LHS = EmitLValueForField(LHS.getAddress(), anonMember, false, 0);
+ LHS = EmitLValueForField(LHS.getAddress(), anonMember,
+ /*IsUnion=*/true, 0);
FieldType = anonMember->getType();
}
}
diff --git a/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp b/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp
new file mode 100644
index 00000000000..2030f4053c9
--- /dev/null
+++ b/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-cc -emit-llvm -o - %s
+
+struct A {
+ union {
+ int a;
+ void* b;
+ };
+
+ A() : a(0) { }
+};
+
+A a;
OpenPOWER on IntegriCloud