]> granicus.if.org Git - clang/commitdiff
Don't try to take the address of a bitfield; fixes PR2310.
authorEli Friedman <eli.friedman@gmail.com>
Mon, 12 May 2008 15:06:05 +0000 (15:06 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 12 May 2008 15:06:05 +0000 (15:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50966 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprAgg.cpp
test/CodeGen/bitfield-init.c

index 508bf753832a70b1bc2426d05f1623ad3e6682d3..6b68705af7329d99516a078f021a2d3920743034 100644 (file)
@@ -304,12 +304,11 @@ void AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV) {
   // 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) {
index 6e89e1185a4d3297fff39a2737a44e7347cdc42e..c5f6139800df03fd398040ad2c11b885d2309a21 100644 (file)
@@ -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 };
+}
+