]> granicus.if.org Git - clang/commitdiff
Revert r220153: "CodeGen: ConstStructBuilder must verify packed constraints after...
authorChandler Carruth <chandlerc@gmail.com>
Sun, 19 Oct 2014 19:41:46 +0000 (19:41 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sun, 19 Oct 2014 19:41:46 +0000 (19:41 +0000)
This commit caused two tests in LNT to regress. I'm able to reproduce on
any platform and will send reproduction steps to the original commit
log. This should restore the LNT bots that have been failing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220169 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprConstant.cpp
test/CodeGen/const-init.c

index dd87dd4657e08edaab96b2fa9044b6414aa6bba7..421e7deccc3917cb4309d938c9f0cbb41240fe3d 100644 (file)
@@ -106,6 +106,15 @@ AppendBytes(CharUnits FieldOffsetInChars, llvm::Constant *InitCst) {
   CharUnits AlignedNextFieldOffsetInChars =
     NextFieldOffsetInChars.RoundUpToAlignment(FieldAlignment);
 
+  if (AlignedNextFieldOffsetInChars > FieldOffsetInChars) {
+    assert(!Packed && "Alignment is wrong even with a packed struct!");
+
+    // Convert the struct to a packed struct.
+    ConvertStructToPacked();
+
+    AlignedNextFieldOffsetInChars = NextFieldOffsetInChars;
+  }
+
   if (AlignedNextFieldOffsetInChars < FieldOffsetInChars) {
     // We need to append padding.
     AppendPadding(FieldOffsetInChars - NextFieldOffsetInChars);
@@ -113,16 +122,6 @@ AppendBytes(CharUnits FieldOffsetInChars, llvm::Constant *InitCst) {
     assert(NextFieldOffsetInChars == FieldOffsetInChars &&
            "Did not add enough padding!");
 
-    AlignedNextFieldOffsetInChars =
-      NextFieldOffsetInChars.RoundUpToAlignment(FieldAlignment);
-  }
-
-  if (AlignedNextFieldOffsetInChars > FieldOffsetInChars) {
-    assert(!Packed && "Alignment is wrong even with a packed struct!");
-
-    // Convert the struct to a packed struct.
-    ConvertStructToPacked();
-
     AlignedNextFieldOffsetInChars = NextFieldOffsetInChars;
   }
 
index ccc6604c4560c622e1a582a6e3b7eb5138925894..7d7ccae370dd91c2524ac24e018764f743fce8b2 100644 (file)
@@ -159,14 +159,3 @@ void g29() {
   static int b[1] = { "asdf" }; // expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char [5]'}}
   static int c[1] = { L"a" };
 }
-
-// PR21300
-void g30() {
-#pragma pack(1)
-  static struct {
-    int : 1;
-    int x;
-  } a = {};
-  // CHECK: @g30.a = internal global %struct.anon.1 <{ i8 undef, i32 0 }>, align 1
-#pragma pack()
-}