[clang] Diagnose problematic uses of constructor/destructor attribute (PR #67360)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 25 13:22:08 PDT 2023
================
@@ -2352,26 +2352,61 @@ static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL));
}
-static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
- uint32_t priority = ConstructorAttr::DefaultPriority;
+static bool diagnoseInvalidPriority(Sema &S, uint32_t Priority,
+ const ParsedAttr &A,
+ SourceLocation PriorityLoc) {
+ // Only perform the priority check if the attribute is outside of a system
+ // header. Values <= 100 are reserved for the implementation, and libc++
+ // benefits from being able to specify values in that range.
+ if ((Priority < 101 || Priority > 65535) &&
+ !S.getSourceManager().isInSystemHeader(A.getLoc())) {
+ S.Diag(A.getLoc(), diag::err_attribute_argument_out_of_range)
+ << PriorityLoc << A << 101 << 65535;
----------------
cor3ntin wrote:
Where does `65535` comes from? GCC compat?
https://github.com/llvm/llvm-project/pull/67360
More information about the cfe-commits
mailing list