[cfe-commits] r97981 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp test/CodeGen/init.c
Chris Lattner
sabre at nondot.org
Mon Mar 8 13:08:07 PST 2010
Author: lattner
Date: Mon Mar 8 15:08:07 2010
New Revision: 97981
URL: http://llvm.org/viewvc/llvm-project?rev=97981&view=rev
Log:
add a codegen hack to work around an AST bug, allowing us to compile the
code in PR6537. This should be reverted when the ast bug is fixed.
Modified:
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/test/CodeGen/init.c
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=97981&r1=97980&r2=97981&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Mon Mar 8 15:08:07 2010
@@ -662,6 +662,16 @@
return;
}
+
+ // If we're initializing the whole aggregate, just do it in place.
+ // FIXME: This is a hack around an AST bug (PR6537).
+ if (NumInitElements == 1 && E->getType() == E->getInit(0)->getType()) {
+ EmitInitializationToLValue(E->getInit(0),
+ LValue::MakeAddr(DestPtr, Qualifiers()),
+ E->getType());
+ return;
+ }
+
// Here we iterate over the fields; this makes it simpler to both
// default-initialize fields and skip over unnamed fields.
@@ -680,8 +690,8 @@
// We never generate write-barries for initialized fields.
LValue::SetObjCNonGC(FieldLoc, true);
if (CurInitVal < NumInitElements) {
- // Store the initializer into the field
- EmitInitializationToLValue(E->getInit(CurInitVal++), FieldLoc,
+ // Store the initializer into the field.
+ EmitInitializationToLValue(E->getInit(CurInitVal++), FieldLoc,
Field->getType());
} else {
// We're out of initalizers; default-initialize to null
Modified: cfe/trunk/test/CodeGen/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/init.c?rev=97981&r1=97980&r2=97981&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/init.c (original)
+++ cfe/trunk/test/CodeGen/init.c Mon Mar 8 15:08:07 2010
@@ -29,3 +29,14 @@
static const int g4 = 12;
return g4;
}
+
+// PR6537
+typedef union vec3 {
+ struct { double x, y, z; };
+ double component[3];
+} vec3;
+vec3 f5(vec3 value) {
+ return (vec3) {{
+ .x = value.x
+ }};
+}
More information about the cfe-commits
mailing list