https://gcc.gnu.org/g:4e7f74225116e76caa65c5ce2815c2714343dfbc

commit r15-7511-g4e7f74225116e76caa65c5ce2815c2714343dfbc
Author: Jason Merrill <ja...@redhat.com>
Date:   Wed Feb 12 23:21:25 2025 +0100

    c++: use -Wprio-ctor-dtor for attribute init_priority
    
    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.

Diff:
---
 gcc/cp/tree.cc                        | 3 ++-
 gcc/testsuite/g++.dg/special/initp1.C | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 79bc74fa2b7a..bf84fb6bcec4 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -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);
     }
 
diff --git a/gcc/testsuite/g++.dg/special/initp1.C 
b/gcc/testsuite/g++.dg/special/initp1.C
index 4a539a5a4bdd..ef88ca970b88 100644
--- a/gcc/testsuite/g++.dg/special/initp1.C
+++ b/gcc/testsuite/g++.dg/special/initp1.C
@@ -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 )

Reply via email to