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 | b58a80440041407b1617e32db1ce83fa567991e9 (patch) | |
tree | 0cc91d577e8d7ca058c3c5a039c926608886ec76 /tools | |
parent | 30457f2cab0bf62d1d1d144028c8b03965aee2ef (diff) | |
download | external_llvm-b58a80440041407b1617e32db1ce83fa567991e9.zip external_llvm-b58a80440041407b1617e32db1ce83fa567991e9.tar.gz external_llvm-b58a80440041407b1617e32db1ce83fa567991e9.tar.bz2 |
llvm-mc: Make non-sensical max bytes to .align an error.
Also, warn about overflow in alignment values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-mc/AsmParser.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index d92d514..24c8301 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/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; } |