aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2025-03-18 18:51:48 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2025-03-18 18:51:48 +0100
commit53d8ed13bb5a6972efab7c56c066010cd1f78b35 (patch)
tree32e08178dcef7495b506b74432fe7f3033f6e7d8 /gcc/c/c-parser.cc
parent1d7f57da583782ae5d56655a3ac413bdf259838a (diff)
downloadgcc-53d8ed13bb5a6972efab7c56c066010cd1f78b35.zip
gcc-53d8ed13bb5a6972efab7c56c066010cd1f78b35.tar.gz
gcc-53d8ed13bb5a6972efab7c56c066010cd1f78b35.tar.bz2
c: Fix handling of [[gnu::musttail] return in if and else bodies [PR119311]
The following new testcase FAILs with C (and succeeds with C++). c_parser_handle_musttail is used in c_parser_compound_statement_nostart where it is directly passed to c_parser_statement_after_labels, and in c_parser_all_labels where it is returned. Now, out of the 3 c_parser_all_labels callers, c_parser_statement passes it down to c_parser_statement_after_labels, but c_parser_if_body and c_parser_else_body don't, so if there are return statements with [[gnu::musttail]] or [[clang::musttail]] directly in if or else bodies rather than wrapped with {}s, we throw that information away. 2025-03-18 Jakub Jelinek <jakub@redhat.com> PR c/119311 * c-parser.cc (c_parser_if_body): Pass result of c_parser_all_labels as last argument to c_parser_statement_after_labels. (c_parser_else_body): Likewise. * c-c++-common/musttail14.c: Use * instead of \* in the regexps. * c-c++-common/musttail25.c: New test.
Diffstat (limited to 'gcc/c/c-parser.cc')
-rw-r--r--gcc/c/c-parser.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 93233a87..d49d5c5 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -8545,8 +8545,8 @@ c_parser_if_body (c_parser *parser, bool *if_p,
token_indent_info body_tinfo
= get_token_indent_info (c_parser_peek_token (parser));
tree before_labels = get_before_labels ();
+ attr_state a = c_parser_all_labels (parser);
- c_parser_all_labels (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
location_t loc = c_parser_peek_token (parser)->location;
@@ -8561,7 +8561,7 @@ c_parser_if_body (c_parser *parser, bool *if_p,
else
{
body_loc_after_labels = c_parser_peek_token (parser)->location;
- c_parser_statement_after_labels (parser, if_p, before_labels);
+ c_parser_statement_after_labels (parser, if_p, before_labels, NULL, a);
}
token_indent_info next_tinfo
@@ -8590,8 +8590,8 @@ c_parser_else_body (c_parser *parser, const token_indent_info &else_tinfo,
= get_token_indent_info (c_parser_peek_token (parser));
location_t body_loc_after_labels = UNKNOWN_LOCATION;
tree before_labels = get_before_labels ();
+ attr_state a = c_parser_all_labels (parser);
- c_parser_all_labels (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
location_t loc = c_parser_peek_token (parser)->location;
@@ -8605,7 +8605,7 @@ c_parser_else_body (c_parser *parser, const token_indent_info &else_tinfo,
{
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, before_labels, chain);
+ c_parser_statement_after_labels (parser, NULL, before_labels, chain, a);
}
token_indent_info next_tinfo