зеркало из https://github.com/microsoft/clang-1.git
Parse/Sema: Add support for '#pragma options align=native'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104864 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
a2ace58cf9
Коммит
638e7cf3a0
|
@ -2565,6 +2565,7 @@ public:
|
|||
//===---------------------------- Pragmas -------------------------------===//
|
||||
|
||||
enum PragmaOptionsAlignKind {
|
||||
POAK_Native, // #pragma options align=native
|
||||
POAK_Natural, // #pragma options align=natural
|
||||
POAK_Power, // #pragma options align=power
|
||||
POAK_Mac68k, // #pragma options align=mac68k
|
||||
|
|
|
@ -110,7 +110,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
|
|||
LParenLoc, RParenLoc);
|
||||
}
|
||||
|
||||
// #pragma 'options' 'align' '=' {'natural', 'mac68k', 'power', 'reset'}
|
||||
// #pragma 'options' 'align' '=' {'native','natural','mac68k','power','reset'}
|
||||
void PragmaOptionsHandler::HandlePragma(Preprocessor &PP, Token &OptionsTok) {
|
||||
SourceLocation OptionsLoc = OptionsTok.getLocation();
|
||||
|
||||
|
@ -120,7 +120,7 @@ void PragmaOptionsHandler::HandlePragma(Preprocessor &PP, Token &OptionsTok) {
|
|||
PP.Diag(Tok.getLocation(), diag::warn_pragma_options_expected_align);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PP.Lex(Tok);
|
||||
if (Tok.isNot(tok::equal)) {
|
||||
PP.Diag(Tok.getLocation(), diag::warn_pragma_options_expected_equal);
|
||||
|
@ -136,7 +136,9 @@ void PragmaOptionsHandler::HandlePragma(Preprocessor &PP, Token &OptionsTok) {
|
|||
|
||||
Action::PragmaOptionsAlignKind Kind = Action::POAK_Natural;
|
||||
const IdentifierInfo *II = Tok.getIdentifierInfo();
|
||||
if (II->isStr("natural"))
|
||||
if (II->isStr("native"))
|
||||
Kind = Action::POAK_Native;
|
||||
else if (II->isStr("natural"))
|
||||
Kind = Action::POAK_Natural;
|
||||
else if (II->isStr("power"))
|
||||
Kind = Action::POAK_Power;
|
||||
|
|
|
@ -137,6 +137,10 @@ void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
|
|||
|
||||
// We don't support #pragma options align=power.
|
||||
switch (Kind) {
|
||||
// For all targets we support native and natural are the same.
|
||||
//
|
||||
// FIXME: This is not true on Darwin/PPC.
|
||||
case POAK_Native:
|
||||
case POAK_Natural:
|
||||
Context->push(0);
|
||||
Context->setAlignment(0);
|
||||
|
|
|
@ -16,6 +16,14 @@ struct s1 {
|
|||
};
|
||||
extern int a[sizeof(struct s1) == 8 ? 1 : -1];
|
||||
|
||||
#pragma options align=reset
|
||||
#pragma options align=native
|
||||
struct s1_1 {
|
||||
char c;
|
||||
int x;
|
||||
};
|
||||
extern int a[sizeof(struct s1_1) == 8 ? 1 : -1];
|
||||
|
||||
#pragma pack(pop)
|
||||
struct s2 {
|
||||
char c;
|
||||
|
|
Загрузка…
Ссылка в новой задаче