noted, is not the same as __attribute__((packed)). That would be ridiculous!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104865
91177308-0d34-0410-b5e6-
96231b3b80d8
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
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"))
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()) {
--- /dev/null
+// 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