[Bug c/119311] musttail attribute is lost sometimes as single statement for then part of an if statement

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Mar 18 17:52:21 GMT 2025


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119311

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:53d8ed13bb5a6972efab7c56c066010cd1f78b35

commit r15-8267-g53d8ed13bb5a6972efab7c56c066010cd1f78b35
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Mar 18 18:51:48 2025 +0100

    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.


More information about the Gcc-bugs mailing list