]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: use -Wprio-ctor-dtor for attribute init_priority
authorJason Merrill <jason@redhat.com>
Wed, 12 Feb 2025 22:21:25 +0000 (23:21 +0100)
committerJason Merrill <jason@redhat.com>
Thu, 13 Feb 2025 21:53:38 +0000 (22:53 +0100)
gcc/cp/ChangeLog:

* tree.cc (handle_init_priority_attribute): Use OPT_prio_ctor_dtor.

gcc/testsuite/ChangeLog:

* g++.dg/special/initp1.C: Test disabling -Wprio-ctor-dtor.

gcc/cp/tree.cc
gcc/testsuite/g++.dg/special/initp1.C

index 79bc74fa2b7ae141a067c1f0472e3c5b27c396d1..bf84fb6bcec4d89ede5ce5635a2be7d0f1e2c55d 100644 (file)
@@ -5335,7 +5335,8 @@ handle_init_priority_attribute (tree* node,
       && !in_system_header_at (input_location))
     {
       warning
-       (0, "requested %<init_priority%> %i is reserved for internal use",
+       (OPT_Wprio_ctor_dtor,
+        "requested %<init_priority%> %i is reserved for internal use",
         pri);
     }
 
index 4a539a5a4bdd851a33fcb6b653741c4411450428..ef88ca970b88043bc5c9043932343a824cf435ae 100644 (file)
@@ -30,9 +30,9 @@ Two hoo[ 3 ] = {
     Two( 15, 16 )
 };
 
-Two coo[ 3 ] __attribute__((init_priority(1000)));
-
-Two koo[ 3 ] __attribute__((init_priority(1000))) = {
+Two coo[ 3 ] __attribute__((init_priority(10))); // { dg-warning "reserved" }
+#pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
+Two koo[ 3 ] __attribute__((init_priority(10))) = {
     Two( 21, 22 ),
     Two( 23, 24 ),
     Two( 25, 26 )