aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2017-07-25 09:49:08 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2017-07-25 09:49:08 +0000
commitd49718d6ff41cdf8ed6b013b9e099f7ec3541053 (patch)
tree1cb6cf103468770b4f76a042134eac5a3ae9a58b /gcc/c/c-parser.c
parent0e82a9b9422447fe9730831a5072655e0f5780f7 (diff)
downloadgcc-d49718d6ff41cdf8ed6b013b9e099f7ec3541053.zip
gcc-d49718d6ff41cdf8ed6b013b9e099f7ec3541053.tar.gz
gcc-d49718d6ff41cdf8ed6b013b9e099f7ec3541053.tar.bz2
re PR c/81364 (Bogus -Wmultistatement-macros warning)
PR c/81364 * c-parser.c (c_parser_else_body): Don't warn about multistatement macro expansion if the body is in { }. (c_parser_while_statement): Likewise. (c_parser_for_statement): Likewise. * Wmultistatement-macros-12.c: New test. From-SVN: r250498
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r--gcc/c/c-parser.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index eae7689..16cd357 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -5557,7 +5557,8 @@ c_parser_else_body (c_parser *parser, const token_indent_info &else_tinfo,
}
else
{
- body_loc_after_labels = c_parser_peek_token (parser)->location;
+ if (!c_parser_next_token_is (parser, CPP_OPEN_BRACE))
+ body_loc_after_labels = c_parser_peek_token (parser)->location;
c_parser_statement_after_labels (parser, NULL, chain);
}
@@ -5811,6 +5812,7 @@ c_parser_while_statement (c_parser *parser, bool ivdep, bool *if_p)
= get_token_indent_info (c_parser_peek_token (parser));
location_t loc_after_labels;
+ bool open_brace = c_parser_next_token_is (parser, CPP_OPEN_BRACE);
body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels);
c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true);
add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
@@ -5820,7 +5822,7 @@ c_parser_while_statement (c_parser *parser, bool ivdep, bool *if_p)
= get_token_indent_info (c_parser_peek_token (parser));
warn_for_misleading_indentation (while_tinfo, body_tinfo, next_tinfo);
- if (next_tinfo.type != CPP_SEMICOLON)
+ if (next_tinfo.type != CPP_SEMICOLON && !open_brace)
warn_for_multistatement_macros (loc_after_labels, next_tinfo.location,
while_tinfo.location, RID_WHILE);
@@ -6109,6 +6111,7 @@ c_parser_for_statement (c_parser *parser, bool ivdep, bool *if_p)
= get_token_indent_info (c_parser_peek_token (parser));
location_t loc_after_labels;
+ bool open_brace = c_parser_next_token_is (parser, CPP_OPEN_BRACE);
body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels);
if (is_foreach_statement)
@@ -6122,7 +6125,7 @@ c_parser_for_statement (c_parser *parser, bool ivdep, bool *if_p)
= get_token_indent_info (c_parser_peek_token (parser));
warn_for_misleading_indentation (for_tinfo, body_tinfo, next_tinfo);
- if (next_tinfo.type != CPP_SEMICOLON)
+ if (next_tinfo.type != CPP_SEMICOLON && !open_brace)
warn_for_multistatement_macros (loc_after_labels, next_tinfo.location,
for_tinfo.location, RID_FOR);