https://gcc.gnu.org/g:29eb6f8f41e0530f7ecb93cb66d3a35e0344bc1d

commit r15-7646-g29eb6f8f41e0530f7ecb93cb66d3a35e0344bc1d
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Fri Feb 14 15:28:32 2025 +0000

    libstdc++: Remove workaround for reserved init_priority warnings
    
    Since r15-7511-g4e7f74225116e7 we can disable the warnings for using a
    reserved priority using a diagnostic pragma. That means we no longer
    need to put globals using that attribute into separate files that get
    included.
    
    This replaces the two uses of such separate files by moving the variable
    definition into the source file and adding the diagnostic pragma.
    
    libstdc++-v3/ChangeLog:
    
            * src/c++17/memory_resource.cc (default_res): Define here
            instead of including default_resource.h.
            * src/c++98/globals_io.cc (__ioinit): Define here instead of
            including ios_base_init.h.
            * src/c++17/default_resource.h: Removed.
            * src/c++98/ios_base_init.h: Removed.

Diff:
---
 libstdc++-v3/src/c++17/default_resource.h | 15 ---------------
 libstdc++-v3/src/c++17/memory_resource.cc |  5 ++++-
 libstdc++-v3/src/c++98/globals_io.cc      | 11 ++++++++++-
 libstdc++-v3/src/c++98/ios_base_init.h    | 13 -------------
 4 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/libstdc++-v3/src/c++17/default_resource.h 
b/libstdc++-v3/src/c++17/default_resource.h
deleted file mode 100644
index f8d03d7d3bca..000000000000
--- a/libstdc++-v3/src/c++17/default_resource.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// This is only in a header so we can use the system_header pragma,
-// to suppress the warning caused by using a reserved init_priority.
-#pragma GCC system_header
-
-#ifndef _GLIBCXX_HAS_GTHREADS
-# error "This file should not be included for this build"
-#elif ATOMIC_POINTER_LOCK_FREE == 2
-# error "This file should not be included for this build"
-#elif defined __GTHREAD_MUTEX_INIT
-# error "This file should not be included for this build"
-#endif
-
-struct {
-  atomic_mem_res obj = &newdel_res.obj;
-} default_res __attribute__ ((init_priority (100)));
diff --git a/libstdc++-v3/src/c++17/memory_resource.cc 
b/libstdc++-v3/src/c++17/memory_resource.cc
index 2b6bfbd4dd33..0e984f27b827 100644
--- a/libstdc++-v3/src/c++17/memory_resource.cc
+++ b/libstdc++-v3/src/c++17/memory_resource.cc
@@ -149,7 +149,10 @@ namespace pmr
 #ifdef _GLIBCXX_ATOMIC_MEM_RES_CAN_BE_CONSTANT_INITIALIZED
     __constinit constant_init<atomic_mem_res> default_res{&newdel_res.obj};
 #else
-# include "default_resource.h"
+# pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
+    struct {
+      atomic_mem_res obj = &newdel_res.obj;
+    } default_res __attribute__ ((init_priority (100)));
 #endif
   } // namespace
 
diff --git a/libstdc++-v3/src/c++98/globals_io.cc 
b/libstdc++-v3/src/c++98/globals_io.cc
index 6dc6bf40fe27..e30edf7eae2f 100644
--- a/libstdc++-v3/src/c++98/globals_io.cc
+++ b/libstdc++-v3/src/c++98/globals_io.cc
@@ -69,7 +69,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   fake_wostream wclog;
 #endif
 
-#include "ios_base_init.h"
+// If the target supports init priorities, set up a static object in the
+// compiled library to perform the <iostream> initialization once and
+// sufficiently early (so that it happens before any other global
+// constructor when statically linking with libstdc++.a), instead of
+// doing so in (each TU that includes) <iostream>.
+// This needs to be done in the same TU that defines the stream objects.
+#if _GLIBCXX_USE_INIT_PRIORITY_ATTRIBUTE
+#pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
+static ios_base::Init __ioinit __attribute__((init_priority(90)));
+#endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
diff --git a/libstdc++-v3/src/c++98/ios_base_init.h 
b/libstdc++-v3/src/c++98/ios_base_init.h
deleted file mode 100644
index f7edfc846258..000000000000
--- a/libstdc++-v3/src/c++98/ios_base_init.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// This is only in a header so we can use the system_header pragma,
-// to suppress the warning caused by using a reserved init_priority.
-#pragma GCC system_header
-
-// If the target supports init priorities, set up a static object in the
-// compiled library to perform the <iostream> initialization once and
-// sufficiently early (so that it happens before any other global
-// constructor when statically linking with libstdc++.a), instead of
-// doing so in (each TU that includes) <iostream>.
-// This needs to be done in the same TU that defines the stream objects.
-#if _GLIBCXX_USE_INIT_PRIORITY_ATTRIBUTE
-static ios_base::Init __ioinit __attribute__((init_priority(90)));
-#endif

Reply via email to