Skip to content

Commit a94226f

Browse files
authored
[llvm-ml] Remove unsafe getCurrentSegmentOnly() call (llvm#123355)
This call was made unsafe recently, but was not fixed in db48f1a (the commit that fixed the parallel code in AsmParser.cpp). Fixes llvm#123189
1 parent 6c11b7e commit a94226f

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

llvm/lib/MC/MCParser/COFFMasmParser.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,9 @@ bool COFFMasmParser::parseDirectiveOption(StringRef Directive, SMLoc Loc) {
441441
/// statements
442442
/// label "endproc"
443443
bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
444+
if (!getStreamer().getCurrentFragment())
445+
return Error(getTok().getLoc(), "expected section directive");
446+
444447
StringRef Label;
445448
if (getParser().parseIdentifier(Label))
446449
return Error(Loc, "expected identifier for procedure");

llvm/lib/MC/MCParser/MasmParser.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,8 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
14541454
}
14551455

14561456
bool MasmParser::checkForValidSection() {
1457-
if (!ParsingMSInlineAsm && !getStreamer().getCurrentSectionOnly()) {
1457+
if (!ParsingMSInlineAsm && !(getStreamer().getCurrentFragment() &&
1458+
getStreamer().getCurrentSectionOnly())) {
14581459
Out.initSections(false, getTargetParser().getSTI());
14591460
return Error(getTok().getLoc(),
14601461
"expected section directive before assembly directive");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; RUN: not llvm-ml -filetype=s %s /Fo /dev/null 2>&1 | FileCheck %s
2+
3+
; CHECK: :[[# @LINE+1]]:1: error: expected section directive
4+
foo PROC
5+
; CHECK: :[[# @LINE+1]]:6: error: expected section directive before assembly directive
6+
ret
7+
foo ENDP
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
; RUN: not llvm-ml -filetype=s %s /Fo /dev/null 2>&1 | FileCheck %s
2+
3+
; CHECK: :[[# @LINE + 1]]:6: error: expected section directive before assembly directive in 'BYTE' directive
4+
BYTE 2, 3, 4

0 commit comments

Comments
 (0)