[cfe-commits] r50966 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp test/CodeGen/bitfield-init.c

Eli Friedman eli.friedman at gmail.com
Mon May 12 08:06:06 PDT 2008


Author: efriedma
Date: Mon May 12 10:06:05 2008
New Revision: 50966

URL: http://llvm.org/viewvc/llvm-project?rev=50966&view=rev
Log:
Don't try to take the address of a bitfield; fixes PR2310.


Modified:
    cfe/trunk/lib/CodeGen/CGExprAgg.cpp
    cfe/trunk/test/CodeGen/bitfield-init.c

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=50966&r1=50965&r2=50966&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Mon May 12 10:06:05 2008
@@ -304,12 +304,11 @@
   // FIXME: Are initializers affected by volatile?
   if (E->getType()->isComplexType()) {
     CGF.EmitComplexExprIntoAddr(E, LV.getAddress(), false);
-    return;
+  } else if (CGF.hasAggregateLLVMType(E->getType())) {
+    CGF.EmitAnyExpr(E, LV.getAddress(), false);
+  } else {
+    CGF.EmitStoreThroughLValue(CGF.EmitAnyExpr(E), LV, E->getType());
   }
-  RValue RV = CGF.EmitAnyExpr(E, LV.getAddress(), false);
-  if (CGF.hasAggregateLLVMType(E->getType()))
-    return;
-  CGF.EmitStoreThroughLValue(RV, LV, E->getType());
 }
 
 void AggExprEmitter::EmitNullInitializationToLValue(LValue LV, QualType T) {

Modified: cfe/trunk/test/CodeGen/bitfield-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bitfield-init.c?rev=50966&r1=50965&r2=50966&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/bitfield-init.c (original)
+++ cfe/trunk/test/CodeGen/bitfield-init.c Mon May 12 10:06:05 2008
@@ -2,3 +2,11 @@
 typedef struct { unsigned int i: 1; } c;
 const c d = { 1 };
 
+// PR2310
+struct Token {
+  unsigned n : 31;
+};
+void sqlite3CodeSubselect(){
+  struct Token one = { 1 };
+}
+





More information about the cfe-commits mailing list