Skip to content

Commit

Permalink
Fix cheerp check for function addr taken in case the operand is not a…
Browse files Browse the repository at this point in the history
… function
  • Loading branch information
yuri91 authored and Maqrkk committed Sep 17, 2024
1 parent 59309ae commit 874b38c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,19 +525,21 @@ ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, bool Diagnose) {
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E)) {
NamedDecl* D = DR->getFoundDecl();
FunctionDecl* Callee = isa<FunctionTemplateDecl>(D) ?
cast<FunctionTemplateDecl>(D)->getTemplatedDecl() :
cast<FunctionDecl>(D);
// Overloaded operators end up here when called, but not when their address is taken,
// because they require the `&` in front of them
bool oper = Callee->isOverloadedOperator();
if (!oper && Caller->hasAttr<GenericJSAttr>() && Callee->hasAttr<AsmJSAttr>()) {
Diag(E->getExprLoc(), diag::err_cheerp_wrong_function_addr)
<< Callee << Callee->getAttr<AsmJSAttr>()
<< Caller << Caller->getAttr<GenericJSAttr>();
} else if (!oper && Caller->hasAttr<AsmJSAttr>() && Callee->hasAttr<GenericJSAttr>()) {
Diag(E->getExprLoc(), diag::err_cheerp_wrong_function_addr)
<< Callee << Callee->getAttr<GenericJSAttr>()
<< Caller << Caller->getAttr<AsmJSAttr>();
cast<FunctionTemplateDecl>(D)->getTemplatedDecl() :
isa<FunctionDecl>(D)? cast<FunctionDecl>(D) : nullptr;
if (Callee) {
// Overloaded operators end up here when called, but not when their address is taken,
// because they require the `&` in front of them
bool oper = Callee->isOverloadedOperator();
if (!oper && Caller->hasAttr<GenericJSAttr>() && Callee->hasAttr<AsmJSAttr>()) {
Diag(E->getExprLoc(), diag::err_cheerp_wrong_function_addr)
<< Callee << Callee->getAttr<AsmJSAttr>()
<< Caller << Caller->getAttr<GenericJSAttr>();
} else if (!oper && Caller->hasAttr<AsmJSAttr>() && Callee->hasAttr<GenericJSAttr>()) {
Diag(E->getExprLoc(), diag::err_cheerp_wrong_function_addr)
<< Callee << Callee->getAttr<GenericJSAttr>()
<< Caller << Caller->getAttr<AsmJSAttr>();
}
}
}
}
Expand Down

0 comments on commit 874b38c

Please sign in to comment.