suppress "statement has no effect" warning for ms __noop operations
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 18 Mar 2008 13:52:54 +0000 (13:52 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 18 Mar 2008 13:52:54 +0000 (13:52 +0000)
[r18978]

ast_t.h
parser.c
parsetest/MS/noop.c

diff --git a/ast_t.h b/ast_t.h
index 17e9d10..6b6b94e 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -197,11 +197,13 @@ struct expression_base_t {
 struct const_expression_t {
        expression_base_t  base;
        union {
-               long long     int_value;
-               long double   float_value;
-               string_t      character;
-               wide_string_t wide_character;
+               long long      int_value;
+               long double    float_value;
+               string_t       character;
+               wide_string_t  wide_character;
        } v;
+       bool               is_ms_noop;  /**< True, if this constant is the result
+                                            of an microsoft __noop operator */
 };
 
 struct string_literal_expression_t {
index 8478953..5b21baf 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -4846,6 +4846,7 @@ static expression_t *parse_noop_expression(void) {
        cnst->base.source_position = source_position;
        cnst->base.type            = type_int;
        cnst->conste.v.int_value   = 0;
+       cnst->conste.is_ms_noop    = true;
 
        return cnst;
 
@@ -5832,7 +5833,8 @@ static bool expression_has_effect(const expression_t *const expr)
                case EXPR_UNKNOWN:                   break;
                case EXPR_INVALID:                   return true; /* do NOT warn */
                case EXPR_REFERENCE:                 return false;
-               case EXPR_CONST:                     return false;
+               /* suppress the warning for microsoft __noop operations */
+               case EXPR_CONST:                     return expr->conste.is_ms_noop;
                case EXPR_CHARACTER_CONSTANT:        return false;
                case EXPR_WIDE_CHARACTER_CONSTANT:   return false;
                case EXPR_STRING_LITERAL:            return false;
index d3ed78c..548b182 100644 (file)
@@ -1,3 +1,4 @@
 int test(int a, int b) {
-       return __noop(a+b, a, b);
+       __noop(a+b, a, b);
+       return 0;
 }