@@ -2138,6 +2138,8 @@ static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
21382138 if (AL.getNumArgs () &&
21392139 !S.checkUInt32Argument (AL, AL.getArgAsExpr (0 ), priority))
21402140 return ;
2141+ S.Diag (D->getLocation (), diag::warn_global_constructor)
2142+ << D->getSourceRange ();
21412143
21422144 D->addAttr (::new (S.Context ) ConstructorAttr (S.Context , AL, priority));
21432145}
@@ -2147,6 +2149,7 @@ static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
21472149 if (AL.getNumArgs () &&
21482150 !S.checkUInt32Argument (AL, AL.getArgAsExpr (0 ), priority))
21492151 return ;
2152+ S.Diag (D->getLocation (), diag::warn_global_destructor) << D->getSourceRange ();
21502153
21512154 D->addAttr (::new (S.Context ) DestructorAttr (S.Context , AL, priority));
21522155}
@@ -7727,17 +7730,6 @@ void Sema::ProcessDeclAttributeList(
77277730 D->setInvalidDecl ();
77287731 }
77297732
7730- // Warn on global constructors and destructors created by attributes.
7731- if (D->hasAttr <ConstructorAttr>() &&
7732- !getDiagnostics ().isIgnored (diag::warn_global_constructor,
7733- D->getLocation ()))
7734- Diag (D->getLocation (), diag::warn_global_constructor)
7735- << D->getSourceRange ();
7736- if (D->hasAttr <DestructorAttr>() &&
7737- !getDiagnostics ().isIgnored (diag::warn_global_destructor,
7738- D->getLocation ()))
7739- Diag (D->getLocation (), diag::warn_global_destructor) << D->getSourceRange ();
7740-
77417733 // Do this check after processing D's attributes because the attribute
77427734 // objc_method_family can change whether the given method is in the init
77437735 // family, and it can be applied after objc_designated_initializer. This is a
0 commit comments