mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-10-10 00:25:06 -04:00
Add gcc-style -W/-Wno- warning selections; -Wall; -Werror
Add gcc-style -Wxxx -Wno-xxx warning selection as an alternative to -w+xxx/-w-xxx. Add "all" as an alias for all (actual) warnings. Add "error" to treat warnings as errors.
This commit is contained in:
62
nasm.c
62
nasm.c
@@ -91,18 +91,18 @@ static enum op_type operating_mode;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Which of the suppressible warnings are suppressed. Entry zero
|
* Which of the suppressible warnings are suppressed. Entry zero
|
||||||
* doesn't do anything. Initial defaults are given here.
|
* isn't an actual warning, but it used for -w+error/-Werror.
|
||||||
*/
|
*/
|
||||||
static bool suppressed[1 + ERR_WARN_MAX] = {
|
static bool suppressed[ERR_WARN_MAX+1] = {
|
||||||
0, true, true, true, false, true, false, true, true, false
|
true, true, true, true, false, true, false, true, true, false
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The option names for the suppressible warnings. As before, entry
|
* The option names for the suppressible warnings. As before, entry
|
||||||
* zero does nothing.
|
* zero does nothing.
|
||||||
*/
|
*/
|
||||||
static const char *suppressed_names[1 + ERR_WARN_MAX] = {
|
static const char *suppressed_names[ERR_WARN_MAX+1] = {
|
||||||
NULL, "macro-params", "macro-selfref", "orphan-labels",
|
"error", "macro-params", "macro-selfref", "orphan-labels",
|
||||||
"number-overflow", "gnu-elf-extensions", "float-overflow",
|
"number-overflow", "gnu-elf-extensions", "float-overflow",
|
||||||
"float-denorm", "float-underflow", "float-toolong"
|
"float-denorm", "float-underflow", "float-toolong"
|
||||||
};
|
};
|
||||||
@@ -111,8 +111,8 @@ static const char *suppressed_names[1 + ERR_WARN_MAX] = {
|
|||||||
* The explanations for the suppressible warnings. As before, entry
|
* The explanations for the suppressible warnings. As before, entry
|
||||||
* zero does nothing.
|
* zero does nothing.
|
||||||
*/
|
*/
|
||||||
static const char *suppressed_what[1 + ERR_WARN_MAX] = {
|
static const char *suppressed_what[ERR_WARN_MAX+1] = {
|
||||||
NULL,
|
"treat warnings as errors",
|
||||||
"macro calls with wrong no. of params",
|
"macro calls with wrong no. of params",
|
||||||
"cyclic macro self-references",
|
"cyclic macro self-references",
|
||||||
"labels alone on lines without trailing `:'",
|
"labels alone on lines without trailing `:'",
|
||||||
@@ -372,6 +372,7 @@ static int process_arg(char *p, char *q)
|
|||||||
{
|
{
|
||||||
char *param;
|
char *param;
|
||||||
int i, advance = 0;
|
int i, advance = 0;
|
||||||
|
bool suppress;
|
||||||
|
|
||||||
if (!p || !p[0])
|
if (!p || !p[0])
|
||||||
return 0;
|
return 0;
|
||||||
@@ -509,9 +510,10 @@ static int process_arg(char *p, char *q)
|
|||||||
" -D<macro>[=<value>] pre-defines a macro\n"
|
" -D<macro>[=<value>] pre-defines a macro\n"
|
||||||
" -U<macro> undefines a macro\n"
|
" -U<macro> undefines a macro\n"
|
||||||
" -X<format> specifies error reporting format (gnu or vc)\n"
|
" -X<format> specifies error reporting format (gnu or vc)\n"
|
||||||
" -w+foo enables warnings about foo; -w-foo disables them\n"
|
" -w+foo enables warning foo (equiv. -Wfoo)\n"
|
||||||
"where foo can be:\n");
|
" -w-foo disable warning foo (equiv. -Wno-foo)\n"
|
||||||
for (i = 1; i <= ERR_WARN_MAX; i++)
|
"Warnings:\n");
|
||||||
|
for (i = 0; i <= ERR_WARN_MAX; i++)
|
||||||
printf(" %-23s %s (default %s)\n",
|
printf(" %-23s %s (default %s)\n",
|
||||||
suppressed_names[i], suppressed_what[i],
|
suppressed_names[i], suppressed_what[i],
|
||||||
suppressed[i] ? "off" : "on");
|
suppressed[i] ? "off" : "on");
|
||||||
@@ -556,20 +558,36 @@ static int process_arg(char *p, char *q)
|
|||||||
case 'a': /* assemble only - don't preprocess */
|
case 'a': /* assemble only - don't preprocess */
|
||||||
preproc = &no_pp;
|
preproc = &no_pp;
|
||||||
break;
|
break;
|
||||||
|
case 'W':
|
||||||
|
if (p[2] == 'n' && p[3] == 'o' && p[4] == '-') {
|
||||||
|
suppress = true;
|
||||||
|
p += 5;
|
||||||
|
} else {
|
||||||
|
suppress = false;
|
||||||
|
p += 2;
|
||||||
|
}
|
||||||
|
goto set_warning;
|
||||||
case 'w':
|
case 'w':
|
||||||
if (p[2] != '+' && p[2] != '-') {
|
if (p[2] != '+' && p[2] != '-') {
|
||||||
report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
|
report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
|
||||||
"invalid option to `-w'");
|
"invalid option to `-w'");
|
||||||
} else {
|
break;
|
||||||
for (i = 1; i <= ERR_WARN_MAX; i++)
|
|
||||||
if (!nasm_stricmp(p + 3, suppressed_names[i]))
|
|
||||||
break;
|
|
||||||
if (i <= ERR_WARN_MAX)
|
|
||||||
suppressed[i] = (p[2] == '-');
|
|
||||||
else
|
|
||||||
report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
|
|
||||||
"invalid option to `-w'");
|
|
||||||
}
|
}
|
||||||
|
suppress = (p[2] == '-');
|
||||||
|
p += 3;
|
||||||
|
goto set_warning;
|
||||||
|
set_warning:
|
||||||
|
for (i = 0; i <= ERR_WARN_MAX; i++)
|
||||||
|
if (!nasm_stricmp(p, suppressed_names[i]))
|
||||||
|
break;
|
||||||
|
if (i <= ERR_WARN_MAX)
|
||||||
|
suppressed[i] = suppress;
|
||||||
|
else if (!nasm_stricmp(p, "all"))
|
||||||
|
for (i = 1; i <= ERR_WARN_MAX; i++)
|
||||||
|
suppressed[i] = suppress;
|
||||||
|
else
|
||||||
|
report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
|
||||||
|
"invalid warning `%s'", p);
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
operating_mode = p[2] == 'G' ? op_depend_missing_ok : op_depend;
|
operating_mode = p[2] == 'G' ? op_depend_missing_ok : op_depend;
|
||||||
@@ -1614,12 +1632,14 @@ static void report_error_common(int severity, const char *fmt,
|
|||||||
want_usage = true;
|
want_usage = true;
|
||||||
|
|
||||||
switch (severity & ERR_MASK) {
|
switch (severity & ERR_MASK) {
|
||||||
case ERR_WARNING:
|
|
||||||
case ERR_DEBUG:
|
case ERR_DEBUG:
|
||||||
/* no further action, by definition */
|
/* no further action, by definition */
|
||||||
break;
|
break;
|
||||||
|
case ERR_WARNING:
|
||||||
|
if (!suppressed[0]) /* Treat warnings as errors */
|
||||||
|
terminate_after_phase = true;
|
||||||
|
break;
|
||||||
case ERR_NONFATAL:
|
case ERR_NONFATAL:
|
||||||
/* hack enables listing(!) on errors */
|
|
||||||
terminate_after_phase = true;
|
terminate_after_phase = true;
|
||||||
break;
|
break;
|
||||||
case ERR_FATAL:
|
case ERR_FATAL:
|
||||||
|
|||||||
Reference in New Issue
Block a user