From 4b619ce1cdc755b2cfaf5adbe45d6e470cf1469b Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sun, 25 Nov 2012 15:56:13 +0100 Subject: [PATCH] -Wconst-var --- opts.def | 1 + parser.c | 7 +++++++ 2 files changed, 8 insertions(+) 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")) { -- 2.39.2