From: Andi Kleen <a...@gcc.gnu.org> There are multiple reports (see PR 119376) now where semantic differences in the gcc musttail implementation break existing programs written for the clang variant.
Even though that can be all hopefully fixed eventually, for the gcc 15 release it seems safer to disable clang::musttail, and only keep gnu::musttail. That means that programs that use __has_c_attribute to check for clang::musttail must opt-in explicitly. Reported-by: Sam James gcc/c/ChangeLog: PR ipa/119376 * c-parser.cc (c_parser_handle_musttail): Drop clang namespace check. gcc/cp/ChangeLog: PR ipa/119376 * parser.cc (cp_parser_jump_statement): Drop clang namespace check. gcc/ChangeLog: PR ipa/119376 * doc/extend.texi: Drop clang::musttail reference. gcc/testsuite/ChangeLog: PR ipa/119376 * c-c++-common/musttail23.c: Don't use clang::musttail * c-c++-common/musttail24.c: Dito. * c-c++-common/musttail3.c: Dito. * g++.dg/musttail14.C: Dito. --- gcc/c/c-parser.cc | 5 ----- gcc/cp/parser.cc | 6 ------ gcc/doc/extend.texi | 2 +- gcc/testsuite/c-c++-common/musttail23.c | 10 +++++----- gcc/testsuite/c-c++-common/musttail24.c | 6 ------ gcc/testsuite/c-c++-common/musttail3.c | 6 +++--- gcc/testsuite/g++.dg/musttail14.C | 4 ++-- 7 files changed, 11 insertions(+), 28 deletions(-) diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index d49d5c58659..79654448aca 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -7409,11 +7409,6 @@ c_parser_handle_musttail (c_parser *parser, tree std_attrs, attr_state &attr) std_attrs = remove_attribute ("gnu", "musttail", std_attrs); attr.musttail_p = true; } - if (lookup_attribute ("clang", "musttail", std_attrs)) - { - std_attrs = remove_attribute ("clang", "musttail", std_attrs); - attr.musttail_p = true; - } } return std_attrs; } diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 2fb1dc5992d..da7700b55c6 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -15342,12 +15342,6 @@ cp_parser_jump_statement (cp_parser* parser, tree &std_attrs) musttail_p = true; std_attrs = remove_attribute ("gnu", "musttail", std_attrs); } - /* Support this for compatibility. */ - if (lookup_attribute ("clang", "musttail", std_attrs)) - { - musttail_p = true; - std_attrs = remove_attribute ("clang", "musttail", std_attrs); - } tree ret_expr = expr; if (ret_expr && TREE_CODE (ret_expr) == TARGET_EXPR) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index b919df91464..50f95e968ff 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -10241,7 +10241,7 @@ have to optimize it to just @code{return 42 + 42;}. @cindex @code{musttail} statement attribute @item musttail -The @code{gnu::musttail} or @code{clang::musttail} standard attribute +The @code{gnu::musttail} standard attribute or @code{musttail} GNU attribute can be applied to a @code{return} statement with a return-value expression that is a function call. It asserts that the call must be a tail call that does not allocate extra stack space, so it is diff --git a/gcc/testsuite/c-c++-common/musttail23.c b/gcc/testsuite/c-c++-common/musttail23.c index d2ba70b0325..1ceab116512 100644 --- a/gcc/testsuite/c-c++-common/musttail23.c +++ b/gcc/testsuite/c-c++-common/musttail23.c @@ -19,10 +19,10 @@ foo (int x) [[gnu::musttail (1, "", 3)]] return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */ /* { dg-error "expected" "" { target c } .-1 } */ if (x == 3) - [[clang::musttail (1)]] return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */ + [[gnu::musttail (1)]] return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */ /* { dg-error "expected" "" { target c } .-1 } */ if (x == 4) - [[clang::musttail (1, "", 3)]] return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */ + [[gnu::musttail (1, "", 3)]] return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */ /* { dg-error "expected" "" { target c } .-1 } */ if (x == 5) __attribute__((fallthrough, musttail)) return bar (); /* { dg-warning "attribute 'musttail' mixed with other attributes on 'return' statement" "" { target c } } */ @@ -32,14 +32,14 @@ foo (int x) [[fallthrough]] [[gnu::musttail]] return bar (); /* { dg-warning "'fallthrough' attribute ignored" "" { target c } } */ /* { dg-warning "attributes at the beginning of statement are ignored" "" { target c++ } .-1 } */ if (x == 7) - [[clang::musttail, fallthrough]] return bar (); /* { dg-warning "'fallthrough' attribute ignored" "" { target c } } */ + [[gnu::musttail, fallthrough]] return bar (); /* { dg-warning "'fallthrough' attribute ignored" "" { target c } } */ /* { dg-warning "attributes at the beginning of statement are ignored" "" { target c++ } .-1 } */ if (x == 8) __attribute__((musttail, musttail)) return bar (); if (x == 9) [[gnu::musttail, gnu::musttail]] return bar (); if (x == 10) - [[clang::musttail]] [[clang::musttail]] return bar (); + [[gnu::musttail]] [[gnu::musttail]] return bar (); if (x == 11) - [[clang::musttail]] [[gnu::musttail]] return bar (); + [[gnu::musttail]] [[gnu::musttail]] return bar (); } diff --git a/gcc/testsuite/c-c++-common/musttail24.c b/gcc/testsuite/c-c++-common/musttail24.c index 10c2d3f188d..26b8dbfb4c8 100644 --- a/gcc/testsuite/c-c++-common/musttail24.c +++ b/gcc/testsuite/c-c++-common/musttail24.c @@ -8,14 +8,8 @@ #if !__has_cpp_attribute (gnu::musttail) #error missing gnu::musttail attribute #endif -#if !__has_cpp_attribute (clang::musttail) -#error missing clang::musttail attribute -#endif #else #if !__has_c_attribute (gnu::musttail) #error missing gnu::musttail attribute #endif -#if !__has_c_attribute (clang::musttail) -#error missing clang::musttail attribute -#endif #endif diff --git a/gcc/testsuite/c-c++-common/musttail3.c b/gcc/testsuite/c-c++-common/musttail3.c index 7499fd6460b..daedca28852 100644 --- a/gcc/testsuite/c-c++-common/musttail3.c +++ b/gcc/testsuite/c-c++-common/musttail3.c @@ -11,7 +11,7 @@ struct str cstruct (int x) { if (x < 10) - [[clang::musttail]] return cstruct (x + 1); + [[gnu::musttail]] return cstruct (x + 1); return ((struct str){ x, 0 }); } @@ -19,11 +19,11 @@ int foo (int x) { if (x < 10) - [[clang::musttail]] return foo2 (x, 29); + [[gnu::musttail]] return foo2 (x, 29); if (x < 100) { int k = foo (x + 1); - [[clang::musttail]] return k; /* { dg-error "cannot tail-call: " } */ + [[gnu::musttail]] return k; /* { dg-error "cannot tail-call: " } */ } return x; } diff --git a/gcc/testsuite/g++.dg/musttail14.C b/gcc/testsuite/g++.dg/musttail14.C index 810b45546d6..e4764a3bc03 100644 --- a/gcc/testsuite/g++.dg/musttail14.C +++ b/gcc/testsuite/g++.dg/musttail14.C @@ -58,8 +58,8 @@ garply (int x) case 3: __attribute__(()) [[gnu::musttail]] __attribute__(()) [[]] __attribute__(()) return qux (45); case 4: - [[]] __attribute__(()) [[clang::musttail]] __attribute__(()) [[]] return corge (46); + [[]] __attribute__(()) [[gnu::musttail]] __attribute__(()) [[]] return corge (46); default: - __attribute__(()) [[clang::musttail]] __attribute__(()) [[]] __attribute__(()) return freddy (47); + __attribute__(()) [[gnu::musttail]] __attribute__(()) [[]] __attribute__(()) return freddy (47); } } -- 2.47.1