From: Wolfgang (Blub) Bumiller Date: Sun, 25 Nov 2012 14:56:13 +0000 (+0100) Subject: -Wconst-var X-Git-Tag: 0.1.9~268 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4b619ce1cdc755b2cfaf5adbe45d6e470cf1469b;p=xonotic%2Fgmqcc.git -Wconst-var --- diff --git a/opts.def b/opts.def index 0741115..696ac37 100644 --- a/opts.def +++ b/opts.def @@ -59,6 +59,7 @@ GMQCC_DEFINE_FLAG(PREPROCESSOR) GMQCC_DEFINE_FLAG(MULTIFILE_IF) GMQCC_DEFINE_FLAG(DOUBLE_DECLARATION) + GMQCC_DEFINE_FLAG(CONST_VAR) #endif /* some cleanup so we don't have to */ diff --git a/parser.c b/parser.c index 5e2b160..4e628d9 100644 --- a/parser.c +++ b/parser.c @@ -3871,6 +3871,13 @@ static bool parser_global_statement(parser_t *parser) parseerror(parser, "expected variable declaration after 'const'"); return false; } + if (parser->tok == TOKEN_IDENT && !strcmp(parser_tokval(parser), "var")) { + (void)!parsewarning(parser, WARN_CONST_VAR, "ignoring `var` after const qualifier"); + if (!parser_next(parser)) { + parseerror(parser, "expected variable declaration after 'const var'"); + return false; + } + } return parse_variable(parser, NULL, true, true, NULL); } else if (!strcmp(parser_tokval(parser), "typedef")) {