Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/lib/MC/MCParser/COFFMasmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ bool COFFMasmParser::parseDirectiveOption(StringRef Directive, SMLoc Loc) {
/// statements
/// label "endproc"
bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
if (!getStreamer().getCurrentFragment()) {
return Error(getTok().getLoc(), "expected section directive");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omit braces for the single line simple statement

}

StringRef Label;
if (getParser().parseIdentifier(Label))
return Error(Loc, "expected identifier for procedure");
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/MC/MCParser/MasmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,8 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
}

bool MasmParser::checkForValidSection() {
if (!ParsingMSInlineAsm && !getStreamer().getCurrentSectionOnly()) {
if (!ParsingMSInlineAsm && !(getStreamer().getCurrentFragment() &&
getStreamer().getCurrentSectionOnly())) {
Out.initSections(false, getTargetParser().getSTI());
return Error(getTok().getLoc(),
"expected section directive before assembly directive");
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/tools/llvm-ml/bare_proc_error.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; RUN: not llvm-ml -filetype=s %s /Fo /dev/null 2>&1 | FileCheck %s

; CHECK: :[[# @LINE + 1]]:1: error: expected section directive before 'PROC' directive
Copy link
Member

@MaskRay MaskRay Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ok, but in the majority of tests we omit spaces beside +: LINE+1

foo PROC
; CHECK: :[[# @LINE + 1]]:6: error: expected section directive before assembly directive
ret
foo ENDP
4 changes: 4 additions & 0 deletions llvm/test/tools/llvm-ml/no_section_error.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
; RUN: not llvm-ml -filetype=s %s /Fo /dev/null 2>&1 | FileCheck %s

; CHECK: :[[# @LINE + 1]]:6: error: expected section directive before assembly directive in 'BYTE' directive
BYTE 2, 3, 4
Loading