[cfe-commits] r80837 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/anonymous-union-member-initializer.cpp
Anders Carlsson
andersca at mac.com
Wed Sep 2 14:14:48 PDT 2009
Author: andersca
Date: Wed Sep 2 16:14:47 2009
New Revision: 80837
URL: http://llvm.org/viewvc/llvm-project?rev=80837&view=rev
Log:
Fix an assertion when initializing a union using a member initializer. (We weren't casting from the union type to the initializer type correctly).
Added:
cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=80837&r1=80836&r2=80837&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Sep 2 16:14:47 2009
@@ -1658,7 +1658,8 @@
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();
}
}
Added: cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp?rev=80837&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp Wed Sep 2 16:14:47 2009
@@ -0,0 +1,12 @@
+// RUN: clang-cc -emit-llvm -o - %s
+
+struct A {
+ union {
+ int a;
+ void* b;
+ };
+
+ A() : a(0) { }
+};
+
+A a;
More information about the cfe-commits
mailing list