Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cheerp check for function addr taken in case the operand is not a… #250

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all 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
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
Loading