On 5/14/24 19:23, Andi Kleen wrote:
You need a template testcase; I expect it doesn't work in templates with the
current patch.  It's probably enough to copy it in tsubst_expr where we
currently propagate CALL_EXPR_OPERATOR_SYNTAX.

I tried it with the appended test case, everything seems to work without
changes.

Does it cover the cases you were concerned about?

Not fully; this testcase doesn't seem to check for errors if tail-call
fails, only whether the syntax is accepted.  So it would pass if the
attribute were simply ignored.

Okay I'm not clear how I would do that. Pattern match the assembler
in a target specific test case? From looking at the assembler output
everything got tail converted.

Write a testcase where the tail-call optimization can't happen, perhaps because the caller and callee disagree on return type:

int f();

double h() { [[gnu::musttail]] return f(); } // error

template <class T>
T g() { [[gnu::musttail]] return f(); }

int main()
{
  g<int>();
  g<double>(); // should error, but doesn't with v6 patch set
}

Jason

Reply via email to