@@ -5921,7 +5921,6 @@ void Sema::ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(
5921
5921
continue;
5922
5922
5923
5923
QualType UDeclTy = UDecl->getType();
5924
- // TODO: Verify types for templates eventually.
5925
5924
if (!UDeclTy->isDependentType()) {
5926
5925
QualType NewType = Context.mergeFunctionTypes(
5927
5926
FType, UDeclTy, /* OfBlockPointer */ false,
@@ -6009,6 +6008,8 @@ ExprResult Sema::ActOnOpenMPCall(ExprResult Call, Scope *Scope,
6009
6008
TargetOMPContext OMPCtx(Context, std::move(DiagUnknownTrait),
6010
6009
getCurFunctionDecl());
6011
6010
6011
+ QualType CalleeFnType = CalleeFnDecl->getType();
6012
+
6012
6013
SmallVector<Expr *, 4> Exprs;
6013
6014
SmallVector<VariantMatchInfo, 4> VMIs;
6014
6015
while (CalleeFnDecl) {
@@ -6061,8 +6062,19 @@ ExprResult Sema::ActOnOpenMPCall(ExprResult Call, Scope *Scope,
6061
6062
}
6062
6063
NewCall = BuildCallExpr(Scope, BestExpr, LParenLoc, ArgExprs, RParenLoc,
6063
6064
ExecConfig);
6064
- if (NewCall.isUsable())
6065
- break;
6065
+ if (NewCall.isUsable()) {
6066
+ if (CallExpr *NCE = dyn_cast<CallExpr>(NewCall.get())) {
6067
+ FunctionDecl *NewCalleeFnDecl = NCE->getDirectCallee();
6068
+ QualType NewType = Context.mergeFunctionTypes(
6069
+ CalleeFnType, NewCalleeFnDecl->getType(),
6070
+ /* OfBlockPointer */ false,
6071
+ /* Unqualified */ false, /* AllowCXX */ true);
6072
+ if (!NewType.isNull())
6073
+ break;
6074
+ // Don't use the call if the function type was not compatible.
6075
+ NewCall = nullptr;
6076
+ }
6077
+ }
6066
6078
}
6067
6079
6068
6080
VMIs.erase(VMIs.begin() + BestIdx);
0 commit comments