From: Wolfgang (Blub) Bumiller Date: Thu, 23 Aug 2012 18:52:09 +0000 (+0200) Subject: -Weffectless-statement, on by default, creates 'statement has no effect' warning X-Git-Tag: 0.1-rc1~61 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=45388202c418539dc8826d190a14d211136e32a0;p=xonotic%2Fgmqcc.git -Weffectless-statement, on by default, creates 'statement has no effect' warning --- diff --git a/main.c b/main.c index acc03c8..36b3349 100644 --- a/main.c +++ b/main.c @@ -402,6 +402,7 @@ int main(int argc, char **argv) { options_set(opts_warn, WARN_VARIADIC_FUNCTION, true); options_set(opts_warn, WARN_FRAME_MACROS, true); options_set(opts_warn, WARN_UNUSED_VARIABLE, true); + options_set(opts_warn, WARN_EFFECTLESS_STATEMENT, true); if (!options_parse(argc, argv)) { return usage(); diff --git a/parser.c b/parser.c index d382dd1..892ef2f 100644 --- a/parser.c +++ b/parser.c @@ -1768,6 +1768,13 @@ static bool parser_parse_statement(parser_t *parser, ast_block *block, ast_expre if (!exp) return false; *out = exp; + if (!ast_istype(exp, ast_store) && + !ast_istype(exp, ast_call) && + !ast_istype(exp, ast_binstore)) + { + if (parsewarning(parser, WARN_EFFECTLESS_STATEMENT, "statement has no effect")) + return false; + } return true; } } diff --git a/warns.def b/warns.def index b3abd78..1f47fed 100644 --- a/warns.def +++ b/warns.def @@ -16,3 +16,4 @@ GMQCC_DEFINE_FLAG(VOID_VARIABLES) GMQCC_DEFINE_FLAG(IMPLICIT_FUNCTION_POINTER) GMQCC_DEFINE_FLAG(VARIADIC_FUNCTION) GMQCC_DEFINE_FLAG(FRAME_MACROS) +GMQCC_DEFINE_FLAG(EFFECTLESS_STATEMENT)