]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Remove workaround for reserved init_priority warnings
authorJonathan Wakely <jwakely@redhat.com>
Fri, 14 Feb 2025 15:28:32 +0000 (15:28 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 20 Feb 2025 11:33:41 +0000 (11:33 +0000)
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.

libstdc++-v3/src/c++17/default_resource.h [deleted file]
libstdc++-v3/src/c++17/memory_resource.cc
libstdc++-v3/src/c++98/globals_io.cc
libstdc++-v3/src/c++98/ios_base_init.h [deleted file]

diff --git a/libstdc++-v3/src/c++17/default_resource.h b/libstdc++-v3/src/c++17/default_resource.h
deleted file mode 100644 (file)
index f8d03d7..0000000
+++ /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)));
index 2b6bfbd4dd33c50f19b5c7e98e760297759f9d13..0e984f27b8273862f7d67cb34ada49a63c698eec 100644 (file)
@@ -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
 
index 6dc6bf40fe27f292f7bb9e07f74bca4a3dc703ac..e30edf7eae2fcc9bf35b96ab0201c81ca026e3c6 100644 (file)
@@ -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 (file)
index f7edfc8..0000000
+++ /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