@@ -3511,16 +3511,6 @@ static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
35113511 return ;
35123512 }
35133513
3514- // We're currently more strict than GCC about what function types we accept.
3515- // If this ever proves to be a problem it should be easy to fix.
3516- QualType Ty = S.Context .getPointerType (cast<VarDecl>(D)->getType ());
3517- QualType ParamTy = FD->getParamDecl (0 )->getType ();
3518- if (!S.IsAssignConvertCompatible (S.CheckAssignmentConstraints (
3519- FD->getParamDecl (0 )->getLocation (), ParamTy, Ty))) {
3520- S.Diag (Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
3521- << NI.getName () << ParamTy << Ty;
3522- return ;
3523- }
35243514 VarDecl *VD = cast<VarDecl>(D);
35253515 // Create a reference to the variable declaration. This is a fake/dummy
35263516 // reference.
@@ -8311,3 +8301,27 @@ void Sema::redelayDiagnostics(DelayedDiagnosticPool &pool) {
83118301 assert (curPool && " re-emitting in undelayed context not supported" );
83128302 curPool->steal (pool);
83138303}
8304+
8305+ void Sema::ActOnCleanupAttr (Expr *E, Decl *D, const Attr *A) {
8306+ FunctionDecl *FD = nullptr ;
8307+ DeclarationNameInfo NI;
8308+ CleanupAttr *Attr = D->getAttr <CleanupAttr>();
8309+
8310+ // Obtains the FunctionDecl that was found when handling the attribute
8311+ // earlier.
8312+ FD = Attr->getFunctionDecl ();
8313+ NI = FD->getNameInfo ();
8314+
8315+ // We're currently more strict than GCC about what function types we accept.
8316+ // If this ever proves to be a problem it should be easy to fix.
8317+ QualType Ty = this ->Context .getPointerType (cast<VarDecl>(D)->getType ());
8318+ QualType ParamTy = FD->getParamDecl (0 )->getType ();
8319+ if (!this ->IsAssignConvertCompatible (this ->CheckAssignmentConstraints (
8320+ FD->getParamDecl (0 )->getLocation (), ParamTy, Ty))) {
8321+ this ->Diag (Attr->getArgLoc (),
8322+ diag::err_attribute_cleanup_func_arg_incompatible_type)
8323+ << NI.getName () << ParamTy << Ty;
8324+ D->dropAttr <CleanupAttr>();
8325+ return ;
8326+ }
8327+ }
0 commit comments