Skip to content

Commit ba90e46

Browse files
committed
comments
1 parent 7ce5bb7 commit ba90e46

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ AST Dumping Potentially Breaking Changes
6262
Clang Frontend Potentially Breaking Changes
6363
-------------------------------------------
6464

65+
- The ``-Wglobal-constructors`` flag now applies to ``[[gnu::constructor]]`` and
66+
``[[gnu::destructor]]`` attributes.
67+
6568
Clang Python Bindings Potentially Breaking Changes
6669
--------------------------------------------------
6770

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)