mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
new warning: -Wlocal-constants
This commit is contained in:
parent
92e8f08df3
commit
8fcc528ffa
3 changed files with 12 additions and 0 deletions
1
main.c
1
main.c
|
@ -384,6 +384,7 @@ int main(int argc, char **argv) {
|
|||
options_set(opts_warn, WARN_TOO_FEW_PARAMETERS, true);
|
||||
options_set(opts_warn, WARN_MISSING_RETURN_VALUES, true);
|
||||
options_set(opts_warn, WARN_USED_UNINITIALIZED, true);
|
||||
options_set(opts_warn, WARN_LOCAL_CONSTANTS, true);
|
||||
|
||||
if (!options_parse(argc, argv)) {
|
||||
return usage();
|
||||
|
|
10
parser.c
10
parser.c
|
@ -2115,6 +2115,16 @@ nextvar:
|
|||
continue;
|
||||
}
|
||||
|
||||
if (localblock && opts_standard == COMPILER_QCC) {
|
||||
if (parsewarning(parser, WARN_LOCAL_CONSTANTS,
|
||||
"initializing expression turns variable `%s` into a constant in this standard",
|
||||
var->name) )
|
||||
{
|
||||
ast_value_delete(typevar);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (parser->tok != '=') {
|
||||
ast_value_delete(typevar);
|
||||
parseerror(parser, "expected '=' or ';'");
|
||||
|
|
|
@ -11,3 +11,4 @@ GMQCC_DEFINE_FLAG(FIELD_REDECLARED)
|
|||
GMQCC_DEFINE_FLAG(MISSING_RETURN_VALUES)
|
||||
GMQCC_DEFINE_FLAG(TOO_FEW_PARAMETERS)
|
||||
GMQCC_DEFINE_FLAG(LOCAL_SHADOWS)
|
||||
GMQCC_DEFINE_FLAG(LOCAL_CONSTANTS)
|
||||
|
|
Loading…
Reference in a new issue