[clang] [clang] Fix `gnu::init_priority` attribute handling for reserved values (PR #121577)

Nikolas Klauser via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 3 07:29:47 PST 2025


================
@@ -3324,6 +3324,9 @@ def err_attribute_argument_out_of_range : Error<
 def err_init_priority_object_attr : Error<
   "can only use 'init_priority' attribute on file-scope definitions "
   "of objects of class type">;
+def warn_init_priority_reserved : Warning<
+  "requested 'init_priority' %0 is reserved for internal use">,
+  InGroup<InitPriorityReserved>;
----------------
philnik777 wrote:

```suggestion
def warn_init_priority_reserved : Warning<
  "requested 'init_priority' %0 is reserved for internal use">,
  InGroup<DiagGroup<"init-priority-reserved">>;
```
Then you don't need to add a named diagnostic group. Also, should we make this an error by default? Very few people should want this to not be diagnosed. Given that it's been a hard error before, I don't think we're impacting any users if we decide to make it an error by default.

https://github.com/llvm/llvm-project/pull/121577


More information about the cfe-commits mailing list