diff options
-rw-r--r-- | test/MC/AsmParser/directive_darwin_section.s | 4 | ||||
-rw-r--r-- | tools/llvm-mc/AsmParser.cpp | 18 |
2 files changed, 18 insertions, 4 deletions
diff --git a/test/MC/AsmParser/directive_darwin_section.s b/test/MC/AsmParser/directive_darwin_section.s new file mode 100644 index 0000000..4fea2ea --- /dev/null +++ b/test/MC/AsmParser/directive_darwin_section.s @@ -0,0 +1,4 @@ +# RUN: llvm-mc -triple i386-apple-darwin9 %s | FileCheck %s + +# CHECK: .section __DWARF,__debug_frame,regular,debug + .section __DWARF,__debug_frame,regular,debug diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index 09ca3f2..b4fdd83 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -688,14 +688,24 @@ bool AsmParser::ParseDirectiveSet() { /// FIXME: This should actually parse out the segment, section, attributes and /// sizeof_stub fields. bool AsmParser::ParseDirectiveDarwinSection() { + SMLoc Loc = Lexer.getLoc(); + StringRef SectionName; + if (ParseIdentifier(SectionName)) + return Error(Loc, "expected identifier after '.section' directive"); + + // Verify there is a following comma. + if (!Lexer.is(AsmToken::Comma)) + return TokError("unexpected token in '.section' directive"); - if (Lexer.isNot(AsmToken::Identifier)) - return TokError("expected identifier after '.section' directive"); - std::string SectionSpec = SectionName; + SectionSpec += ","; + + // Add all the tokens until the end of the line, ParseSectionSpecifier will + // handle this. StringRef EOL = Lexer.LexUntilEndOfStatement(); SectionSpec.append(EOL.begin(), EOL.end()); + Lexer.Lex(); if (Lexer.isNot(AsmToken::EndOfStatement)) return TokError("unexpected token in '.section' directive"); @@ -709,7 +719,7 @@ bool AsmParser::ParseDirectiveDarwinSection() { TAA, StubSize); if (!ErrorStr.empty()) - return TokError(ErrorStr.c_str()); + return Error(Loc, ErrorStr.c_str()); // FIXME: CACHE THESE. |