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.
---

Tested x86_64-linux. Pushed to trunk.

 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(-)
 delete mode 100644 libstdc++-v3/src/c++17/default_resource.h
 delete mode 100644 libstdc++-v3/src/c++98/ios_base_init.h

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 f8d03d7d3bc..00000000000
--- 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 2b6bfbd4dd3..0e984f27b82 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 6dc6bf40fe2..e30edf7eae2 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 f7edfc84625..00000000000
--- 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
-- 
2.48.1

Reply via email to