[cfe-commits] r73349 - in /cfe/trunk: lib/CodeGen/CGExprConstant.cpp test/CodeGen/2009-06-14-anonymous-union-init.c
Eli Friedman
eli.friedman at gmail.com
Sun Jun 14 14:41:37 PDT 2009
Author: efriedma
Date: Sun Jun 14 16:41:37 2009
New Revision: 73349
URL: http://llvm.org/viewvc/llvm-project?rev=73349&view=rev
Log:
PR4390: Make sure to handle anonymous unions correctly while building
static intializers for structs.
Added:
cfe/trunk/test/CodeGen/2009-06-14-anonymous-union-init.c
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=73349&r1=73348&r2=73349&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Sun Jun 14 16:41:37 2009
@@ -198,16 +198,13 @@
// Copy initializer elements. Skip padding fields.
unsigned EltNo = 0; // Element no in ILE
- int FieldNo = 0; // Field no in RecordDecl
bool RewriteType = false;
for (RecordDecl::field_iterator Field = RD->field_begin(CGM.getContext()),
FieldEnd = RD->field_end(CGM.getContext());
EltNo < ILE->getNumInits() && Field != FieldEnd; ++Field) {
- FieldNo++;
- if (!Field->getIdentifier())
- continue;
-
if (Field->isBitField()) {
+ if (!Field->getIdentifier())
+ continue;
InsertBitfieldIntoStruct(Elts, *Field, ILE->getInit(EltNo));
} else {
unsigned FieldNo = CGM.getTypes().getLLVMFieldNo(*Field);
Added: cfe/trunk/test/CodeGen/2009-06-14-anonymous-union-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/2009-06-14-anonymous-union-init.c?rev=73349&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/2009-06-14-anonymous-union-init.c (added)
+++ cfe/trunk/test/CodeGen/2009-06-14-anonymous-union-init.c Sun Jun 14 16:41:37 2009
@@ -0,0 +1,7 @@
+// RUN: clang-cc -emit-llvm < %s | grep "zeroinitializer, i16 16877"
+// PR4390
+struct sysfs_dirent {
+ union { struct sysfs_elem_dir {} s_dir; };
+ unsigned short s_mode;
+};
+struct sysfs_dirent sysfs_root = { {}, 16877 };
More information about the cfe-commits
mailing list