@@ -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.
@@ -8291,3 +8281,27 @@ void Sema::redelayDiagnostics(DelayedDiagnosticPool &pool) {
82918281 assert (curPool && " re-emitting in undelayed context not supported" );
82928282 curPool->steal (pool);
82938283}
8284+
8285+ void Sema::ActOnCleanupAttr (Expr *E, Decl *D, const Attr *A) {
8286+ FunctionDecl *FD = nullptr ;
8287+ DeclarationNameInfo NI;
8288+ CleanupAttr *Attr = D->getAttr <CleanupAttr>();
8289+
8290+ // Obtains the FunctionDecl that was found when handling the attribute
8291+ // earlier.
8292+ FD = Attr->getFunctionDecl ();
8293+ NI = FD->getNameInfo ();
8294+
8295+ // We're currently more strict than GCC about what function types we accept.
8296+ // If this ever proves to be a problem it should be easy to fix.
8297+ QualType Ty = this ->Context .getPointerType (cast<VarDecl>(D)->getType ());
8298+ QualType ParamTy = FD->getParamDecl (0 )->getType ();
8299+ if (!this ->IsAssignConvertCompatible (this ->CheckAssignmentConstraints (
8300+ FD->getParamDecl (0 )->getLocation (), ParamTy, Ty))) {
8301+ this ->Diag (Attr->getArgLoc (),
8302+ diag::err_attribute_cleanup_func_arg_incompatible_type)
8303+ << NI.getName () << ParamTy << Ty;
8304+ D->dropAttr <CleanupAttr>();
8305+ return ;
8306+ }
8307+ }
0 commit comments