Skip to content

Commit 0dd9daf

Browse files
ericastormemfrob
authored andcommitted
[ms] [llvm-ml] Accept /WX to signal that warnings should be fatal.
Define -fatal-warnings to make warnings fatal, and accept /WX as an ML.EXE compatible alias for it. Also make sure that if Warning() returns true, we always treat it as an error. Reviewed By: thakis Differential Revision: https://reviews.llvm.org/D92504
1 parent a541603 commit 0dd9daf

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

llvm/lib/MC/MCParser/MasmParser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4473,8 +4473,9 @@ bool MasmParser::parseDirectiveAlign() {
44734473
return addErrorSuffix(" in align directive");
44744474
// Ignore empty 'align' directives.
44754475
if (getTok().is(AsmToken::EndOfStatement)) {
4476-
Warning(AlignmentLoc, "align directive with no operand is ignored");
4477-
return parseToken(AsmToken::EndOfStatement);
4476+
return Warning(AlignmentLoc,
4477+
"align directive with no operand is ignored") &&
4478+
parseToken(AsmToken::EndOfStatement);
44784479
}
44794480
if (parseAbsoluteExpression(Alignment) ||
44804481
parseToken(AsmToken::EndOfStatement))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; RUN: not llvm-ml -filetype=s %s /WX /Fo /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
2+
3+
.data
4+
5+
; CHECK: :[[# @LINE + 1]]:25: error: MASM-style hex floats ignore explicit sign
6+
negative_hexfloat REAL4 -3fa66666r
7+
8+
.code
9+
10+
END
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: llvm-ml -filetype=s %s /Fo - 2>&1 | FileCheck %s
2+
3+
.data
4+
5+
; CHECK: :[[# @LINE + 1]]:25: warning: MASM-style hex floats ignore explicit sign
6+
negative_hexfloat REAL4 -3fa66666r
7+
; CHECK-LABEL: negative_hexfloat:
8+
; CHECK-NEXT: .long 1067869798
9+
10+
.code
11+
12+
END

llvm/tools/llvm-ml/Opts.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def bitness : LLVMJoined<"m">, Values<"32,64">,
3131
HelpText<"Target platform (x86 or x86-64)">;
3232
def as_lex : LLVMFlag<"as-lex">,
3333
HelpText<"Lex tokens from a .asm file without assembling">;
34+
def fatal_warnings : LLVMFlag<"fatal-warnings">,
35+
HelpText<"Treat warnings as errors">;
3436
def filetype : LLVMJoined<"filetype=">, Values<"obj,s,null">,
3537
HelpText<"Emit a file with the given type">;
3638
def output_att_asm : LLVMFlag<"output-att-asm">,
@@ -68,6 +70,7 @@ def safeseh : MLFlag<"safeseh">,
6870
def assembly_file : MLJoinedOrSeparate<"Ta">,
6971
HelpText<"Assemble source file with name not ending with "
7072
"the .asm extension">;
73+
def error_on_warning : MLFlag<"WX">, Alias<fatal_warnings>;
7174
def parse_only : MLFlag<"Zs">, HelpText<"Run a syntax-check only">,
7275
Alias<filetype>, AliasArgs<["null"]>;
7376

@@ -102,7 +105,6 @@ def listing_title : UnsupportedSeparate<"St">, HelpText<"">;
102105
def listing_false_conditionals : UnsupportedFlag<"Sx">, HelpText<"">;
103106
def extra_warnings : UnsupportedFlag<"w">, HelpText<"">;
104107
def warning_level : UnsupportedJoined<"W">, HelpText<"">;
105-
def error_on_warning : UnsupportedFlag<"WX">, HelpText<"">;
106108
def ignore_include_envvar : UnsupportedFlag<"X">, HelpText<"">;
107109
def line_number_info : UnsupportedFlag<"Zd">, HelpText<"">;
108110
def export_all_symbols : UnsupportedFlag<"Zf">, HelpText<"">;

llvm/tools/llvm-ml/llvm-ml.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ int main(int Argc, char **Argv) {
231231

232232
MCTargetOptions MCOptions;
233233
MCOptions.AssemblyLanguage = "masm";
234+
MCOptions.MCFatalWarnings = InputArgs.hasArg(OPT_fatal_warnings);
234235

235236
Triple TheTriple = GetTriple(ProgName, InputArgs);
236237
std::string Error;

0 commit comments

Comments
 (0)