On Tue, Jul 16, 2024 at 02:51:13PM -0400, Jason Merrill wrote:
> On 7/16/24 12:18 PM, Andi Kleen wrote:
> > On Tue, Jul 16, 2024 at 11:17:14AM -0400, Jason Merrill wrote:
> > > On 7/16/24 11:15 AM, Andi Kleen wrote:
> > > > > In the adjusted test it looks like the types of f and g match, so I
> > > > > wouldn't
> > > > > expect an error.
> > > >
> > > > Good point! Missing the forest for the trees.
> > > >
> > > > Anyways are the C++ patches ok with this change?
> > >
> > > I'm still looking for a test which does error because the types are
> > > different.
> >
> > Like this?
>
> Where the called function returns C and the callee function does not.
In this case the attribute seems to get lost and it succeeds.
diff --git a/gcc/testsuite/g++.dg/musttail10.C
b/gcc/testsuite/g++.dg/musttail10.C
index e454a6238a06..39f0ec38253d 100644
--- a/gcc/testsuite/g++.dg/musttail10.C
+++ b/gcc/testsuite/g++.dg/musttail10.C
@@ -28,12 +28,18 @@ class C
public:
C(double x) : x(x) {}
~C() { asm("":::"memory"); }
+ operator int() { return x; }
};
+template <class T>
+__attribute__((noinline, noclone, noipa))
+T g5() { [[gnu::musttail]] return f<C>(); } /* { dg-error "cannot tail-call" }
*/
+
int main()
{
g1<int>();
g2<double>();
g3<C>();
g4<int>();
+ g5<int>();
}