On 7/8/24 12:56 PM, Andi Kleen wrote:
diff --git a/gcc/testsuite/g++.dg/musttail10.C 
b/gcc/testsuite/g++.dg/musttail10.C
new file mode 100644
index 000000000000..9b7043b8a306
--- /dev/null
+++ b/gcc/testsuite/g++.dg/musttail10.C
@@ -0,0 +1,34 @@
+/* { dg-do compile { target { tail_call } } } */
+/* { dg-options "-std=gnu++11" } */
+/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
+
+int f();
+
+double h() { [[gnu::musttail]] return f(); } /* { dg-error "cannot tail-call" 
} */
+
+template <class T>
+__attribute__((noinline, noclone, noipa))
+T g1() { [[gnu::musttail]] return f(); } /* { dg-error "target is not able" "" 
{ target powerpc*-*-* } } */
+
+template <class T>
+__attribute__((noinline, noclone, noipa))
+T g2() { [[gnu::musttail]] return f(); } /* { dg-error "cannot tail-call" } */
+
+template <class T>
+__attribute__((noinline, noclone, noipa))
+T g3() { [[gnu::musttail]] return f(); } /* { dg-error "cannot tail-call" } */
+
+class C
+{
+  double x;
+public:
+  C(double x) : x(x) {}
+  ~C() { asm("":::"memory"); }
+};
+
+int main()
+{
+  g1<int>();
+  g2<double>();
+  g3<C>();
+}

I had asked for this test to check the case where the function called with [[musttail]] returns a non-trivially-copyable class; the test now includes such a class, but all the [[musttail]] calls are still to a function that returns int.

Jason

Reply via email to