mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 22:22:17 +00:00
-Wreserved-names, -fpermissive allows local variables named 'nil' to be created even with -funtyped-nil, they supersede the global untyped 'nil'
This commit is contained in:
parent
2e0216b7c6
commit
77d454725a
3 changed files with 10 additions and 0 deletions
1
opts.c
1
opts.c
|
@ -54,6 +54,7 @@ static void opts_setdefault() {
|
|||
opts_set(opts.warn, WARN_UNREACHABLE_CODE, true);
|
||||
opts_set(opts.warn, WARN_CPP, true);
|
||||
opts_set(opts.warn, WARN_UNKNOWN_ATTRIBUTE, true);
|
||||
opts_set(opts.warn, WARN_RESERVED_NAMES, true);
|
||||
/* flags */
|
||||
opts_set(opts.flags, ADJUST_VECTOR_FIELDS, true);
|
||||
opts_set(opts.flags, FTEPP, false);
|
||||
|
|
2
opts.def
2
opts.def
|
@ -47,6 +47,7 @@
|
|||
GMQCC_DEFINE_FLAG(BAIL_ON_WERROR)
|
||||
GMQCC_DEFINE_FLAG(LOOP_LABELS)
|
||||
GMQCC_DEFINE_FLAG(UNTYPED_NIL)
|
||||
GMQCC_DEFINE_FLAG(PERMISSIVE)
|
||||
#endif
|
||||
|
||||
/* warning flags */
|
||||
|
@ -78,6 +79,7 @@
|
|||
GMQCC_DEFINE_FLAG(UNREACHABLE_CODE)
|
||||
GMQCC_DEFINE_FLAG(CPP)
|
||||
GMQCC_DEFINE_FLAG(UNKNOWN_ATTRIBUTE)
|
||||
GMQCC_DEFINE_FLAG(RESERVED_NAMES)
|
||||
#endif
|
||||
|
||||
#ifdef GMQCC_TYPE_OPTIMIZATIONS
|
||||
|
|
7
parser.c
7
parser.c
|
@ -4283,6 +4283,13 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
|
|||
* Also: if there was a prototype, `var` will be deleted and set to `proto` which
|
||||
* is then filled with the previous definition and the parameter-names replaced.
|
||||
*/
|
||||
if (!strcmp(var->name, "nil")) {
|
||||
if (OPTS_FLAG(UNTYPED_NIL)) {
|
||||
if (!localblock || !OPTS_FLAG(PERMISSIVE))
|
||||
parseerror(parser, "name `nil` not allowed (try -fpermissive)");
|
||||
} else
|
||||
(void)!parsewarning(parser, WARN_RESERVED_NAMES, "variable name `nil` is reserved");
|
||||
}
|
||||
if (!localblock) {
|
||||
/* Deal with end_sys_ vars */
|
||||
was_end = false;
|
||||
|
|
Loading…
Reference in a new issue