[llvm-branch-commits] [cfe-branch] r105031 - in /cfe/branches/Apple/whitney: include/clang/Parse/Action.h lib/Parse/ParsePragma.cpp lib/Sema/SemaAttr.cpp test/Sema/pragma-align-packed.c

Daniel Dunbar daniel at zuster.org
Fri May 28 16:06:27 PDT 2010


Author: ddunbar
Date: Fri May 28 18:06:27 2010
New Revision: 105031

URL: http://llvm.org/viewvc/llvm-project?rev=105031&view=rev
Log:
Merge r104865:
--
Author: Daniel Dunbar <daniel at zuster.org>
Date:   Thu May 27 18:42:17 2010 +0000

    Parse/Sema: Add support for '#pragma options align=packed', which, it should be
    noted, is not the same as __attribute__((packed)). That would be ridiculous!

Added:
    cfe/branches/Apple/whitney/test/Sema/pragma-align-packed.c
Modified:
    cfe/branches/Apple/whitney/include/clang/Parse/Action.h
    cfe/branches/Apple/whitney/lib/Parse/ParsePragma.cpp
    cfe/branches/Apple/whitney/lib/Sema/SemaAttr.cpp

Modified: cfe/branches/Apple/whitney/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/Parse/Action.h?rev=105031&r1=105030&r2=105031&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/Parse/Action.h (original)
+++ cfe/branches/Apple/whitney/include/clang/Parse/Action.h Fri May 28 18:06:27 2010
@@ -2567,6 +2567,7 @@
   enum PragmaOptionsAlignKind {
     POAK_Native,  // #pragma options align=native
     POAK_Natural, // #pragma options align=natural
+    POAK_Packed,  // #pragma options align=packed
     POAK_Power,   // #pragma options align=power
     POAK_Mac68k,  // #pragma options align=mac68k
     POAK_Reset    // #pragma options align=reset

Modified: cfe/branches/Apple/whitney/lib/Parse/ParsePragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Parse/ParsePragma.cpp?rev=105031&r1=105030&r2=105031&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Parse/ParsePragma.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Parse/ParsePragma.cpp Fri May 28 18:06:27 2010
@@ -140,6 +140,8 @@
     Kind = Action::POAK_Native;
   else if (II->isStr("natural"))
     Kind = Action::POAK_Natural;
+  else if (II->isStr("packed"))
+    Kind = Action::POAK_Packed;
   else if (II->isStr("power"))
     Kind = Action::POAK_Power;
   else if (II->isStr("mac68k"))

Modified: cfe/branches/Apple/whitney/lib/Sema/SemaAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaAttr.cpp?rev=105031&r1=105030&r2=105031&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaAttr.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaAttr.cpp Fri May 28 18:06:27 2010
@@ -146,6 +146,13 @@
     Context->setAlignment(0);
     break;
 
+    // Note that '#pragma options align=packed' is not equivalent to attribute
+    // packed, it has a different precedence relative to attribute aligned.
+  case POAK_Packed:
+    Context->push(0);
+    Context->setAlignment(1);
+    break;
+
   case POAK_Mac68k:
     // Check if the target supports this.
     if (!PP.getTargetInfo().hasAlignMac68kSupport()) {

Added: cfe/branches/Apple/whitney/test/Sema/pragma-align-packed.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/Sema/pragma-align-packed.c?rev=105031&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/Sema/pragma-align-packed.c (added)
+++ cfe/branches/Apple/whitney/test/Sema/pragma-align-packed.c Fri May 28 18:06:27 2010
@@ -0,0 +1,23 @@
+// RUN: %clang-cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+#pragma pack(push, 1)
+struct s0 {
+  char f0;
+  int  f1 __attribute__((aligned(4)));
+};
+extern int a[sizeof(struct s0) == 5 ? 1 : -1];
+#pragma pack(pop)
+
+struct __attribute__((packed)) s1 {
+  char f0;
+  int  f1 __attribute__((aligned(4)));
+};
+extern int a[sizeof(struct s1) == 8 ? 1 : -1];
+
+#pragma options align=packed
+struct s2 {
+  char f0;
+  int  f1 __attribute__((aligned(4)));
+};
+extern int a[sizeof(struct s2) == 5 ? 1 : -1];
+#pragma options align=reset





More information about the llvm-branch-commits mailing list