diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-26 09:16:34 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-26 09:16:34 +0000 |
commit | 18f3c9b9941f374d5455534cb6b0df5e6f6f6e03 (patch) | |
tree | 1a436ce5777ddb164816921afbdfb76112e694d1 /llvm/tools | |
parent | 5f4e42ef9c84bdaf5f923246a85fd49dff7da7d2 (diff) | |
download | bcm5719-llvm-18f3c9b9941f374d5455534cb6b0df5e6f6f6e03.tar.gz bcm5719-llvm-18f3c9b9941f374d5455534cb6b0df5e6f6f6e03.zip |
llvm-mc: Make non-sensical max bytes to .align an error.
Also, warn about overflow in alignment values.
llvm-svn: 80077
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-mc/AsmParser.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/tools/llvm-mc/AsmParser.cpp b/llvm/tools/llvm-mc/AsmParser.cpp index d92d514f8a4..24c830127ac 100644 --- a/llvm/tools/llvm-mc/AsmParser.cpp +++ b/llvm/tools/llvm-mc/AsmParser.cpp @@ -1024,6 +1024,7 @@ bool AsmParser::ParseDirectiveOrg() { /// ParseDirectiveAlign /// ::= {.align, ...} expression [ , expression [ , expression ]] bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) { + SMLoc AlignmentLoc = Lexer.getLoc(); int64_t Alignment; if (ParseAbsoluteExpression(Alignment)) return true; @@ -1070,15 +1071,19 @@ bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) { // Compute alignment in bytes. if (IsPow2) { // FIXME: Diagnose overflow. - Alignment = 1LL << Alignment; + if (Alignment >= 32) { + Error(AlignmentLoc, "invalid alignment value"); + Alignment = 31; + } + + Alignment = 1 << Alignment; } - // Diagnose non-sensical max bytes to fill, which are treated as missing (this - // matches 'as'). + // Diagnose non-sensical max bytes to align. if (MaxBytesLoc.isValid()) { if (MaxBytesToFill < 1) { - Warning(MaxBytesLoc, "alignment directive can never be satisfied in this " - "many bytes, ignoring maximum bytes expression"); + Error(MaxBytesLoc, "alignment directive can never be satisfied in this " + "many bytes, ignoring maximum bytes expression"); MaxBytesToFill = 0; } |