diff options
author | Mike Stump <mrs@apple.com> | 2006-07-12 13:12:08 +0000 |
---|---|---|
committer | Mike Stump <mrs@gcc.gnu.org> | 2006-07-12 13:12:08 +0000 |
commit | 8b907df422779e4e8e8c45c108d977c438596a0a (patch) | |
tree | 50c5349162dd02d3c472fa9ef829d8c3ee475883 /gcc/c-parser.c | |
parent | 4b641750827a22aa0335f52c8319808acf3f6217 (diff) | |
download | gcc-8b907df422779e4e8e8c45c108d977c438596a0a.zip gcc-8b907df422779e4e8e8c45c108d977c438596a0a.tar.gz gcc-8b907df422779e4e8e8c45c108d977c438596a0a.tar.bz2 |
re PR c/28280 (bogus "statement with no effect" warning with VLA and typeof)
PR c/28280
* c-parser.c (c_parser_typeof_specifier): Don't use
c_finish_expr_stmt, open code desired semantics instead.
From-SVN: r115369
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r-- | gcc/c-parser.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 32d2c51..d591284 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -2164,7 +2164,19 @@ c_parser_typeof_specifier (c_parser *parser) is evaluated, this can be evaluated. For now, we avoid evaluation when the context might. */ if (!skip_evaluation && was_vm) - c_finish_expr_stmt (expr.value); + { + tree e = expr.value; + + /* If the expression is not of a type to which we cannot assign a line + number, wrap the thing in a no-op NOP_EXPR. */ + if (DECL_P (e) || CONSTANT_CLASS_P (e)) + e = build1 (NOP_EXPR, void_type_node, e); + + if (EXPR_P (e)) + SET_EXPR_LOCATION (e, input_location); + + add_stmt (e); + } pop_maybe_used (was_vm); } c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); |