commit:     ff1ba90cc398eb99d4e5514e0f0332c2105c5872
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 25 02:32:13 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Mar 25 02:32:13 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=ff1ba90c

Revert "15.0.0: drop musttail workaround"

This reverts commit ebea0f72bf6bcc9c53105a689beb6263047b35c8.

More issues.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../77_all_PR119376-Disable-clang-musttail.patch   | 200 +++++++++++++++++++++
 15.0.0/gentoo/README.history                       |   1 +
 2 files changed, 201 insertions(+)

diff --git a/15.0.0/gentoo/77_all_PR119376-Disable-clang-musttail.patch 
b/15.0.0/gentoo/77_all_PR119376-Disable-clang-musttail.patch
new file mode 100644
index 0000000..3af4ab4
--- /dev/null
+++ b/15.0.0/gentoo/77_all_PR119376-Disable-clang-musttail.patch
@@ -0,0 +1,200 @@
+https://inbox.sourceware.org/gcc-patches/20250320013102.1336516-1-a...@firstfloor.org/
+
+From 592f60bef27cb60ea6405ca8603449fc4d92e640 Mon Sep 17 00:00:00 2001
+Message-ID: 
<592f60bef27cb60ea6405ca8603449fc4d92e640.1742435883.git....@gentoo.org>
+From: Andi Kleen <a...@gcc.gnu.org>
+Date: Wed, 19 Mar 2025 18:31:02 -0700
+Subject: [PATCH] PR119376: Disable clang musttail
+
+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 d49d5c58659f..79654448acaa 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 2fb1dc5992d4..da7700b55c64 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 b919df914648..50f95e968ff9 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 d2ba70b03250..1ceab1165129 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 10c2d3f188d8..26b8dbfb4c8e 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 7499fd6460b4..daedca28852a 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 810b45546d61..e4764a3bc03b 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.49.0
+

diff --git a/15.0.0/gentoo/README.history b/15.0.0/gentoo/README.history
index 92b88c3..2a32843 100644
--- a/15.0.0/gentoo/README.history
+++ b/15.0.0/gentoo/README.history
@@ -1,5 +1,6 @@
 49     ????
 
+       + 77_all_PR119376-Disable-clang-musttail.patch
        + 80_all_PR119428.patch
 
 48     24 March 2025

Reply via email to