mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
Let the integrated assembler understand .warning, PR20428.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213873 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -357,7 +357,7 @@ private:
|
|||||||
DK_CFI_REGISTER, DK_CFI_WINDOW_SAVE,
|
DK_CFI_REGISTER, DK_CFI_WINDOW_SAVE,
|
||||||
DK_MACROS_ON, DK_MACROS_OFF, DK_MACRO, DK_ENDM, DK_ENDMACRO, DK_PURGEM,
|
DK_MACROS_ON, DK_MACROS_OFF, DK_MACRO, DK_ENDM, DK_ENDMACRO, DK_PURGEM,
|
||||||
DK_SLEB128, DK_ULEB128,
|
DK_SLEB128, DK_ULEB128,
|
||||||
DK_ERR, DK_ERROR,
|
DK_ERR, DK_ERROR, DK_WARNING,
|
||||||
DK_END
|
DK_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -474,6 +474,9 @@ private:
|
|||||||
// ".err" or ".error"
|
// ".err" or ".error"
|
||||||
bool parseDirectiveError(SMLoc DirectiveLoc, bool WithMessage);
|
bool parseDirectiveError(SMLoc DirectiveLoc, bool WithMessage);
|
||||||
|
|
||||||
|
// ".warning"
|
||||||
|
bool parseDirectiveWarning(SMLoc DirectiveLoc);
|
||||||
|
|
||||||
void initializeDirectiveKindMap();
|
void initializeDirectiveKindMap();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1553,6 +1556,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info) {
|
|||||||
return parseDirectiveError(IDLoc, false);
|
return parseDirectiveError(IDLoc, false);
|
||||||
case DK_ERROR:
|
case DK_ERROR:
|
||||||
return parseDirectiveError(IDLoc, true);
|
return parseDirectiveError(IDLoc, true);
|
||||||
|
case DK_WARNING:
|
||||||
|
return parseDirectiveWarning(IDLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Error(IDLoc, "unknown directive");
|
return Error(IDLoc, "unknown directive");
|
||||||
@@ -4073,6 +4078,32 @@ bool AsmParser::parseDirectiveError(SMLoc L, bool WithMessage) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// parseDirectiveWarning
|
||||||
|
/// ::= .warning [string]
|
||||||
|
bool AsmParser::parseDirectiveWarning(SMLoc L) {
|
||||||
|
if (!TheCondStack.empty()) {
|
||||||
|
if (TheCondStack.back().Ignore) {
|
||||||
|
eatToEndOfStatement();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringRef Message = ".warning directive invoked in source file";
|
||||||
|
if (Lexer.isNot(AsmToken::EndOfStatement)) {
|
||||||
|
if (Lexer.isNot(AsmToken::String)) {
|
||||||
|
TokError(".warning argument must be a string");
|
||||||
|
eatToEndOfStatement();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Message = getTok().getStringContents();
|
||||||
|
Lex();
|
||||||
|
}
|
||||||
|
|
||||||
|
Warning(L, Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// parseDirectiveEndIf
|
/// parseDirectiveEndIf
|
||||||
/// ::= .endif
|
/// ::= .endif
|
||||||
bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) {
|
bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) {
|
||||||
@@ -4205,6 +4236,7 @@ void AsmParser::initializeDirectiveKindMap() {
|
|||||||
DirectiveKindMap[".purgem"] = DK_PURGEM;
|
DirectiveKindMap[".purgem"] = DK_PURGEM;
|
||||||
DirectiveKindMap[".err"] = DK_ERR;
|
DirectiveKindMap[".err"] = DK_ERR;
|
||||||
DirectiveKindMap[".error"] = DK_ERROR;
|
DirectiveKindMap[".error"] = DK_ERROR;
|
||||||
|
DirectiveKindMap[".warning"] = DK_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) {
|
MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) {
|
||||||
|
26
test/MC/AsmParser/directive-warning.s
Normal file
26
test/MC/AsmParser/directive-warning.s
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// RUN: llvm-mc -triple i386 %s 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
.warning
|
||||||
|
// CHECK: warning: .warning directive invoked in source file
|
||||||
|
// CHECK-NEXT: .warning
|
||||||
|
// CHECK-NEXT: ^
|
||||||
|
|
||||||
|
.ifc a,a
|
||||||
|
.warning
|
||||||
|
.endif
|
||||||
|
// CHECK: warning: .warning directive invoked in source file
|
||||||
|
// CHECK-NEXT: .warning
|
||||||
|
// CHECK-NEXT: ^
|
||||||
|
|
||||||
|
.ifnc a,a
|
||||||
|
.warning
|
||||||
|
.endif
|
||||||
|
// CHECK-NOT: warning: .warning directive invoked in source file
|
||||||
|
|
||||||
|
.warning "here be dragons"
|
||||||
|
// CHECK: warning: here be dragons
|
||||||
|
|
||||||
|
.ifc one, two
|
||||||
|
.warning "dragons, i say"
|
||||||
|
.endif
|
||||||
|
// CHECK-NOT: warning: dragons, i say
|
Reference in New Issue
Block a user