From 69dac58e7d4274137e0c37b215c375e6583c63af Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 27 May 2010 00:04:40 +0000 Subject: Sema: Support for #pragma options align={reset,natural}. '#pragma options align' shares the stack with '#pragma pack', who knew!? llvm-svn: 104786 --- clang/lib/Sema/SemaAttr.cpp | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaAttr.cpp') diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index dc7815fa643..770bd218d19 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -18,7 +18,7 @@ using namespace clang; //===----------------------------------------------------------------------===// -// Pragma Packed +// Pragma 'pack' and 'options align' //===----------------------------------------------------------------------===// namespace { @@ -94,6 +94,41 @@ unsigned Sema::getPragmaPackAlignment() const { return 0; } +void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, + SourceLocation PragmaLoc, + SourceLocation KindLoc) { + if (PackContext == 0) + PackContext = new PragmaPackStack(); + + PragmaPackStack *Context = static_cast(PackContext); + + // Reset just pops the top of the stack. + if (Kind == Action::POAK_Reset) { + // Do the pop. + if (!Context->pop(0)) { + // If a name was specified then failure indicates the name + // wasn't found. Otherwise failure indicates the stack was + // empty. + Diag(PragmaLoc, diag::warn_pragma_options_align_reset_failed) + << "stack empty"; + } + return; + } + + // We don't support #pragma options align=power. + switch (Kind) { + case POAK_Natural: + Context->push(0); + Context->setAlignment(0); + break; + + default: + Diag(PragmaLoc, diag::warn_pragma_options_align_unsupported_option) + << KindLoc; + break; + } +} + void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name, ExprTy *alignment, SourceLocation PragmaLoc, SourceLocation LParenLoc, SourceLocation RParenLoc) { -- cgit v1.2.3