From: Reid Kleckner Date: Mon, 11 Aug 2014 18:34:43 +0000 (+0000) Subject: MC: Diagnose an unexpected token in COFF .section instead of asserting X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b81e6cf6c51866e7e802089a7e0fdb01082fffd7;p=oota-llvm.git MC: Diagnose an unexpected token in COFF .section instead of asserting This can easily arise when trying to assemble and ELF style .section directive for a COFF object file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215373 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCParser/COFFAsmParser.cpp b/lib/MC/MCParser/COFFAsmParser.cpp index 5ecf9e5c64b..6f82e6ef3e4 100644 --- a/lib/MC/MCParser/COFFAsmParser.cpp +++ b/lib/MC/MCParser/COFFAsmParser.cpp @@ -364,6 +364,10 @@ bool COFFAsmParser::ParseDirectiveSection(StringRef, SMLoc) { Flags |= COFF::IMAGE_SCN_LNK_COMDAT; + if (!getLexer().is(AsmToken::Identifier)) + return TokError("expected comdat type such as 'discard' or 'largest' " + "after protection bits"); + if (parseCOMDATType(Type)) return true; diff --git a/test/MC/COFF/section-invalid-flags.s b/test/MC/COFF/section-invalid-flags.s index 17b1550a904..9cdceaf3001 100644 --- a/test/MC/COFF/section-invalid-flags.s +++ b/test/MC/COFF/section-invalid-flags.s @@ -6,3 +6,6 @@ // CHECK: error: conflicting section flags 'b' and 'd' .section s_bd,"bd"; .long 1 + +// CHECK: error: expected comdat type such as 'discard' or 'largest' after protection bits +.section .stack, "w", @nobits