forked from OSchip/llvm-project
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! llvm-svn: 104865
This commit is contained in:
parent
663e8094ae
commit
9c84d4a8a0
|
@ -2567,6 +2567,7 @@ public:
|
|||
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
|
||||
|
|
|
@ -140,6 +140,8 @@ void PragmaOptionsHandler::HandlePragma(Preprocessor &PP, Token &OptionsTok) {
|
|||
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"))
|
||||
|
|
|
@ -146,6 +146,13 @@ void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
|
|||
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()) {
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue