Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -3134,6 +3134,9 @@ def warn_function_attribute_ignored_in_stmt : Warning<
"use '%0' on statements">,
InGroup<IgnoredAttributes>;

def err_musttail_conflicts_with_not_tail_called : Error<
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reuse err_musttail_mismatch instead?

"%0 musttail conflicts with not tail called"
>;
def err_musttail_needs_trivial_args : Error<
"tail call requires that the return value, all parameters, and any "
"temporaries created by the expression are trivially destructible">;
Expand Down
8 changes: 8 additions & 0 deletions clang/lib/Sema/SemaStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,14 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr &MTA) {
return false;
}

if (const FunctionDecl *CalleeDecl = CE->getDirectCallee()) {
if (CalleeDecl->hasAttr<NotTailCalledAttr>()) {
Diag(St->getBeginLoc(), diag::err_musttail_conflicts_with_not_tail_called)
<< &MTA;
return false;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (const FunctionDecl *CalleeDecl = CE->getDirectCallee()) {
if (CalleeDecl->hasAttr<NotTailCalledAttr>()) {
Diag(St->getBeginLoc(), diag::err_musttail_conflicts_with_not_tail_called)
<< &MTA;
return false;
}
}
if (const FunctionDecl *CalleeDecl = CE->getDirectCallee();
CalleeDecl && CalleeDecl->hasAttr<NotTailCalledAttr>()) {
Diag(St->getBeginLoc(), diag::err_musttail_conflicts_with_not_tail_called)
<< &MTA;
return false;
}


if (const auto *EWC = dyn_cast<ExprWithCleanups>(E)) {
if (EWC->cleanupsHaveSideEffects()) {
Diag(St->getBeginLoc(), diag::err_musttail_needs_trivial_args) << &MTA;
Expand Down