diff mbox series

[RFA] libstdc++: #ifdef out #pragma GCC system_header

Message ID 20240923150656.1255080-1-jason@redhat.com
State New
Headers show
Series [RFA] libstdc++: #ifdef out #pragma GCC system_header | expand

Commit Message

Jason Merrill Sept. 23, 2024, 3:06 p.m. UTC
Tested x86_64-pc-linux-gnu, OK for trunk?

-- 8< --

In r15-3714-gd3a7302ec5985a I added -Wsystem-headers to the libstdc++ build
flags to help catch problems in the library.  This patch takes a different
approach, of disabling the #pragma system_header unless _GLIBCXX_SYSHDR is
defined.  As a result, the testsuites will treat them as non-system-headers
to get better warning coverage during regression testing of both gcc and
libstdc++, not just when building the library.

My rationale for the #ifdef instead of just removing the #pragma is the
three G++ tests that want to test libstdc++ system header behavior, so we
need a way to select it.

This doesn't affect installed libraries, as they get their
system-header status from the lookup path.  But testsuite_flags
--build-includes gives -I directives rather than -isystem.

This patch doesn't change the headers in config/ because I'm not compiling
with most of them, so won't see any warnings that need fixing.  Adjusting
them could happen later, or we can not bother.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (WARN_FLAGS): Remove -Wsystem-headers.
	* configure: Regenerate.
	* include/bits/algorithmfwd.h: #ifdef out #pragma GCC system_header.
	* include/bits/atomic_base.h
	* include/bits/atomic_futex.h
	* include/bits/atomic_timed_wait.h
	* include/bits/atomic_wait.h
	* include/bits/basic_ios.h
	* include/bits/basic_string.h
	* include/bits/boost_concept_check.h
	* include/bits/char_traits.h
	* include/bits/charconv.h
	* include/bits/chrono.h
	* include/bits/chrono_io.h
	* include/bits/codecvt.h
	* include/bits/concept_check.h
	* include/bits/cpp_type_traits.h
	* include/bits/elements_of.h
	* include/bits/enable_special_members.h
	* include/bits/erase_if.h
	* include/bits/forward_list.h
	* include/bits/functional_hash.h
	* include/bits/gslice.h
	* include/bits/gslice_array.h
	* include/bits/hashtable.h
	* include/bits/indirect_array.h
	* include/bits/invoke.h
	* include/bits/ios_base.h
	* include/bits/iterator_concepts.h
	* include/bits/locale_classes.h
	* include/bits/locale_facets.h
	* include/bits/locale_facets_nonio.h
	* include/bits/localefwd.h
	* include/bits/mask_array.h
	* include/bits/max_size_type.h
	* include/bits/memory_resource.h
	* include/bits/memoryfwd.h
	* include/bits/move_only_function.h
	* include/bits/node_handle.h
	* include/bits/ostream_insert.h
	* include/bits/out_ptr.h
	* include/bits/parse_numbers.h
	* include/bits/postypes.h
	* include/bits/quoted_string.h
	* include/bits/range_access.h
	* include/bits/ranges_base.h
	* include/bits/refwrap.h
	* include/bits/sat_arith.h
	* include/bits/semaphore_base.h
	* include/bits/slice_array.h
	* include/bits/std_abs.h
	* include/bits/std_function.h
	* include/bits/std_mutex.h
	* include/bits/std_thread.h
	* include/bits/stl_iterator_base_funcs.h
	* include/bits/stl_iterator_base_types.h
	* include/bits/stl_tree.h
	* include/bits/stream_iterator.h
	* include/bits/streambuf_iterator.h
	* include/bits/stringfwd.h
	* include/bits/this_thread_sleep.h
	* include/bits/unique_lock.h
	* include/bits/uses_allocator_args.h
	* include/bits/utility.h
	* include/bits/valarray_after.h
	* include/bits/valarray_array.h
	* include/bits/valarray_before.h
	* include/bits/version.h
	* include/c_compatibility/fenv.h
	* include/c_compatibility/inttypes.h
	* include/c_compatibility/stdint.h
	* include/decimal/decimal.h
	* include/experimental/bits/net.h
	* include/experimental/bits/shared_ptr.h
	* include/ext/aligned_buffer.h
	* include/ext/alloc_traits.h
	* include/ext/atomicity.h
	* include/ext/concurrence.h
	* include/ext/numeric_traits.h
	* include/ext/pod_char_traits.h
	* include/ext/pointer.h
	* include/ext/stdio_filebuf.h
	* include/ext/stdio_sync_filebuf.h
	* include/ext/string_conversions.h
	* include/ext/type_traits.h
	* include/ext/vstring.h
	* include/ext/vstring_fwd.h
	* include/ext/vstring_util.h
	* include/parallel/algorithmfwd.h
	* include/parallel/numericfwd.h
	* include/tr1/functional_hash.h
	* include/tr1/hashtable.h
	* include/tr1/random.h
	* libsupc++/exception.h
	* libsupc++/hash_bytes.h
	* include/bits/basic_ios.tcc
	* include/bits/basic_string.tcc
	* include/bits/fstream.tcc
	* include/bits/istream.tcc
	* include/bits/locale_classes.tcc
	* include/bits/locale_facets.tcc
	* include/bits/locale_facets_nonio.tcc
	* include/bits/ostream.tcc
	* include/bits/sstream.tcc
	* include/bits/streambuf.tcc
	* include/bits/string_view.tcc
	* include/bits/version.tpl
	* include/experimental/bits/string_view.tcc
	* include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp
	* include/ext/random.tcc
	* include/ext/vstring.tcc
	* include/tr2/bool_set.tcc
	* include/tr2/dynamic_bitset.tcc
	* include/bits/c++config
	* include/c/cassert
	* include/c/cctype
	* include/c/cerrno
	* include/c/cfloat
	* include/c/ciso646
	* include/c/climits
	* include/c/clocale
	* include/c/cmath
	* include/c/csetjmp
	* include/c/csignal
	* include/c/cstdarg
	* include/c/cstddef
	* include/c/cstdio
	* include/c/cstdlib
	* include/c/cstring
	* include/c/ctime
	* include/c/cuchar
	* include/c/cwchar
	* include/c/cwctype
	* include/c_global/cassert
	* include/c_global/ccomplex
	* include/c_global/cctype
	* include/c_global/cerrno
	* include/c_global/cfenv
	* include/c_global/cfloat
	* include/c_global/cinttypes
	* include/c_global/ciso646
	* include/c_global/climits
	* include/c_global/clocale
	* include/c_global/cmath
	* include/c_global/csetjmp
	* include/c_global/csignal
	* include/c_global/cstdalign
	* include/c_global/cstdarg
	* include/c_global/cstdbool
	* include/c_global/cstddef
	* include/c_global/cstdint
	* include/c_global/cstdio
	* include/c_global/cstdlib
	* include/c_global/cstring
	* include/c_global/ctgmath
	* include/c_global/ctime
	* include/c_global/cuchar
	* include/c_global/cwchar
	* include/c_global/cwctype
	* include/c_std/cassert
	* include/c_std/cctype
	* include/c_std/cerrno
	* include/c_std/cfloat
	* include/c_std/ciso646
	* include/c_std/climits
	* include/c_std/clocale
	* include/c_std/cmath
	* include/c_std/csetjmp
	* include/c_std/csignal
	* include/c_std/cstdarg
	* include/c_std/cstddef
	* include/c_std/cstdio
	* include/c_std/cstdlib
	* include/c_std/cstring
	* include/c_std/ctime
	* include/c_std/cuchar
	* include/c_std/cwchar
	* include/c_std/cwctype
	* include/debug/array
	* include/debug/bitset
	* include/debug/deque
	* include/debug/forward_list
	* include/debug/list
	* include/debug/map
	* include/debug/set
	* include/debug/string
	* include/debug/unordered_map
	* include/debug/unordered_set
	* include/debug/vector
	* include/decimal/decimal
	* include/experimental/algorithm
	* include/experimental/any
	* include/experimental/array
	* include/experimental/buffer
	* include/experimental/chrono
	* include/experimental/contract
	* include/experimental/deque
	* include/experimental/executor
	* include/experimental/filesystem
	* include/experimental/forward_list
	* include/experimental/functional
	* include/experimental/internet
	* include/experimental/io_context
	* include/experimental/iterator
	* include/experimental/list
	* include/experimental/map
	* include/experimental/memory
	* include/experimental/memory_resource
	* include/experimental/net
	* include/experimental/netfwd
	* include/experimental/numeric
	* include/experimental/propagate_const
	* include/experimental/ratio
	* include/experimental/regex
	* include/experimental/scope
	* include/experimental/set
	* include/experimental/socket
	* include/experimental/string
	* include/experimental/string_view
	* include/experimental/synchronized_value
	* include/experimental/system_error
	* include/experimental/timer
	* include/experimental/tuple
	* include/experimental/type_traits
	* include/experimental/unordered_map
	* include/experimental/unordered_set
	* include/experimental/vector
	* include/ext/algorithm
	* include/ext/cmath
	* include/ext/functional
	* include/ext/iterator
	* include/ext/memory
	* include/ext/numeric
	* include/ext/random
	* include/ext/rb_tree
	* include/ext/rope
	* include/parallel/algorithm
	* include/std/algorithm
	* include/std/any
	* include/std/array
	* include/std/atomic
	* include/std/barrier
	* include/std/bit
	* include/std/bitset
	* include/std/charconv
	* include/std/chrono
	* include/std/codecvt
	* include/std/complex
	* include/std/concepts
	* include/std/condition_variable
	* include/std/coroutine
	* include/std/deque
	* include/std/execution
	* include/std/expected
	* include/std/filesystem
	* include/std/format
	* include/std/forward_list
	* include/std/fstream
	* include/std/functional
	* include/std/future
	* include/std/generator
	* include/std/iomanip
	* include/std/ios
	* include/std/iosfwd
	* include/std/iostream
	* include/std/istream
	* include/std/iterator
	* include/std/latch
	* include/std/limits
	* include/std/list
	* include/std/locale
	* include/std/map
	* include/std/memory
	* include/std/memory_resource
	* include/std/mutex
	* include/std/numbers
	* include/std/numeric
	* include/std/optional
	* include/std/ostream
	* include/std/print
	* include/std/queue
	* include/std/random
	* include/std/ranges
	* include/std/ratio
	* include/std/regex
	* include/std/scoped_allocator
	* include/std/semaphore
	* include/std/set
	* include/std/shared_mutex
	* include/std/span
	* include/std/spanstream
	* include/std/sstream
	* include/std/stack
	* include/std/stacktrace
	* include/std/stdexcept
	* include/std/streambuf
	* include/std/string
	* include/std/string_view
	* include/std/syncstream
	* include/std/system_error
	* include/std/text_encoding
	* include/std/thread
	* include/std/tuple
	* include/std/type_traits
	* include/std/typeindex
	* include/std/unordered_map
	* include/std/unordered_set
	* include/std/utility
	* include/std/valarray
	* include/std/variant
	* include/std/vector
	* include/std/version
	* include/tr1/array
	* include/tr1/cfenv
	* include/tr1/cinttypes
	* include/tr1/cmath
	* include/tr1/complex
	* include/tr1/cstdbool
	* include/tr1/cstdint
	* include/tr1/cstdio
	* include/tr1/cstdlib
	* include/tr1/cwchar
	* include/tr1/cwctype
	* include/tr1/functional
	* include/tr1/memory
	* include/tr1/random
	* include/tr1/regex
	* include/tr1/tuple
	* include/tr1/type_traits
	* include/tr1/unordered_map
	* include/tr1/unordered_set
	* include/tr1/utility
	* include/tr2/bool_set
	* include/tr2/dynamic_bitset
	* include/tr2/type_traits
	* libsupc++/atomic_lockfree_defines.h
	* libsupc++/compare
	* libsupc++/cxxabi.h
	* libsupc++/cxxabi_forced.h
	* libsupc++/cxxabi_init_exception.h
	* libsupc++/exception
	* libsupc++/initializer_list
	* libsupc++/new
	* libsupc++/typeinfo: Likewise.
	* testsuite/20_util/ratio/operations/ops_overflow_neg.cc
	* testsuite/23_containers/array/tuple_interface/get_neg.cc
	* testsuite/23_containers/vector/cons/destructible_debug_neg.cc
	* testsuite/24_iterators/operations/prev_neg.cc
	* testsuite/ext/type_traits/add_unsigned_floating_neg.cc
	* testsuite/ext/type_traits/add_unsigned_integer_neg.cc
	* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
	* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Adjust
	line numbers.

gcc/testsuite/ChangeLog

	* g++.dg/analyzer/fanalyzer-show-events-in-system-headers-default.C
	* g++.dg/analyzer/fanalyzer-show-events-in-system-headers-no.C
	* g++.dg/diagnostic/disable.C: #define _GLIBCXX_SYSHDR.
---
 libstdc++-v3/include/bits/algorithmfwd.h                    | 2 ++
 libstdc++-v3/include/bits/atomic_base.h                     | 2 ++
 libstdc++-v3/include/bits/atomic_futex.h                    | 2 ++
 libstdc++-v3/include/bits/atomic_timed_wait.h               | 2 ++
 libstdc++-v3/include/bits/atomic_wait.h                     | 2 ++
 libstdc++-v3/include/bits/basic_ios.h                       | 2 ++
 libstdc++-v3/include/bits/basic_string.h                    | 2 ++
 libstdc++-v3/include/bits/boost_concept_check.h             | 2 ++
 libstdc++-v3/include/bits/char_traits.h                     | 2 ++
 libstdc++-v3/include/bits/charconv.h                        | 2 ++
 libstdc++-v3/include/bits/chrono.h                          | 2 ++
 libstdc++-v3/include/bits/chrono_io.h                       | 2 ++
 libstdc++-v3/include/bits/codecvt.h                         | 2 ++
 libstdc++-v3/include/bits/concept_check.h                   | 2 ++
 libstdc++-v3/include/bits/cpp_type_traits.h                 | 2 ++
 libstdc++-v3/include/bits/elements_of.h                     | 2 ++
 libstdc++-v3/include/bits/enable_special_members.h          | 2 ++
 libstdc++-v3/include/bits/erase_if.h                        | 2 ++
 libstdc++-v3/include/bits/forward_list.h                    | 2 ++
 libstdc++-v3/include/bits/functional_hash.h                 | 2 ++
 libstdc++-v3/include/bits/gslice.h                          | 2 ++
 libstdc++-v3/include/bits/gslice_array.h                    | 2 ++
 libstdc++-v3/include/bits/hashtable.h                       | 2 ++
 libstdc++-v3/include/bits/indirect_array.h                  | 2 ++
 libstdc++-v3/include/bits/invoke.h                          | 2 ++
 libstdc++-v3/include/bits/ios_base.h                        | 2 ++
 libstdc++-v3/include/bits/iterator_concepts.h               | 2 ++
 libstdc++-v3/include/bits/locale_classes.h                  | 2 ++
 libstdc++-v3/include/bits/locale_facets.h                   | 2 ++
 libstdc++-v3/include/bits/locale_facets_nonio.h             | 2 ++
 libstdc++-v3/include/bits/localefwd.h                       | 2 ++
 libstdc++-v3/include/bits/mask_array.h                      | 2 ++
 libstdc++-v3/include/bits/max_size_type.h                   | 2 ++
 libstdc++-v3/include/bits/memory_resource.h                 | 2 ++
 libstdc++-v3/include/bits/memoryfwd.h                       | 2 ++
 libstdc++-v3/include/bits/move_only_function.h              | 2 ++
 libstdc++-v3/include/bits/node_handle.h                     | 2 ++
 libstdc++-v3/include/bits/ostream_insert.h                  | 2 ++
 libstdc++-v3/include/bits/out_ptr.h                         | 2 ++
 libstdc++-v3/include/bits/parse_numbers.h                   | 2 ++
 libstdc++-v3/include/bits/postypes.h                        | 2 ++
 libstdc++-v3/include/bits/quoted_string.h                   | 2 ++
 libstdc++-v3/include/bits/range_access.h                    | 2 ++
 libstdc++-v3/include/bits/ranges_base.h                     | 2 ++
 libstdc++-v3/include/bits/refwrap.h                         | 2 ++
 libstdc++-v3/include/bits/sat_arith.h                       | 2 ++
 libstdc++-v3/include/bits/semaphore_base.h                  | 2 ++
 libstdc++-v3/include/bits/slice_array.h                     | 2 ++
 libstdc++-v3/include/bits/std_abs.h                         | 2 ++
 libstdc++-v3/include/bits/std_function.h                    | 2 ++
 libstdc++-v3/include/bits/std_mutex.h                       | 2 ++
 libstdc++-v3/include/bits/std_thread.h                      | 2 ++
 libstdc++-v3/include/bits/stl_iterator_base_funcs.h         | 2 ++
 libstdc++-v3/include/bits/stl_iterator_base_types.h         | 2 ++
 libstdc++-v3/include/bits/stl_tree.h                        | 2 ++
 libstdc++-v3/include/bits/stream_iterator.h                 | 2 ++
 libstdc++-v3/include/bits/streambuf_iterator.h              | 2 ++
 libstdc++-v3/include/bits/stringfwd.h                       | 2 ++
 libstdc++-v3/include/bits/this_thread_sleep.h               | 2 ++
 libstdc++-v3/include/bits/unique_lock.h                     | 2 ++
 libstdc++-v3/include/bits/uses_allocator_args.h             | 2 ++
 libstdc++-v3/include/bits/utility.h                         | 2 ++
 libstdc++-v3/include/bits/valarray_after.h                  | 2 ++
 libstdc++-v3/include/bits/valarray_array.h                  | 2 ++
 libstdc++-v3/include/bits/valarray_before.h                 | 2 ++
 libstdc++-v3/include/bits/version.h                         | 2 ++
 libstdc++-v3/include/c_compatibility/fenv.h                 | 2 ++
 libstdc++-v3/include/c_compatibility/inttypes.h             | 2 ++
 libstdc++-v3/include/c_compatibility/stdint.h               | 2 ++
 libstdc++-v3/include/decimal/decimal.h                      | 2 ++
 libstdc++-v3/include/experimental/bits/net.h                | 2 ++
 libstdc++-v3/include/experimental/bits/shared_ptr.h         | 2 ++
 libstdc++-v3/include/ext/aligned_buffer.h                   | 2 ++
 libstdc++-v3/include/ext/alloc_traits.h                     | 2 ++
 libstdc++-v3/include/ext/atomicity.h                        | 2 ++
 libstdc++-v3/include/ext/concurrence.h                      | 2 ++
 libstdc++-v3/include/ext/numeric_traits.h                   | 2 ++
 libstdc++-v3/include/ext/pod_char_traits.h                  | 2 ++
 libstdc++-v3/include/ext/pointer.h                          | 2 ++
 libstdc++-v3/include/ext/stdio_filebuf.h                    | 2 ++
 libstdc++-v3/include/ext/stdio_sync_filebuf.h               | 2 ++
 libstdc++-v3/include/ext/string_conversions.h               | 2 ++
 libstdc++-v3/include/ext/type_traits.h                      | 2 ++
 libstdc++-v3/include/ext/vstring.h                          | 2 ++
 libstdc++-v3/include/ext/vstring_fwd.h                      | 2 ++
 libstdc++-v3/include/ext/vstring_util.h                     | 2 ++
 libstdc++-v3/include/parallel/algorithmfwd.h                | 2 ++
 libstdc++-v3/include/parallel/numericfwd.h                  | 2 ++
 libstdc++-v3/include/tr1/functional_hash.h                  | 2 ++
 libstdc++-v3/include/tr1/hashtable.h                        | 2 ++
 libstdc++-v3/include/tr1/random.h                           | 2 ++
 libstdc++-v3/libsupc++/atomic_lockfree_defines.h            | 2 ++
 libstdc++-v3/libsupc++/cxxabi.h                             | 2 ++
 libstdc++-v3/libsupc++/cxxabi_forced.h                      | 2 ++
 libstdc++-v3/libsupc++/cxxabi_init_exception.h              | 2 ++
 libstdc++-v3/libsupc++/exception.h                          | 2 ++
 libstdc++-v3/libsupc++/hash_bytes.h                         | 2 ++
 .../fanalyzer-show-events-in-system-headers-default.C       | 1 +
 .../analyzer/fanalyzer-show-events-in-system-headers-no.C   | 1 +
 gcc/testsuite/g++.dg/diagnostic/disable.C                   | 1 +
 .../testsuite/20_util/ratio/operations/ops_overflow_neg.cc  | 3 ++-
 .../23_containers/array/tuple_interface/get_neg.cc          | 6 +++---
 .../23_containers/vector/cons/destructible_debug_neg.cc     | 2 +-
 libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc  | 2 +-
 .../testsuite/ext/type_traits/add_unsigned_floating_neg.cc  | 2 +-
 .../testsuite/ext/type_traits/add_unsigned_integer_neg.cc   | 4 ++--
 .../ext/type_traits/remove_unsigned_floating_neg.cc         | 2 +-
 .../ext/type_traits/remove_unsigned_integer_neg.cc          | 4 ++--
 libstdc++-v3/acinclude.m4                                   | 2 +-
 libstdc++-v3/include/bits/basic_ios.tcc                     | 2 ++
 libstdc++-v3/include/bits/basic_string.tcc                  | 2 ++
 libstdc++-v3/include/bits/fstream.tcc                       | 2 ++
 libstdc++-v3/include/bits/istream.tcc                       | 2 ++
 libstdc++-v3/include/bits/locale_classes.tcc                | 3 ++-
 libstdc++-v3/include/bits/locale_facets.tcc                 | 3 ++-
 libstdc++-v3/include/bits/locale_facets_nonio.tcc           | 2 ++
 libstdc++-v3/include/bits/ostream.tcc                       | 3 ++-
 libstdc++-v3/include/bits/sstream.tcc                       | 3 ++-
 libstdc++-v3/include/bits/streambuf.tcc                     | 2 ++
 libstdc++-v3/include/bits/string_view.tcc                   | 2 ++
 libstdc++-v3/include/bits/version.tpl                       | 2 ++
 libstdc++-v3/include/experimental/bits/string_view.tcc      | 2 ++
 .../detail/resize_policy/hash_prime_size_policy_imp.hpp     | 2 ++
 libstdc++-v3/include/ext/random.tcc                         | 2 ++
 libstdc++-v3/include/ext/vstring.tcc                        | 2 ++
 libstdc++-v3/include/tr2/bool_set.tcc                       | 2 ++
 libstdc++-v3/include/tr2/dynamic_bitset.tcc                 | 2 ++
 libstdc++-v3/configure                                      | 2 +-
 libstdc++-v3/include/bits/c++config                         | 2 ++
 libstdc++-v3/include/c/cassert                              | 2 ++
 libstdc++-v3/include/c/cctype                               | 2 ++
 libstdc++-v3/include/c/cerrno                               | 2 ++
 libstdc++-v3/include/c/cfloat                               | 2 ++
 libstdc++-v3/include/c/ciso646                              | 2 ++
 libstdc++-v3/include/c/climits                              | 2 ++
 libstdc++-v3/include/c/clocale                              | 2 ++
 libstdc++-v3/include/c/cmath                                | 2 ++
 libstdc++-v3/include/c/csetjmp                              | 2 ++
 libstdc++-v3/include/c/csignal                              | 2 ++
 libstdc++-v3/include/c/cstdarg                              | 2 ++
 libstdc++-v3/include/c/cstddef                              | 2 ++
 libstdc++-v3/include/c/cstdio                               | 2 ++
 libstdc++-v3/include/c/cstdlib                              | 2 ++
 libstdc++-v3/include/c/cstring                              | 2 ++
 libstdc++-v3/include/c/ctime                                | 2 ++
 libstdc++-v3/include/c/cuchar                               | 2 ++
 libstdc++-v3/include/c/cwchar                               | 2 ++
 libstdc++-v3/include/c/cwctype                              | 2 ++
 libstdc++-v3/include/c_global/cassert                       | 2 ++
 libstdc++-v3/include/c_global/ccomplex                      | 2 ++
 libstdc++-v3/include/c_global/cctype                        | 2 ++
 libstdc++-v3/include/c_global/cerrno                        | 2 ++
 libstdc++-v3/include/c_global/cfenv                         | 2 ++
 libstdc++-v3/include/c_global/cfloat                        | 2 ++
 libstdc++-v3/include/c_global/cinttypes                     | 2 ++
 libstdc++-v3/include/c_global/ciso646                       | 3 +++
 libstdc++-v3/include/c_global/climits                       | 2 ++
 libstdc++-v3/include/c_global/clocale                       | 2 ++
 libstdc++-v3/include/c_global/cmath                         | 2 ++
 libstdc++-v3/include/c_global/csetjmp                       | 2 ++
 libstdc++-v3/include/c_global/csignal                       | 2 ++
 libstdc++-v3/include/c_global/cstdalign                     | 2 ++
 libstdc++-v3/include/c_global/cstdarg                       | 2 ++
 libstdc++-v3/include/c_global/cstdbool                      | 2 ++
 libstdc++-v3/include/c_global/cstddef                       | 2 ++
 libstdc++-v3/include/c_global/cstdint                       | 2 ++
 libstdc++-v3/include/c_global/cstdio                        | 2 ++
 libstdc++-v3/include/c_global/cstdlib                       | 2 ++
 libstdc++-v3/include/c_global/cstring                       | 2 ++
 libstdc++-v3/include/c_global/ctgmath                       | 2 ++
 libstdc++-v3/include/c_global/ctime                         | 2 ++
 libstdc++-v3/include/c_global/cuchar                        | 2 ++
 libstdc++-v3/include/c_global/cwchar                        | 2 ++
 libstdc++-v3/include/c_global/cwctype                       | 2 ++
 libstdc++-v3/include/c_std/cassert                          | 2 ++
 libstdc++-v3/include/c_std/cctype                           | 2 ++
 libstdc++-v3/include/c_std/cerrno                           | 2 ++
 libstdc++-v3/include/c_std/cfloat                           | 2 ++
 libstdc++-v3/include/c_std/ciso646                          | 2 ++
 libstdc++-v3/include/c_std/climits                          | 2 ++
 libstdc++-v3/include/c_std/clocale                          | 2 ++
 libstdc++-v3/include/c_std/cmath                            | 2 ++
 libstdc++-v3/include/c_std/csetjmp                          | 2 ++
 libstdc++-v3/include/c_std/csignal                          | 2 ++
 libstdc++-v3/include/c_std/cstdarg                          | 2 ++
 libstdc++-v3/include/c_std/cstddef                          | 2 ++
 libstdc++-v3/include/c_std/cstdio                           | 2 ++
 libstdc++-v3/include/c_std/cstdlib                          | 2 ++
 libstdc++-v3/include/c_std/cstring                          | 2 ++
 libstdc++-v3/include/c_std/ctime                            | 2 ++
 libstdc++-v3/include/c_std/cuchar                           | 2 ++
 libstdc++-v3/include/c_std/cwchar                           | 2 ++
 libstdc++-v3/include/c_std/cwctype                          | 2 ++
 libstdc++-v3/include/debug/array                            | 2 ++
 libstdc++-v3/include/debug/bitset                           | 2 ++
 libstdc++-v3/include/debug/deque                            | 2 ++
 libstdc++-v3/include/debug/forward_list                     | 2 ++
 libstdc++-v3/include/debug/list                             | 2 ++
 libstdc++-v3/include/debug/map                              | 2 ++
 libstdc++-v3/include/debug/set                              | 2 ++
 libstdc++-v3/include/debug/string                           | 2 ++
 libstdc++-v3/include/debug/unordered_map                    | 2 ++
 libstdc++-v3/include/debug/unordered_set                    | 2 ++
 libstdc++-v3/include/debug/vector                           | 2 ++
 libstdc++-v3/include/decimal/decimal                        | 2 ++
 libstdc++-v3/include/experimental/algorithm                 | 2 ++
 libstdc++-v3/include/experimental/any                       | 2 ++
 libstdc++-v3/include/experimental/array                     | 2 ++
 libstdc++-v3/include/experimental/buffer                    | 2 ++
 libstdc++-v3/include/experimental/chrono                    | 2 ++
 libstdc++-v3/include/experimental/contract                  | 2 ++
 libstdc++-v3/include/experimental/deque                     | 2 ++
 libstdc++-v3/include/experimental/executor                  | 2 ++
 libstdc++-v3/include/experimental/filesystem                | 2 ++
 libstdc++-v3/include/experimental/forward_list              | 2 ++
 libstdc++-v3/include/experimental/functional                | 2 ++
 libstdc++-v3/include/experimental/internet                  | 2 ++
 libstdc++-v3/include/experimental/io_context                | 2 ++
 libstdc++-v3/include/experimental/iterator                  | 2 ++
 libstdc++-v3/include/experimental/list                      | 2 ++
 libstdc++-v3/include/experimental/map                       | 2 ++
 libstdc++-v3/include/experimental/memory                    | 2 ++
 libstdc++-v3/include/experimental/memory_resource           | 2 ++
 libstdc++-v3/include/experimental/net                       | 2 ++
 libstdc++-v3/include/experimental/netfwd                    | 2 ++
 libstdc++-v3/include/experimental/numeric                   | 2 ++
 libstdc++-v3/include/experimental/propagate_const           | 2 ++
 libstdc++-v3/include/experimental/ratio                     | 2 ++
 libstdc++-v3/include/experimental/regex                     | 2 ++
 libstdc++-v3/include/experimental/scope                     | 2 ++
 libstdc++-v3/include/experimental/set                       | 2 ++
 libstdc++-v3/include/experimental/socket                    | 2 ++
 libstdc++-v3/include/experimental/string                    | 2 ++
 libstdc++-v3/include/experimental/string_view               | 2 ++
 libstdc++-v3/include/experimental/synchronized_value        | 2 ++
 libstdc++-v3/include/experimental/system_error              | 2 ++
 libstdc++-v3/include/experimental/timer                     | 2 ++
 libstdc++-v3/include/experimental/tuple                     | 2 ++
 libstdc++-v3/include/experimental/type_traits               | 2 ++
 libstdc++-v3/include/experimental/unordered_map             | 2 ++
 libstdc++-v3/include/experimental/unordered_set             | 2 ++
 libstdc++-v3/include/experimental/vector                    | 2 ++
 libstdc++-v3/include/ext/algorithm                          | 2 ++
 libstdc++-v3/include/ext/cmath                              | 2 ++
 libstdc++-v3/include/ext/functional                         | 2 ++
 libstdc++-v3/include/ext/iterator                           | 2 ++
 libstdc++-v3/include/ext/memory                             | 2 ++
 libstdc++-v3/include/ext/numeric                            | 2 ++
 libstdc++-v3/include/ext/random                             | 2 ++
 libstdc++-v3/include/ext/rb_tree                            | 2 ++
 libstdc++-v3/include/ext/rope                               | 2 ++
 libstdc++-v3/include/parallel/algorithm                     | 2 ++
 libstdc++-v3/include/std/algorithm                          | 2 ++
 libstdc++-v3/include/std/any                                | 2 ++
 libstdc++-v3/include/std/array                              | 2 ++
 libstdc++-v3/include/std/atomic                             | 2 ++
 libstdc++-v3/include/std/barrier                            | 2 ++
 libstdc++-v3/include/std/bit                                | 2 ++
 libstdc++-v3/include/std/bitset                             | 2 ++
 libstdc++-v3/include/std/charconv                           | 2 ++
 libstdc++-v3/include/std/chrono                             | 2 ++
 libstdc++-v3/include/std/codecvt                            | 2 ++
 libstdc++-v3/include/std/complex                            | 2 ++
 libstdc++-v3/include/std/concepts                           | 2 ++
 libstdc++-v3/include/std/condition_variable                 | 2 ++
 libstdc++-v3/include/std/coroutine                          | 2 ++
 libstdc++-v3/include/std/deque                              | 2 ++
 libstdc++-v3/include/std/execution                          | 2 ++
 libstdc++-v3/include/std/expected                           | 2 ++
 libstdc++-v3/include/std/filesystem                         | 2 ++
 libstdc++-v3/include/std/format                             | 2 ++
 libstdc++-v3/include/std/forward_list                       | 2 ++
 libstdc++-v3/include/std/fstream                            | 2 ++
 libstdc++-v3/include/std/functional                         | 2 ++
 libstdc++-v3/include/std/future                             | 2 ++
 libstdc++-v3/include/std/generator                          | 2 ++
 libstdc++-v3/include/std/iomanip                            | 2 ++
 libstdc++-v3/include/std/ios                                | 2 ++
 libstdc++-v3/include/std/iosfwd                             | 2 ++
 libstdc++-v3/include/std/iostream                           | 2 ++
 libstdc++-v3/include/std/istream                            | 2 ++
 libstdc++-v3/include/std/iterator                           | 2 ++
 libstdc++-v3/include/std/latch                              | 2 ++
 libstdc++-v3/include/std/limits                             | 2 ++
 libstdc++-v3/include/std/list                               | 2 ++
 libstdc++-v3/include/std/locale                             | 2 ++
 libstdc++-v3/include/std/map                                | 2 ++
 libstdc++-v3/include/std/memory                             | 2 ++
 libstdc++-v3/include/std/memory_resource                    | 2 ++
 libstdc++-v3/include/std/mutex                              | 2 ++
 libstdc++-v3/include/std/numbers                            | 2 ++
 libstdc++-v3/include/std/numeric                            | 2 ++
 libstdc++-v3/include/std/optional                           | 2 ++
 libstdc++-v3/include/std/ostream                            | 2 ++
 libstdc++-v3/include/std/print                              | 2 ++
 libstdc++-v3/include/std/queue                              | 2 ++
 libstdc++-v3/include/std/random                             | 2 ++
 libstdc++-v3/include/std/ranges                             | 2 ++
 libstdc++-v3/include/std/ratio                              | 2 ++
 libstdc++-v3/include/std/regex                              | 2 ++
 libstdc++-v3/include/std/scoped_allocator                   | 2 ++
 libstdc++-v3/include/std/semaphore                          | 2 ++
 libstdc++-v3/include/std/set                                | 2 ++
 libstdc++-v3/include/std/shared_mutex                       | 2 ++
 libstdc++-v3/include/std/span                               | 2 ++
 libstdc++-v3/include/std/spanstream                         | 2 ++
 libstdc++-v3/include/std/sstream                            | 2 ++
 libstdc++-v3/include/std/stack                              | 2 ++
 libstdc++-v3/include/std/stacktrace                         | 2 ++
 libstdc++-v3/include/std/stdexcept                          | 2 ++
 libstdc++-v3/include/std/streambuf                          | 2 ++
 libstdc++-v3/include/std/string                             | 2 ++
 libstdc++-v3/include/std/string_view                        | 2 ++
 libstdc++-v3/include/std/syncstream                         | 2 ++
 libstdc++-v3/include/std/system_error                       | 2 ++
 libstdc++-v3/include/std/text_encoding                      | 2 ++
 libstdc++-v3/include/std/thread                             | 2 ++
 libstdc++-v3/include/std/tuple                              | 2 ++
 libstdc++-v3/include/std/type_traits                        | 2 ++
 libstdc++-v3/include/std/typeindex                          | 2 ++
 libstdc++-v3/include/std/unordered_map                      | 2 ++
 libstdc++-v3/include/std/unordered_set                      | 2 ++
 libstdc++-v3/include/std/utility                            | 2 ++
 libstdc++-v3/include/std/valarray                           | 2 ++
 libstdc++-v3/include/std/variant                            | 2 ++
 libstdc++-v3/include/std/vector                             | 2 ++
 libstdc++-v3/include/std/version                            | 2 ++
 libstdc++-v3/include/tr1/array                              | 2 ++
 libstdc++-v3/include/tr1/cfenv                              | 2 ++
 libstdc++-v3/include/tr1/cinttypes                          | 2 ++
 libstdc++-v3/include/tr1/cmath                              | 2 ++
 libstdc++-v3/include/tr1/complex                            | 2 ++
 libstdc++-v3/include/tr1/cstdbool                           | 2 ++
 libstdc++-v3/include/tr1/cstdint                            | 2 ++
 libstdc++-v3/include/tr1/cstdio                             | 2 ++
 libstdc++-v3/include/tr1/cstdlib                            | 2 ++
 libstdc++-v3/include/tr1/cwchar                             | 2 ++
 libstdc++-v3/include/tr1/cwctype                            | 2 ++
 libstdc++-v3/include/tr1/functional                         | 2 ++
 libstdc++-v3/include/tr1/memory                             | 2 ++
 libstdc++-v3/include/tr1/random                             | 2 ++
 libstdc++-v3/include/tr1/regex                              | 2 ++
 libstdc++-v3/include/tr1/tuple                              | 2 ++
 libstdc++-v3/include/tr1/type_traits                        | 2 ++
 libstdc++-v3/include/tr1/unordered_map                      | 2 ++
 libstdc++-v3/include/tr1/unordered_set                      | 2 ++
 libstdc++-v3/include/tr1/utility                            | 2 ++
 libstdc++-v3/include/tr2/bool_set                           | 2 ++
 libstdc++-v3/include/tr2/dynamic_bitset                     | 2 ++
 libstdc++-v3/include/tr2/type_traits                        | 2 ++
 libstdc++-v3/libsupc++/compare                              | 2 ++
 libstdc++-v3/libsupc++/exception                            | 2 ++
 libstdc++-v3/libsupc++/initializer_list                     | 2 ++
 libstdc++-v3/libsupc++/new                                  | 2 ++
 libstdc++-v3/libsupc++/typeinfo                             | 2 ++
 355 files changed, 703 insertions(+), 18 deletions(-)


base-commit: 358db2e3ed4acf44282d1d9ebbc4a1a3b6e38d21

Comments

Jonathan Wakely Sept. 24, 2024, 5:15 p.m. UTC | #1
On 23/09/24 11:06 -0400, Jason Merrill wrote:
>Tested x86_64-pc-linux-gnu, OK for trunk?

Yes please, I've wanted this for years, but it wasn't practical until
you changed some of the warnings recently.

Thanks!
diff mbox series

Patch

diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h
index df14864d210..0016dcd42e9 100644
--- a/libstdc++-v3/include/bits/algorithmfwd.h
+++ b/libstdc++-v3/include/bits/algorithmfwd.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_ALGORITHMFWD_H
 #define _GLIBCXX_ALGORITHMFWD_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/stl_pair.h>
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 7c27bd8c951..7093d0fc822 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_ATOMIC_BASE_H
 #define _GLIBCXX_ATOMIC_BASE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <new> // For placement new
diff --git a/libstdc++-v3/include/bits/atomic_futex.h b/libstdc++-v3/include/bits/atomic_futex.h
index dd654174873..c7d90466418 100644
--- a/libstdc++-v3/include/bits/atomic_futex.h
+++ b/libstdc++-v3/include/bits/atomic_futex.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_ATOMIC_FUTEX_H
 #define _GLIBCXX_ATOMIC_FUTEX_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <atomic>
 #if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1)
diff --git a/libstdc++-v3/include/bits/atomic_timed_wait.h b/libstdc++-v3/include/bits/atomic_timed_wait.h
index 778d2868b03..b1eeb3ceeac 100644
--- a/libstdc++-v3/include/bits/atomic_timed_wait.h
+++ b/libstdc++-v3/include/bits/atomic_timed_wait.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_ATOMIC_TIMED_WAIT_H
 #define _GLIBCXX_ATOMIC_TIMED_WAIT_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/atomic_wait.h>
 
diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h
index f1c183f9dbb..e31b535132a 100644
--- a/libstdc++-v3/include/bits/atomic_wait.h
+++ b/libstdc++-v3/include/bits/atomic_wait.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_ATOMIC_WAIT_H
 #define _GLIBCXX_ATOMIC_WAIT_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/version.h>
 
diff --git a/libstdc++-v3/include/bits/basic_ios.h b/libstdc++-v3/include/bits/basic_ios.h
index 2c2334d0fe3..a2d8060edd2 100644
--- a/libstdc++-v3/include/bits/basic_ios.h
+++ b/libstdc++-v3/include/bits/basic_ios.h
@@ -30,7 +30,9 @@ 
 #ifndef _BASIC_IOS_H
 #define _BASIC_IOS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/localefwd.h>
 #include <bits/locale_classes.h>
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 120c0bc9a17..976577f8f22 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -34,7 +34,9 @@ 
 #ifndef _BASIC_STRING_H
 #define _BASIC_STRING_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <ext/alloc_traits.h>
 #include <debug/debug.h>
diff --git a/libstdc++-v3/include/bits/boost_concept_check.h b/libstdc++-v3/include/bits/boost_concept_check.h
index a042ae670fe..76b5abbecd2 100644
--- a/libstdc++-v3/include/bits/boost_concept_check.h
+++ b/libstdc++-v3/include/bits/boost_concept_check.h
@@ -39,7 +39,9 @@ 
 #ifndef _BOOST_CONCEPT_CHECK_H
 #define _BOOST_CONCEPT_CHECK_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/stl_iterator_base_types.h>    // for traits and tags
diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h
index ac3e43e34b9..fa922e535ce 100644
--- a/libstdc++-v3/include/bits/char_traits.h
+++ b/libstdc++-v3/include/bits/char_traits.h
@@ -34,7 +34,9 @@ 
 #ifndef _CHAR_TRAITS_H
 #define _CHAR_TRAITS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/bits/charconv.h b/libstdc++-v3/include/bits/charconv.h
index c9d439b99f2..b22c7e1195f 100644
--- a/libstdc++-v3/include/bits/charconv.h
+++ b/libstdc++-v3/include/bits/charconv.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_CHARCONV_H
 #define _GLIBCXX_CHARCONV_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201103L
 
diff --git a/libstdc++-v3/include/bits/chrono.h b/libstdc++-v3/include/bits/chrono.h
index fd9c4642f4f..3a5ab95e1ad 100644
--- a/libstdc++-v3/include/bits/chrono.h
+++ b/libstdc++-v3/include/bits/chrono.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_CHRONO_H
 #define _GLIBCXX_CHRONO_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201103L
 
diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h
index c7d2c9862fc..1e34c82b532 100644
--- a/libstdc++-v3/include/bits/chrono_io.h
+++ b/libstdc++-v3/include/bits/chrono_io.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_CHRONO_IO_H
 #define _GLIBCXX_CHRONO_IO_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 202002L
 
diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h
index c51cc7d220d..ce520a6d8de 100644
--- a/libstdc++-v3/include/bits/codecvt.h
+++ b/libstdc++-v3/include/bits/codecvt.h
@@ -36,7 +36,9 @@ 
 #ifndef _CODECVT_H
 #define _CODECVT_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/locale_classes.h> // locale::facet
diff --git a/libstdc++-v3/include/bits/concept_check.h b/libstdc++-v3/include/bits/concept_check.h
index 6479f2fa919..cfedeb8dacf 100644
--- a/libstdc++-v3/include/bits/concept_check.h
+++ b/libstdc++-v3/include/bits/concept_check.h
@@ -30,7 +30,9 @@ 
 #ifndef _CONCEPT_CHECK_H
 #define _CONCEPT_CHECK_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h
index e3a80e06346..19bf1edf647 100644
--- a/libstdc++-v3/include/bits/cpp_type_traits.h
+++ b/libstdc++-v3/include/bits/cpp_type_traits.h
@@ -32,7 +32,9 @@ 
 #ifndef _CPP_TYPE_TRAITS_H
 #define _CPP_TYPE_TRAITS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/version.h>
diff --git a/libstdc++-v3/include/bits/elements_of.h b/libstdc++-v3/include/bits/elements_of.h
index 2c65f2574cb..118efeb3209 100644
--- a/libstdc++-v3/include/bits/elements_of.h
+++ b/libstdc++-v3/include/bits/elements_of.h
@@ -25,7 +25,9 @@ 
 #ifndef _GLIBCXX_BITS_ELEMENTS_OF
 #define _GLIBCXX_BITS_ELEMENTS_OF
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/bits/enable_special_members.h b/libstdc++-v3/include/bits/enable_special_members.h
index 73a9b0202ce..b53ff341108 100644
--- a/libstdc++-v3/include/bits/enable_special_members.h
+++ b/libstdc++-v3/include/bits/enable_special_members.h
@@ -30,7 +30,9 @@ 
 #ifndef _ENABLE_SPECIAL_MEMBERS_H
 #define _ENABLE_SPECIAL_MEMBERS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/bits/erase_if.h b/libstdc++-v3/include/bits/erase_if.h
index 1fc348db1e3..327dade0081 100644
--- a/libstdc++-v3/include/bits/erase_if.h
+++ b/libstdc++-v3/include/bits/erase_if.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_ERASE_IF_H
 #define _GLIBCXX_ERASE_IF_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h
index 5ab2253f609..eee773c0212 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -30,7 +30,9 @@ 
 #ifndef _FORWARD_LIST_H
 #define _FORWARD_LIST_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <initializer_list>
 #include <bits/stl_iterator_base_types.h>
diff --git a/libstdc++-v3/include/bits/functional_hash.h b/libstdc++-v3/include/bits/functional_hash.h
index 3626ebe816b..e7d8c6c2054 100644
--- a/libstdc++-v3/include/bits/functional_hash.h
+++ b/libstdc++-v3/include/bits/functional_hash.h
@@ -30,7 +30,9 @@ 
 #ifndef _FUNCTIONAL_HASH_H
 #define _FUNCTIONAL_HASH_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <type_traits>
 #include <bits/hash_bytes.h>
diff --git a/libstdc++-v3/include/bits/gslice.h b/libstdc++-v3/include/bits/gslice.h
index d9a8b929a57..90e21fdf6bf 100644
--- a/libstdc++-v3/include/bits/gslice.h
+++ b/libstdc++-v3/include/bits/gslice.h
@@ -32,7 +32,9 @@ 
 #ifndef _GSLICE_H
 #define _GSLICE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/gslice_array.h b/libstdc++-v3/include/bits/gslice_array.h
index a358123a2c6..fc3cdb9d157 100644
--- a/libstdc++-v3/include/bits/gslice_array.h
+++ b/libstdc++-v3/include/bits/gslice_array.h
@@ -32,7 +32,9 @@ 
 #ifndef _GSLICE_ARRAY_H
 #define _GSLICE_ARRAY_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h
index b02bddf5635..92b57071f1c 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -30,7 +30,9 @@ 
 #ifndef _HASHTABLE_H
 #define _HASHTABLE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/hashtable_policy.h>
 #include <bits/enable_special_members.h>
diff --git a/libstdc++-v3/include/bits/indirect_array.h b/libstdc++-v3/include/bits/indirect_array.h
index 99980d5dbc1..b6829530daa 100644
--- a/libstdc++-v3/include/bits/indirect_array.h
+++ b/libstdc++-v3/include/bits/indirect_array.h
@@ -32,7 +32,9 @@ 
 #ifndef _INDIRECT_ARRAY_H
 #define _INDIRECT_ARRAY_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/invoke.h b/libstdc++-v3/include/bits/invoke.h
index 2c66a36db81..eff2ff5c238 100644
--- a/libstdc++-v3/include/bits/invoke.h
+++ b/libstdc++-v3/include/bits/invoke.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_INVOKE_H
 #define _GLIBCXX_INVOKE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h
index 6e343658096..a649448e298 100644
--- a/libstdc++-v3/include/bits/ios_base.h
+++ b/libstdc++-v3/include/bits/ios_base.h
@@ -34,7 +34,9 @@ 
 #ifndef _IOS_BASE_H
 #define _IOS_BASE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <ext/atomicity.h>
 #include <bits/localefwd.h>
diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h
index d96573f4213..490a362cdf1 100644
--- a/libstdc++-v3/include/bits/iterator_concepts.h
+++ b/libstdc++-v3/include/bits/iterator_concepts.h
@@ -30,7 +30,9 @@ 
 #ifndef _ITERATOR_CONCEPTS_H
 #define _ITERATOR_CONCEPTS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 202002L
 #include <concepts>
diff --git a/libstdc++-v3/include/bits/locale_classes.h b/libstdc++-v3/include/bits/locale_classes.h
index e168881b516..0edb815aee0 100644
--- a/libstdc++-v3/include/bits/locale_classes.h
+++ b/libstdc++-v3/include/bits/locale_classes.h
@@ -34,7 +34,9 @@ 
 #ifndef _LOCALE_CLASSES_H
 #define _LOCALE_CLASSES_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/localefwd.h>
 #include <string>
diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h
index 53bb108e3ea..afa239ad96a 100644
--- a/libstdc++-v3/include/bits/locale_facets.h
+++ b/libstdc++-v3/include/bits/locale_facets.h
@@ -34,7 +34,9 @@ 
 #ifndef _LOCALE_FACETS_H
 #define _LOCALE_FACETS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <cwctype>	// For wctype_t
 #include <cctype>
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.h b/libstdc++-v3/include/bits/locale_facets_nonio.h
index f9e70e5b227..298ffc10ed3 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.h
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.h
@@ -34,7 +34,9 @@ 
 #ifndef _LOCALE_FACETS_NONIO_H
 #define _LOCALE_FACETS_NONIO_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <ctime>	// For struct tm
 
diff --git a/libstdc++-v3/include/bits/localefwd.h b/libstdc++-v3/include/bits/localefwd.h
index 07e5443b2bb..cee5c4d5134 100644
--- a/libstdc++-v3/include/bits/localefwd.h
+++ b/libstdc++-v3/include/bits/localefwd.h
@@ -34,7 +34,9 @@ 
 #ifndef _LOCALE_FWD_H
 #define _LOCALE_FWD_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/c++locale.h>  // Defines __c_locale, config-specific include
diff --git a/libstdc++-v3/include/bits/mask_array.h b/libstdc++-v3/include/bits/mask_array.h
index 58fcc3027e1..341b828f700 100644
--- a/libstdc++-v3/include/bits/mask_array.h
+++ b/libstdc++-v3/include/bits/mask_array.h
@@ -32,7 +32,9 @@ 
 #ifndef _MASK_ARRAY_H
 #define _MASK_ARRAY_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/max_size_type.h b/libstdc++-v3/include/bits/max_size_type.h
index 7d686708507..d3392b2e6b5 100644
--- a/libstdc++-v3/include/bits/max_size_type.h
+++ b/libstdc++-v3/include/bits/max_size_type.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_MAX_SIZE_TYPE_H
 #define _GLIBCXX_MAX_SIZE_TYPE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus > 201703L && __cpp_lib_concepts
 #include <ext/numeric_traits.h>
diff --git a/libstdc++-v3/include/bits/memory_resource.h b/libstdc++-v3/include/bits/memory_resource.h
index db515fb30ef..a40c9729c57 100644
--- a/libstdc++-v3/include/bits/memory_resource.h
+++ b/libstdc++-v3/include/bits/memory_resource.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_MEMORY_RESOURCE_H
 #define _GLIBCXX_MEMORY_RESOURCE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201703L
 
diff --git a/libstdc++-v3/include/bits/memoryfwd.h b/libstdc++-v3/include/bits/memoryfwd.h
index 03d1162e233..bb6bdcc2225 100644
--- a/libstdc++-v3/include/bits/memoryfwd.h
+++ b/libstdc++-v3/include/bits/memoryfwd.h
@@ -43,7 +43,9 @@ 
 #ifndef _MEMORYFWD_H
 #define _MEMORYFWD_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/bits/move_only_function.h b/libstdc++-v3/include/bits/move_only_function.h
index 2a40ff400de..42b33d01901 100644
--- a/libstdc++-v3/include/bits/move_only_function.h
+++ b/libstdc++-v3/include/bits/move_only_function.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_MOVE_ONLY_FUNCTION_H
 #define _GLIBCXX_MOVE_ONLY_FUNCTION_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/version.h>
 
diff --git a/libstdc++-v3/include/bits/node_handle.h b/libstdc++-v3/include/bits/node_handle.h
index 2d8e47c5062..d8ba11180bd 100644
--- a/libstdc++-v3/include/bits/node_handle.h
+++ b/libstdc++-v3/include/bits/node_handle.h
@@ -31,7 +31,9 @@ 
 #ifndef _NODE_HANDLE
 #define _NODE_HANDLE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/version.h>
 
diff --git a/libstdc++-v3/include/bits/ostream_insert.h b/libstdc++-v3/include/bits/ostream_insert.h
index d61b4b14f97..c92504eed65 100644
--- a/libstdc++-v3/include/bits/ostream_insert.h
+++ b/libstdc++-v3/include/bits/ostream_insert.h
@@ -30,7 +30,9 @@ 
 #ifndef _OSTREAM_INSERT_H
 #define _OSTREAM_INSERT_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <iosfwd>
 #include <bits/cxxabi_forced.h>
diff --git a/libstdc++-v3/include/bits/out_ptr.h b/libstdc++-v3/include/bits/out_ptr.h
index d74c9f52d3b..00ba09d0f18 100644
--- a/libstdc++-v3/include/bits/out_ptr.h
+++ b/libstdc++-v3/include/bits/out_ptr.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_OUT_PTR_H
 #define _GLIBCXX_OUT_PTR_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/version.h>
 
diff --git a/libstdc++-v3/include/bits/parse_numbers.h b/libstdc++-v3/include/bits/parse_numbers.h
index 97c08ca7371..7d352ce625b 100644
--- a/libstdc++-v3/include/bits/parse_numbers.h
+++ b/libstdc++-v3/include/bits/parse_numbers.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_PARSE_NUMBERS_H
 #define _GLIBCXX_PARSE_NUMBERS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 // From n3642.pdf except I added binary literals and digit separator '\''.
 
diff --git a/libstdc++-v3/include/bits/postypes.h b/libstdc++-v3/include/bits/postypes.h
index 3da558b1ad4..7bd973e089b 100644
--- a/libstdc++-v3/include/bits/postypes.h
+++ b/libstdc++-v3/include/bits/postypes.h
@@ -35,7 +35,9 @@ 
 #ifndef _GLIBCXX_POSTYPES_H
 #define _GLIBCXX_POSTYPES_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <cwchar> // For mbstate_t
 
diff --git a/libstdc++-v3/include/bits/quoted_string.h b/libstdc++-v3/include/bits/quoted_string.h
index e2f2518638b..a0b67265ec3 100644
--- a/libstdc++-v3/include/bits/quoted_string.h
+++ b/libstdc++-v3/include/bits/quoted_string.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_QUOTED_STRING_H
 #define _GLIBCXX_QUOTED_STRING_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/include/bits/range_access.h
index a9896d109ef..2dacbedfa53 100644
--- a/libstdc++-v3/include/bits/range_access.h
+++ b/libstdc++-v3/include/bits/range_access.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_RANGE_ACCESS_H
 #define _GLIBCXX_RANGE_ACCESS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201103L
 #include <initializer_list>
diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h
index ebd4f7e5956..137c3c98e14 100644
--- a/libstdc++-v3/include/bits/ranges_base.h
+++ b/libstdc++-v3/include/bits/ranges_base.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_RANGES_BASE_H
 #define _GLIBCXX_RANGES_BASE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus > 201703L
 #include <initializer_list>
diff --git a/libstdc++-v3/include/bits/refwrap.h b/libstdc++-v3/include/bits/refwrap.h
index 71ec2b297b7..a73cdc9c71e 100644
--- a/libstdc++-v3/include/bits/refwrap.h
+++ b/libstdc++-v3/include/bits/refwrap.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_REFWRAP_H
 #define _GLIBCXX_REFWRAP_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201103L
 
diff --git a/libstdc++-v3/include/bits/sat_arith.h b/libstdc++-v3/include/bits/sat_arith.h
index 71793467984..97545d272ca 100644
--- a/libstdc++-v3/include/bits/sat_arith.h
+++ b/libstdc++-v3/include/bits/sat_arith.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_SAT_ARITH_H
 #define _GLIBCXX_SAT_ARITH_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/version.h>
 
diff --git a/libstdc++-v3/include/bits/semaphore_base.h b/libstdc++-v3/include/bits/semaphore_base.h
index 2b19c9c6c6a..9d73b37e60a 100644
--- a/libstdc++-v3/include/bits/semaphore_base.h
+++ b/libstdc++-v3/include/bits/semaphore_base.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_SEMAPHORE_BASE_H
 #define _GLIBCXX_SEMAPHORE_BASE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/atomic_base.h>
 #include <bits/chrono.h>
diff --git a/libstdc++-v3/include/bits/slice_array.h b/libstdc++-v3/include/bits/slice_array.h
index 10e1604a6c0..50ed758726a 100644
--- a/libstdc++-v3/include/bits/slice_array.h
+++ b/libstdc++-v3/include/bits/slice_array.h
@@ -32,7 +32,9 @@ 
 #ifndef _SLICE_ARRAY_H
 #define _SLICE_ARRAY_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/std_abs.h b/libstdc++-v3/include/bits/std_abs.h
index d143ec14179..0fa6468a0c8 100644
--- a/libstdc++-v3/include/bits/std_abs.h
+++ b/libstdc++-v3/include/bits/std_abs.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_BITS_STD_ABS_H
 #define _GLIBCXX_BITS_STD_ABS_H
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/bits/std_function.h b/libstdc++-v3/include/bits/std_function.h
index bb8d8b9306c..d6c448159f2 100644
--- a/libstdc++-v3/include/bits/std_function.h
+++ b/libstdc++-v3/include/bits/std_function.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_STD_FUNCTION_H
 #define _GLIBCXX_STD_FUNCTION_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/bits/std_mutex.h b/libstdc++-v3/include/bits/std_mutex.h
index c4b287672e0..2ade4c59dbe 100644
--- a/libstdc++-v3/include/bits/std_mutex.h
+++ b/libstdc++-v3/include/bits/std_mutex.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_MUTEX_H
 #define _GLIBCXX_MUTEX_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/bits/std_thread.h b/libstdc++-v3/include/bits/std_thread.h
index 5817bfb29dd..eca2de7afa4 100644
--- a/libstdc++-v3/include/bits/std_thread.h
+++ b/libstdc++-v3/include/bits/std_thread.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_THREAD_H
 #define _GLIBCXX_THREAD_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201103L
 #include <bits/c++config.h>
diff --git a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
index 2c9eaf9226d..0ee50aae993 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
@@ -59,7 +59,9 @@ 
 #ifndef _STL_ITERATOR_BASE_FUNCS_H
 #define _STL_ITERATOR_BASE_FUNCS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/concept_check.h>
 #include <debug/assertions.h>
diff --git a/libstdc++-v3/include/bits/stl_iterator_base_types.h b/libstdc++-v3/include/bits/stl_iterator_base_types.h
index 14ea0d44e28..710e367c978 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_types.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_types.h
@@ -59,7 +59,9 @@ 
 #ifndef _STL_ITERATOR_BASE_TYPES_H
 #define _STL_ITERATOR_BASE_TYPES_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h
index 978093fc587..bc27e191e8b 100644
--- a/libstdc++-v3/include/bits/stl_tree.h
+++ b/libstdc++-v3/include/bits/stl_tree.h
@@ -58,7 +58,9 @@ 
 #ifndef _STL_TREE_H
 #define _STL_TREE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/stl_algobase.h>
 #include <bits/allocator.h>
diff --git a/libstdc++-v3/include/bits/stream_iterator.h b/libstdc++-v3/include/bits/stream_iterator.h
index 6c3ba9d6b8b..32b265c90ec 100644
--- a/libstdc++-v3/include/bits/stream_iterator.h
+++ b/libstdc++-v3/include/bits/stream_iterator.h
@@ -30,7 +30,9 @@ 
 #ifndef _STREAM_ITERATOR_H
 #define _STREAM_ITERATOR_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <iosfwd>
 #include <bits/move.h>
diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h b/libstdc++-v3/include/bits/streambuf_iterator.h
index 579bf0b1819..078eeb358b9 100644
--- a/libstdc++-v3/include/bits/streambuf_iterator.h
+++ b/libstdc++-v3/include/bits/streambuf_iterator.h
@@ -30,7 +30,9 @@ 
 #ifndef _STREAMBUF_ITERATOR_H
 #define _STREAMBUF_ITERATOR_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <streambuf>
 #include <bits/stl_iterator_base_types.h>
diff --git a/libstdc++-v3/include/bits/stringfwd.h b/libstdc++-v3/include/bits/stringfwd.h
index dcbc9ed6419..8f9a32dcb3b 100644
--- a/libstdc++-v3/include/bits/stringfwd.h
+++ b/libstdc++-v3/include/bits/stringfwd.h
@@ -34,7 +34,9 @@ 
 #ifndef _STRINGFWD_H
 #define _STRINGFWD_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/memoryfwd.h>
diff --git a/libstdc++-v3/include/bits/this_thread_sleep.h b/libstdc++-v3/include/bits/this_thread_sleep.h
index b7ddd1beaab..d1b1436f4fa 100644
--- a/libstdc++-v3/include/bits/this_thread_sleep.h
+++ b/libstdc++-v3/include/bits/this_thread_sleep.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_THIS_THREAD_SLEEP_H
 #define _GLIBCXX_THIS_THREAD_SLEEP_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201103L
 #include <bits/chrono.h> // std::chrono::*
diff --git a/libstdc++-v3/include/bits/unique_lock.h b/libstdc++-v3/include/bits/unique_lock.h
index efb24cf91d3..acb6545926e 100644
--- a/libstdc++-v3/include/bits/unique_lock.h
+++ b/libstdc++-v3/include/bits/unique_lock.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_UNIQUE_LOCK_H
 #define _GLIBCXX_UNIQUE_LOCK_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/bits/uses_allocator_args.h b/libstdc++-v3/include/bits/uses_allocator_args.h
index 92097c9c60c..18fd4bb360d 100644
--- a/libstdc++-v3/include/bits/uses_allocator_args.h
+++ b/libstdc++-v3/include/bits/uses_allocator_args.h
@@ -30,7 +30,9 @@ 
 #ifndef _USES_ALLOCATOR_ARGS
 #define _USES_ALLOCATOR_ARGS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/version.h>
 
diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h
index 751ff7b9a27..4a6c16dc2e0 100644
--- a/libstdc++-v3/include/bits/utility.h
+++ b/libstdc++-v3/include/bits/utility.h
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_UTILITY_H
 #define _GLIBCXX_UTILITY_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201103L
 
diff --git a/libstdc++-v3/include/bits/valarray_after.h b/libstdc++-v3/include/bits/valarray_after.h
index b7c93fc1fa7..380839cccef 100644
--- a/libstdc++-v3/include/bits/valarray_after.h
+++ b/libstdc++-v3/include/bits/valarray_after.h
@@ -32,7 +32,9 @@ 
 #ifndef _VALARRAY_AFTER_H
 #define _VALARRAY_AFTER_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/valarray_array.h b/libstdc++-v3/include/bits/valarray_array.h
index 0dc28333f33..0c143313882 100644
--- a/libstdc++-v3/include/bits/valarray_array.h
+++ b/libstdc++-v3/include/bits/valarray_array.h
@@ -32,7 +32,9 @@ 
 #ifndef _VALARRAY_ARRAY_H
 #define _VALARRAY_ARRAY_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/cpp_type_traits.h>
diff --git a/libstdc++-v3/include/bits/valarray_before.h b/libstdc++-v3/include/bits/valarray_before.h
index af5a1c20ddd..c6eabd2a16d 100644
--- a/libstdc++-v3/include/bits/valarray_before.h
+++ b/libstdc++-v3/include/bits/valarray_before.h
@@ -32,7 +32,9 @@ 
 #ifndef _VALARRAY_BEFORE_H
 #define _VALARRAY_BEFORE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/slice_array.h>
 
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 22526e85145..dcd93fd432d 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -44,7 +44,9 @@ 
 // if unwanted, to permit bits and other FTMs to depend on them for condtional
 // computation without exposing extra FTMs to user code.
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/c_compatibility/fenv.h b/libstdc++-v3/include/c_compatibility/fenv.h
index a587e7308af..957de38b509 100644
--- a/libstdc++-v3/include/c_compatibility/fenv.h
+++ b/libstdc++-v3/include/c_compatibility/fenv.h
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_FENV_H
 #define _GLIBCXX_FENV_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c_compatibility/inttypes.h b/libstdc++-v3/include/c_compatibility/inttypes.h
index 5a428ce0bd7..1eaa3906552 100644
--- a/libstdc++-v3/include/c_compatibility/inttypes.h
+++ b/libstdc++-v3/include/c_compatibility/inttypes.h
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_INTTYPES_H
 #define _GLIBCXX_INTTYPES_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c_compatibility/stdint.h b/libstdc++-v3/include/c_compatibility/stdint.h
index 2d892e7ceb2..8923db83edd 100644
--- a/libstdc++-v3/include/c_compatibility/stdint.h
+++ b/libstdc++-v3/include/c_compatibility/stdint.h
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_STDINT_H
 #define _GLIBCXX_STDINT_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/decimal/decimal.h b/libstdc++-v3/include/decimal/decimal.h
index 99376a60cdf..36557b22348 100644
--- a/libstdc++-v3/include/decimal/decimal.h
+++ b/libstdc++-v3/include/decimal/decimal.h
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_DECIMAL_IMPL
 #define _GLIBCXX_DECIMAL_IMPL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/experimental/bits/net.h b/libstdc++-v3/include/experimental/bits/net.h
index 9697069bb70..d536d865be4 100644
--- a/libstdc++-v3/include/experimental/bits/net.h
+++ b/libstdc++-v3/include/experimental/bits/net.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_NET_H
 #define _GLIBCXX_EXPERIMENTAL_NET_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201402L
 
diff --git a/libstdc++-v3/include/experimental/bits/shared_ptr.h b/libstdc++-v3/include/experimental/bits/shared_ptr.h
index f30d9a74006..9a5659c682b 100644
--- a/libstdc++-v3/include/experimental/bits/shared_ptr.h
+++ b/libstdc++-v3/include/experimental/bits/shared_ptr.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_SHARED_PTR_H
 #define _GLIBCXX_EXPERIMENTAL_SHARED_PTR_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201402L
 
diff --git a/libstdc++-v3/include/ext/aligned_buffer.h b/libstdc++-v3/include/ext/aligned_buffer.h
index 9c2c628e54a..25f9b25a17e 100644
--- a/libstdc++-v3/include/ext/aligned_buffer.h
+++ b/libstdc++-v3/include/ext/aligned_buffer.h
@@ -29,7 +29,9 @@ 
 #ifndef _ALIGNED_BUFFER_H
 #define _ALIGNED_BUFFER_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201103L
 # include <type_traits>
diff --git a/libstdc++-v3/include/ext/alloc_traits.h b/libstdc++-v3/include/ext/alloc_traits.h
index f778c4d3ba9..d2560531bac 100644
--- a/libstdc++-v3/include/ext/alloc_traits.h
+++ b/libstdc++-v3/include/ext/alloc_traits.h
@@ -29,7 +29,9 @@ 
 #ifndef _EXT_ALLOC_TRAITS_H
 #define _EXT_ALLOC_TRAITS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 # include <bits/alloc_traits.h>
 
diff --git a/libstdc++-v3/include/ext/atomicity.h b/libstdc++-v3/include/ext/atomicity.h
index cc2fe3b28bc..964a63438d3 100644
--- a/libstdc++-v3/include/ext/atomicity.h
+++ b/libstdc++-v3/include/ext/atomicity.h
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_ATOMICITY_H
 #define _GLIBCXX_ATOMICITY_H	1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/gthr.h>
diff --git a/libstdc++-v3/include/ext/concurrence.h b/libstdc++-v3/include/ext/concurrence.h
index 8188c1366b0..8191e7abe04 100644
--- a/libstdc++-v3/include/ext/concurrence.h
+++ b/libstdc++-v3/include/ext/concurrence.h
@@ -29,7 +29,9 @@ 
 #ifndef _CONCURRENCE_H
 #define _CONCURRENCE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <exception>
 #include <bits/gthr.h> 
diff --git a/libstdc++-v3/include/ext/numeric_traits.h b/libstdc++-v3/include/ext/numeric_traits.h
index b2723bfabfa..91fe18ea548 100644
--- a/libstdc++-v3/include/ext/numeric_traits.h
+++ b/libstdc++-v3/include/ext/numeric_traits.h
@@ -29,7 +29,9 @@ 
 #ifndef _EXT_NUMERIC_TRAITS
 #define _EXT_NUMERIC_TRAITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/cpp_type_traits.h>
 #include <ext/type_traits.h>
diff --git a/libstdc++-v3/include/ext/pod_char_traits.h b/libstdc++-v3/include/ext/pod_char_traits.h
index 5f60d8a82a9..83386c85680 100644
--- a/libstdc++-v3/include/ext/pod_char_traits.h
+++ b/libstdc++-v3/include/ext/pod_char_traits.h
@@ -32,7 +32,9 @@ 
 #ifndef _POD_CHAR_TRAITS_H
 #define _POD_CHAR_TRAITS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/pointer.h b/libstdc++-v3/include/ext/pointer.h
index 0ead6f53d5f..ab3016e225d 100644
--- a/libstdc++-v3/include/ext/pointer.h
+++ b/libstdc++-v3/include/ext/pointer.h
@@ -36,7 +36,9 @@ 
 #ifndef _POINTER_H
 #define _POINTER_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if _GLIBCXX_HOSTED
 #  include <iosfwd>
diff --git a/libstdc++-v3/include/ext/stdio_filebuf.h b/libstdc++-v3/include/ext/stdio_filebuf.h
index 1f9713bcd15..4a095694942 100644
--- a/libstdc++-v3/include/ext/stdio_filebuf.h
+++ b/libstdc++-v3/include/ext/stdio_filebuf.h
@@ -29,7 +29,9 @@ 
 #ifndef _STDIO_FILEBUF_H
 #define _STDIO_FILEBUF_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/stdio_sync_filebuf.h b/libstdc++-v3/include/ext/stdio_sync_filebuf.h
index f8993ad521a..0f5381d9cb5 100644
--- a/libstdc++-v3/include/ext/stdio_sync_filebuf.h
+++ b/libstdc++-v3/include/ext/stdio_sync_filebuf.h
@@ -29,7 +29,9 @@ 
 #ifndef _STDIO_SYNC_FILEBUF_H
 #define _STDIO_SYNC_FILEBUF_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/string_conversions.h b/libstdc++-v3/include/ext/string_conversions.h
index 2e0755a772e..acbe11fa37b 100644
--- a/libstdc++-v3/include/ext/string_conversions.h
+++ b/libstdc++-v3/include/ext/string_conversions.h
@@ -29,7 +29,9 @@ 
 #ifndef _STRING_CONVERSIONS_H
 #define _STRING_CONVERSIONS_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/type_traits.h b/libstdc++-v3/include/ext/type_traits.h
index 165e1b43da0..651dfd62f3b 100644
--- a/libstdc++-v3/include/ext/type_traits.h
+++ b/libstdc++-v3/include/ext/type_traits.h
@@ -29,7 +29,9 @@ 
 #ifndef _EXT_TYPE_TRAITS
 #define _EXT_TYPE_TRAITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/cpp_type_traits.h>
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index 25a7d82bf6d..22b9a1db842 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -29,7 +29,9 @@ 
 #ifndef _VSTRING_H
 #define _VSTRING_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/vstring_fwd.h b/libstdc++-v3/include/ext/vstring_fwd.h
index f6b6a6f54ca..8c646045c6b 100644
--- a/libstdc++-v3/include/ext/vstring_fwd.h
+++ b/libstdc++-v3/include/ext/vstring_fwd.h
@@ -30,7 +30,9 @@ 
 #ifndef _VSTRING_FWD_H
 #define _VSTRING_FWD_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/vstring_util.h b/libstdc++-v3/include/ext/vstring_util.h
index 364814182f8..8c9c5acaaa9 100644
--- a/libstdc++-v3/include/ext/vstring_util.h
+++ b/libstdc++-v3/include/ext/vstring_util.h
@@ -30,7 +30,9 @@ 
 #ifndef _VSTRING_UTIL_H
 #define _VSTRING_UTIL_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/parallel/algorithmfwd.h b/libstdc++-v3/include/parallel/algorithmfwd.h
index d8d5c85413a..476072b860a 100644
--- a/libstdc++-v3/include/parallel/algorithmfwd.h
+++ b/libstdc++-v3/include/parallel/algorithmfwd.h
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_PARALLEL_ALGORITHMFWD_H
 #define _GLIBCXX_PARALLEL_ALGORITHMFWD_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <parallel/tags.h>
 #include <parallel/settings.h>
diff --git a/libstdc++-v3/include/parallel/numericfwd.h b/libstdc++-v3/include/parallel/numericfwd.h
index 05af27aeedc..7f264867cbb 100644
--- a/libstdc++-v3/include/parallel/numericfwd.h
+++ b/libstdc++-v3/include/parallel/numericfwd.h
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_PARALLEL_NUMERICFWD_H
 #define _GLIBCXX_PARALLEL_NUMERICFWD_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <parallel/tags.h>
 #include <parallel/settings.h>
diff --git a/libstdc++-v3/include/tr1/functional_hash.h b/libstdc++-v3/include/tr1/functional_hash.h
index 57f0eb604ce..01ebfc907db 100644
--- a/libstdc++-v3/include/tr1/functional_hash.h
+++ b/libstdc++-v3/include/tr1/functional_hash.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_TR1_FUNCTIONAL_HASH_H
 #define _GLIBCXX_TR1_FUNCTIONAL_HASH_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/tr1/hashtable.h b/libstdc++-v3/include/tr1/hashtable.h
index bcf178554eb..ebb79eaddb2 100644
--- a/libstdc++-v3/include/tr1/hashtable.h
+++ b/libstdc++-v3/include/tr1/hashtable.h
@@ -31,7 +31,9 @@ 
 #ifndef _GLIBCXX_TR1_HASHTABLE_H
 #define _GLIBCXX_TR1_HASHTABLE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <tr1/hashtable_policy.h>
 #include <ext/alloc_traits.h>
diff --git a/libstdc++-v3/include/tr1/random.h b/libstdc++-v3/include/tr1/random.h
index 449b846aac8..74950c9c906 100644
--- a/libstdc++-v3/include/tr1/random.h
+++ b/libstdc++-v3/include/tr1/random.h
@@ -31,7 +31,9 @@ 
 #ifndef _GLIBCXX_TR1_RANDOM_H
 #define _GLIBCXX_TR1_RANDOM_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/libsupc++/atomic_lockfree_defines.h b/libstdc++-v3/libsupc++/atomic_lockfree_defines.h
index 978aedb392f..cbe488e91b5 100644
--- a/libstdc++-v3/libsupc++/atomic_lockfree_defines.h
+++ b/libstdc++-v3/libsupc++/atomic_lockfree_defines.h
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_ATOMIC_LOCK_FREE_H
 #define _GLIBCXX_ATOMIC_LOCK_FREE_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 /**
  * @addtogroup atomics
diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h
index d63eae6ae4c..f10cb91c329 100644
--- a/libstdc++-v3/libsupc++/cxxabi.h
+++ b/libstdc++-v3/libsupc++/cxxabi.h
@@ -41,7 +41,9 @@ 
 #ifndef _CXXABI_H
 #define _CXXABI_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC visibility push(default)
 
diff --git a/libstdc++-v3/libsupc++/cxxabi_forced.h b/libstdc++-v3/libsupc++/cxxabi_forced.h
index 5759a891770..960900122b7 100644
--- a/libstdc++-v3/libsupc++/cxxabi_forced.h
+++ b/libstdc++-v3/libsupc++/cxxabi_forced.h
@@ -31,7 +31,9 @@ 
 #ifndef _CXXABI_FORCED_H
 #define _CXXABI_FORCED_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC visibility push(default)
 
diff --git a/libstdc++-v3/libsupc++/cxxabi_init_exception.h b/libstdc++-v3/libsupc++/cxxabi_init_exception.h
index cbb3ce33d6f..815aa427b8a 100644
--- a/libstdc++-v3/libsupc++/cxxabi_init_exception.h
+++ b/libstdc++-v3/libsupc++/cxxabi_init_exception.h
@@ -31,7 +31,9 @@ 
 #ifndef _CXXABI_INIT_EXCEPTION_H
 #define _CXXABI_INIT_EXCEPTION_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC visibility push(default)
 
diff --git a/libstdc++-v3/libsupc++/exception.h b/libstdc++-v3/libsupc++/exception.h
index dca58825c3c..41fae8055ec 100644
--- a/libstdc++-v3/libsupc++/exception.h
+++ b/libstdc++-v3/libsupc++/exception.h
@@ -31,7 +31,9 @@ 
 #ifndef __EXCEPTION_H
 #define __EXCEPTION_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/libsupc++/hash_bytes.h b/libstdc++-v3/libsupc++/hash_bytes.h
index f3f965c595f..f79fca279b5 100644
--- a/libstdc++-v3/libsupc++/hash_bytes.h
+++ b/libstdc++-v3/libsupc++/hash_bytes.h
@@ -30,7 +30,9 @@ 
 #ifndef _HASH_BYTES_H
 #define _HASH_BYTES_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/gcc/testsuite/g++.dg/analyzer/fanalyzer-show-events-in-system-headers-default.C b/gcc/testsuite/g++.dg/analyzer/fanalyzer-show-events-in-system-headers-default.C
index 483cefd6ec3..d2381d0af3d 100644
--- a/gcc/testsuite/g++.dg/analyzer/fanalyzer-show-events-in-system-headers-default.C
+++ b/gcc/testsuite/g++.dg/analyzer/fanalyzer-show-events-in-system-headers-default.C
@@ -1,6 +1,7 @@ 
 /* { dg-skip-if "no shared_ptr in C++98" { c++98_only }  } */
 /* { dg-skip-if "requires hosted libstdc++ for memory shared_ptr" { ! hostedlib } } */
 
+#define _GLIBCXX_SYSHDR
 #include <memory>
 
 struct A {int x; int y;};
diff --git a/gcc/testsuite/g++.dg/analyzer/fanalyzer-show-events-in-system-headers-no.C b/gcc/testsuite/g++.dg/analyzer/fanalyzer-show-events-in-system-headers-no.C
index 10d220fa940..e143645074b 100644
--- a/gcc/testsuite/g++.dg/analyzer/fanalyzer-show-events-in-system-headers-no.C
+++ b/gcc/testsuite/g++.dg/analyzer/fanalyzer-show-events-in-system-headers-no.C
@@ -2,6 +2,7 @@ 
 /* { dg-skip-if "no shared_ptr in C++98" { c++98_only }  } */
 /* { dg-skip-if "requires hosted libstdc++ for memory shared_ptr" { ! hostedlib } } */
 
+#define _GLIBCXX_SYSHDR
 #include <memory>
 
 struct A {int x; int y;};
diff --git a/gcc/testsuite/g++.dg/diagnostic/disable.C b/gcc/testsuite/g++.dg/diagnostic/disable.C
index c055c40bd49..464066fd6ff 100644
--- a/gcc/testsuite/g++.dg/diagnostic/disable.C
+++ b/gcc/testsuite/g++.dg/diagnostic/disable.C
@@ -1,6 +1,7 @@ 
 // { dg-options "-Wtemplates -Wmultiple-inheritance -Wvirtual-inheritance -Wnamespaces" }
 // { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } }
 
+#define _GLIBCXX_SYSHDR
 #include <iostream>
 #include <algorithm>
 
diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc
index 33c1f59bb77..f54cd310ebc 100644
--- a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc
@@ -43,10 +43,11 @@  test02()
 // { dg-error "expected initializer" "" { target *-*-* } 35 }
 // { dg-error "expected initializer" "" { target *-*-* } 37 }
 // { dg-error "overflow in addition" "" { target *-*-* } 0 }
-// { dg-error "overflow in multiplication" "" { target *-*-* } 101 }
 // { dg-error "overflow in multiplication" "" { target *-*-* } 103 }
 // { dg-error "overflow in multiplication" "" { target *-*-* } 105 }
+// { dg-error "overflow in multiplication" "" { target *-*-* } 107 }
 // { dg-error "overflow in constant expression" "" { target *-*-* } 0 }
 // { dg-error "narrowing conversion" "" { target *-*-* } 0 }
+// { dg-error "overflow in expression" "" { target *-*-* } 114 }
 // { dg-prune-output "out of range" }
 // { dg-prune-output "not usable in a constant expression" }
diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
index f74513da65f..d901bd9fae2 100644
--- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
@@ -26,6 +26,6 @@  int n1 = std::get<1>(a);
 int n2 = std::get<1>(std::move(a));
 int n3 = std::get<1>(ca);
 
-// { dg-error "static assertion failed" "" { target *-*-* } 392 }
-// { dg-error "static assertion failed" "" { target *-*-* } 401 }
-// { dg-error "static assertion failed" "" { target *-*-* } 410 }
+// { dg-error "static assertion failed" "" { target *-*-* } 394 }
+// { dg-error "static assertion failed" "" { target *-*-* } 403 }
+// { dg-error "static assertion failed" "" { target *-*-* } 412 }
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc
index f06668cff37..adcffb6e629 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc
@@ -46,7 +46,7 @@  test02()
 // { dg-error "value type is destructible" "" { target *-*-* } 0 }
 
 // In Debug Mode the "required from here" errors come from <debug/vector>
-// { dg-error "required from here" "" { target *-*-* } 180 }
+// { dg-error "required from here" "" { target *-*-* } 182 }
 
 // Needed because of PR c++/92193
 // { dg-prune-output "deleted function" }
diff --git a/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc b/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc
index 17242bdf3c7..bf0c5e8b3ee 100644
--- a/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc
+++ b/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc
@@ -38,5 +38,5 @@  test02()
 {
   const Y array[1] = { };
   (void) std::prev(array + 1);
-  // { dg-error "forward_iterator" "" { target *-*-* } 239 }
+  // { dg-error "forward_iterator" "" { target *-*-* } 241 }
 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc
index 458748af28a..36562c66b4c 100644
--- a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc
+++ b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc
@@ -35,4 +35,4 @@  int main()
 }
 
 // { dg-error "required from" "" { target *-*-* } 28 }
-// { dg-error "no type" "" { target *-*-* } 74 }
+// { dg-error "no type" "" { target *-*-* } 76 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc
index c1dde44e118..e297332fee9 100644
--- a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc
+++ b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc
@@ -36,5 +36,5 @@  int main()
 }
 
 // { dg-error "invalid use of incomplete" "" { target *-*-* } 28 } 
-// { dg-error "declaration of" "" { target *-*-* } 103 }
-// { dg-error "declaration of" "" { target *-*-* } 106 }
+// { dg-error "declaration of" "" { target *-*-* } 105 }
+// { dg-error "declaration of" "" { target *-*-* } 108 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
index 5f77c1a652a..2c6c53ba1fc 100644
--- a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
+++ b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
@@ -35,4 +35,4 @@  int main()
 }
 
 // { dg-error "required from" "" { target *-*-* } 28 }
-// { dg-error "no type" "" { target *-*-* } 117 }
+// { dg-error "no type" "" { target *-*-* } 119 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc
index 7f5a304c526..af6ea1c8691 100644
--- a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc
+++ b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc
@@ -36,5 +36,5 @@  int main()
 }
 
 // { dg-error "invalid use of incomplete" "" { target *-*-* } 28 } 
-// { dg-error "declaration of" "" { target *-*-* } 146 }
-// { dg-error "declaration of" "" { target *-*-* } 149 }
+// { dg-error "declaration of" "" { target *-*-* } 148 }
+// { dg-error "declaration of" "" { target *-*-* } 151 }
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 768c2991ec2..b3423d7957a 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -707,7 +707,7 @@  AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
   AC_SUBST(OPTIMIZE_CXXFLAGS)
 
-  WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=19 -Wsystem-headers"
+  WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=19"
   AC_SUBST(WARN_FLAGS)
 ])
 
diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc
index 1519603f6b5..d28424fa39d 100644
--- a/libstdc++-v3/include/bits/basic_ios.tcc
+++ b/libstdc++-v3/include/bits/basic_ios.tcc
@@ -30,7 +30,9 @@ 
 #ifndef _BASIC_IOS_TCC
 #define _BASIC_IOS_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 8a764855698..2c17d258bfe 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -39,7 +39,9 @@ 
 #ifndef _BASIC_STRING_TCC
 #define _BASIC_STRING_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions"
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 7b246ad59d2..9f250d33c45 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -34,7 +34,9 @@ 
 #ifndef _FSTREAM_TCC
 #define _FSTREAM_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc
index 23a7c849777..e8957fd2c3b 100644
--- a/libstdc++-v3/include/bits/istream.tcc
+++ b/libstdc++-v3/include/bits/istream.tcc
@@ -34,7 +34,9 @@ 
 #ifndef _ISTREAM_TCC
 #define _ISTREAM_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
diff --git a/libstdc++-v3/include/bits/locale_classes.tcc b/libstdc++-v3/include/bits/locale_classes.tcc
index 4f3af2461a5..2b78008e9ae 100644
--- a/libstdc++-v3/include/bits/locale_classes.tcc
+++ b/libstdc++-v3/include/bits/locale_classes.tcc
@@ -34,8 +34,9 @@ 
 #ifndef _LOCALE_CLASSES_TCC
 #define _LOCALE_CLASSES_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
-
+#endif
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
 #pragma GCC diagnostic ignored "-Wvariadic-macros"
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index 4e9bf6fb8f9..14e87ab0ed3 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -30,8 +30,9 @@ 
 #ifndef _LOCALE_FACETS_TCC
 #define _LOCALE_FACETS_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
-
+#endif
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
 
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 72136f42f08..7b597c86aea 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -30,7 +30,9 @@ 
 #ifndef _LOCALE_FACETS_NONIO_TCC
 #define _LOCALE_FACETS_NONIO_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc
index 7aeb23ad38d..06cf2da1e07 100644
--- a/libstdc++-v3/include/bits/ostream.tcc
+++ b/libstdc++-v3/include/bits/ostream.tcc
@@ -34,8 +34,9 @@ 
 #ifndef _OSTREAM_TCC
 #define _OSTREAM_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
-
+#endif
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
 
diff --git a/libstdc++-v3/include/bits/sstream.tcc b/libstdc++-v3/include/bits/sstream.tcc
index 7eb5561b630..e6a06d13fff 100644
--- a/libstdc++-v3/include/bits/sstream.tcc
+++ b/libstdc++-v3/include/bits/sstream.tcc
@@ -34,8 +34,9 @@ 
 #ifndef _SSTREAM_TCC
 #define _SSTREAM_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
-
+#endif
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
 
diff --git a/libstdc++-v3/include/bits/streambuf.tcc b/libstdc++-v3/include/bits/streambuf.tcc
index 0c28033f491..991c27e19a7 100644
--- a/libstdc++-v3/include/bits/streambuf.tcc
+++ b/libstdc++-v3/include/bits/streambuf.tcc
@@ -34,7 +34,9 @@ 
 #ifndef _STREAMBUF_TCC
 #define _STREAMBUF_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
diff --git a/libstdc++-v3/include/bits/string_view.tcc b/libstdc++-v3/include/bits/string_view.tcc
index 5fa50493db7..a9ba668d05c 100644
--- a/libstdc++-v3/include/bits/string_view.tcc
+++ b/libstdc++-v3/include/bits/string_view.tcc
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_STRING_VIEW_TCC
 #define _GLIBCXX_STRING_VIEW_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201703L
 
diff --git a/libstdc++-v3/include/bits/version.tpl b/libstdc++-v3/include/bits/version.tpl
index 4a7d5e29c10..d4cb88f40fa 100644
--- a/libstdc++-v3/include/bits/version.tpl
+++ b/libstdc++-v3/include/bits/version.tpl
@@ -44,7 +44,9 @@  h
 // if unwanted, to permit bits and other FTMs to depend on them for condtional
 // computation without exposing extra FTMs to user code.
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 /*{
diff --git a/libstdc++-v3/include/experimental/bits/string_view.tcc b/libstdc++-v3/include/experimental/bits/string_view.tcc
index 80de34d7dd4..c0e1ab56d5e 100644
--- a/libstdc++-v3/include/experimental/bits/string_view.tcc
+++ b/libstdc++-v3/include/experimental/bits/string_view.tcc
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_STRING_VIEW_TCC
 #define _GLIBCXX_EXPERIMENTAL_STRING_VIEW_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201402L
 
diff --git a/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp b/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp
index 52c83296e62..8fdec6d5754 100644
--- a/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp
+++ b/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp
@@ -40,7 +40,9 @@ 
 
 #ifdef PB_DS_CLASS_C_DEC
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace detail
 {
diff --git a/libstdc++-v3/include/ext/random.tcc b/libstdc++-v3/include/ext/random.tcc
index c6c3fbeec83..822b52f5f8a 100644
--- a/libstdc++-v3/include/ext/random.tcc
+++ b/libstdc++-v3/include/ext/random.tcc
@@ -30,7 +30,9 @@ 
 #ifndef _EXT_RANDOM_TCC
 #define _EXT_RANDOM_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/vstring.tcc b/libstdc++-v3/include/ext/vstring.tcc
index 86fcfaa5758..39837d5cbf8 100644
--- a/libstdc++-v3/include/ext/vstring.tcc
+++ b/libstdc++-v3/include/ext/vstring.tcc
@@ -30,7 +30,9 @@ 
 #ifndef _VSTRING_TCC
 #define _VSTRING_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/tr2/bool_set.tcc b/libstdc++-v3/include/tr2/bool_set.tcc
index 05f16efbcfc..87fa2ebf83a 100644
--- a/libstdc++-v3/include/tr2/bool_set.tcc
+++ b/libstdc++-v3/include/tr2/bool_set.tcc
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR2_BOOL_SET_TCC
 #define _GLIBCXX_TR2_BOOL_SET_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/tr2/dynamic_bitset.tcc b/libstdc++-v3/include/tr2/dynamic_bitset.tcc
index 5aac7d88ee3..7400b268d32 100644
--- a/libstdc++-v3/include/tr2/dynamic_bitset.tcc
+++ b/libstdc++-v3/include/tr2/dynamic_bitset.tcc
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_TR2_DYNAMIC_BITSET_TCC
 #define _GLIBCXX_TR2_DYNAMIC_BITSET_TCC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index de05e63de4c..e115ee55739 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -55720,7 +55720,7 @@  $as_echo "$gxx_include_dir" >&6; }
   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
 
 
-  WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=19 -Wsystem-headers"
+  WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=19"
 
 
 
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 16c67b80e76..29d795f687c 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_CXX_CONFIG_H
 #define _GLIBCXX_CXX_CONFIG_H 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wvariadic-macros"
diff --git a/libstdc++-v3/include/c/cassert b/libstdc++-v3/include/c/cassert
index ef6e844a72b..8163d0ca9c5 100644
--- a/libstdc++-v3/include/c/cassert
+++ b/libstdc++-v3/include/c/cassert
@@ -28,7 +28,9 @@ 
 
 // No include guards on this header...
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cctype b/libstdc++-v3/include/c/cctype
index a7a59551d86..cc5ebf57465 100644
--- a/libstdc++-v3/include/c/cctype
+++ b/libstdc++-v3/include/c/cctype
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CCTYPE
 #define _GLIBCXX_CCTYPE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cerrno b/libstdc++-v3/include/c/cerrno
index 29bf0b403aa..18750543bc0 100644
--- a/libstdc++-v3/include/c/cerrno
+++ b/libstdc++-v3/include/c/cerrno
@@ -38,7 +38,9 @@ 
 #ifndef _GLIBCXX_CERRNO
 #define _GLIBCXX_CERRNO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cfloat b/libstdc++-v3/include/c/cfloat
index 1f9edada950..9eab4fb1c76 100644
--- a/libstdc++-v3/include/c/cfloat
+++ b/libstdc++-v3/include/c/cfloat
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CFLOAT
 #define _GLIBCXX_CFLOAT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/ciso646 b/libstdc++-v3/include/c/ciso646
index 2b6f797c580..bd04ef3f22a 100644
--- a/libstdc++-v3/include/c/ciso646
+++ b/libstdc++-v3/include/c/ciso646
@@ -32,7 +32,9 @@ 
 #ifndef _GLIBCXX_CISO646
 #define _GLIBCXX_CISO646
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #endif
diff --git a/libstdc++-v3/include/c/climits b/libstdc++-v3/include/c/climits
index 846fe190707..9728ca5832f 100644
--- a/libstdc++-v3/include/c/climits
+++ b/libstdc++-v3/include/c/climits
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CLIMITS
 #define _GLIBCXX_CLIMITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/clocale b/libstdc++-v3/include/c/clocale
index 62d85ed6609..183d22479a8 100644
--- a/libstdc++-v3/include/c/clocale
+++ b/libstdc++-v3/include/c/clocale
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CLOCALE
 #define _GLIBCXX_CLOCALE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cmath b/libstdc++-v3/include/c/cmath
index 371ee59986c..43ff06aba75 100644
--- a/libstdc++-v3/include/c/cmath
+++ b/libstdc++-v3/include/c/cmath
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CMATH
 #define _GLIBCXX_CMATH 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/c/csetjmp b/libstdc++-v3/include/c/csetjmp
index acf113a0c5a..10e5e933a52 100644
--- a/libstdc++-v3/include/c/csetjmp
+++ b/libstdc++-v3/include/c/csetjmp
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSETJMP
 #define _GLIBCXX_CSETJMP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/csignal b/libstdc++-v3/include/c/csignal
index c04bb6042f4..987d457e48e 100644
--- a/libstdc++-v3/include/c/csignal
+++ b/libstdc++-v3/include/c/csignal
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSIGNAL
 #define _GLIBCXX_CSIGNAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cstdarg b/libstdc++-v3/include/c/cstdarg
index 7648662680c..520c3399c1c 100644
--- a/libstdc++-v3/include/c/cstdarg
+++ b/libstdc++-v3/include/c/cstdarg
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSTDARG
 #define _GLIBCXX_CSTDARG 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cstddef b/libstdc++-v3/include/c/cstddef
index e1435b94556..657363cf249 100644
--- a/libstdc++-v3/include/c/cstddef
+++ b/libstdc++-v3/include/c/cstddef
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSTDDEF
 #define _GLIBCXX_CSTDDEF 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cstdio b/libstdc++-v3/include/c/cstdio
index 99aead4ef9c..4e044fc62fd 100644
--- a/libstdc++-v3/include/c/cstdio
+++ b/libstdc++-v3/include/c/cstdio
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSTDIO
 #define _GLIBCXX_CSTDIO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cstdlib b/libstdc++-v3/include/c/cstdlib
index 75e6382c01b..7aaf8d10987 100644
--- a/libstdc++-v3/include/c/cstdlib
+++ b/libstdc++-v3/include/c/cstdlib
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSTDLIB
 #define _GLIBCXX_CSTDLIB 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cstring b/libstdc++-v3/include/c/cstring
index 05d75182a7a..b0dae9dfef1 100644
--- a/libstdc++-v3/include/c/cstring
+++ b/libstdc++-v3/include/c/cstring
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSTRING
 #define _GLIBCXX_CSTRING 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/ctime b/libstdc++-v3/include/c/ctime
index 73e2a7a0167..fb6ba3f2560 100644
--- a/libstdc++-v3/include/c/ctime
+++ b/libstdc++-v3/include/c/ctime
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CTIME
 #define _GLIBCXX_CTIME 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c/cuchar b/libstdc++-v3/include/c/cuchar
index 430d1ff50ba..58aa822e2ce 100644
--- a/libstdc++-v3/include/c/cuchar
+++ b/libstdc++-v3/include/c/cuchar
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CUCHAR
 #define _GLIBCXX_CUCHAR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/c/cwchar b/libstdc++-v3/include/c/cwchar
index 921de267750..7f6de347de5 100644
--- a/libstdc++-v3/include/c/cwchar
+++ b/libstdc++-v3/include/c/cwchar
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CWCHAR
 #define _GLIBCXX_CWCHAR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <cstddef>
diff --git a/libstdc++-v3/include/c/cwctype b/libstdc++-v3/include/c/cwctype
index 0d2f55d9d6d..9505dd93bb9 100644
--- a/libstdc++-v3/include/c/cwctype
+++ b/libstdc++-v3/include/c/cwctype
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CWCTYPE
 #define _GLIBCXX_CWCTYPE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // include_next
diff --git a/libstdc++-v3/include/c_global/cassert b/libstdc++-v3/include/c_global/cassert
index 87b61bdb6ad..ed05d538744 100644
--- a/libstdc++-v3/include/c_global/cassert
+++ b/libstdc++-v3/include/c_global/cassert
@@ -38,7 +38,9 @@ 
 
 // No include guards on this header...
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <assert.h>
diff --git a/libstdc++-v3/include/c_global/ccomplex b/libstdc++-v3/include/c_global/ccomplex
index 899d41cf856..ee1166aaecb 100644
--- a/libstdc++-v3/include/c_global/ccomplex
+++ b/libstdc++-v3/include/c_global/ccomplex
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CCOMPLEX
 #define _GLIBCXX_CCOMPLEX 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/c_global/cctype b/libstdc++-v3/include/c_global/cctype
index 0c6d027ed24..9eec9cada06 100644
--- a/libstdc++-v3/include/c_global/cctype
+++ b/libstdc++-v3/include/c_global/cctype
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CCTYPE
 #define _GLIBCXX_CCTYPE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <ctype.h>
diff --git a/libstdc++-v3/include/c_global/cerrno b/libstdc++-v3/include/c_global/cerrno
index 5cad0795b27..e11a412bb62 100644
--- a/libstdc++-v3/include/c_global/cerrno
+++ b/libstdc++-v3/include/c_global/cerrno
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CERRNO
 #define _GLIBCXX_CERRNO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <errno.h>
diff --git a/libstdc++-v3/include/c_global/cfenv b/libstdc++-v3/include/c_global/cfenv
index fd32daa8d2d..b63f643696b 100644
--- a/libstdc++-v3/include/c_global/cfenv
+++ b/libstdc++-v3/include/c_global/cfenv
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CFENV
 #define _GLIBCXX_CFENV 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/c_global/cfloat b/libstdc++-v3/include/c_global/cfloat
index bc90e75ba57..622aba83391 100644
--- a/libstdc++-v3/include/c_global/cfloat
+++ b/libstdc++-v3/include/c_global/cfloat
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CFLOAT
 #define _GLIBCXX_CFLOAT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <float.h>
diff --git a/libstdc++-v3/include/c_global/cinttypes b/libstdc++-v3/include/c_global/cinttypes
index a6f3dad5ccc..6ab84e3f586 100644
--- a/libstdc++-v3/include/c_global/cinttypes
+++ b/libstdc++-v3/include/c_global/cinttypes
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CINTTYPES
 #define _GLIBCXX_CINTTYPES 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/c_global/ciso646 b/libstdc++-v3/include/c_global/ciso646
index 5b039930056..6e26f9be12e 100644
--- a/libstdc++-v3/include/c_global/ciso646
+++ b/libstdc++-v3/include/c_global/ciso646
@@ -32,7 +32,10 @@ 
 #ifndef _GLIBCXX_CISO646
 #define _GLIBCXX_CISO646
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
+
 #endif
diff --git a/libstdc++-v3/include/c_global/climits b/libstdc++-v3/include/c_global/climits
index ae1390bdc1d..5970a6cdb3b 100644
--- a/libstdc++-v3/include/c_global/climits
+++ b/libstdc++-v3/include/c_global/climits
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CLIMITS
 #define _GLIBCXX_CLIMITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <limits.h>
diff --git a/libstdc++-v3/include/c_global/clocale b/libstdc++-v3/include/c_global/clocale
index b795f5759d1..c9aeb744175 100644
--- a/libstdc++-v3/include/c_global/clocale
+++ b/libstdc++-v3/include/c_global/clocale
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CLOCALE
 #define _GLIBCXX_CLOCALE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <locale.h>
diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath
index 2b7186c8c27..ca84f951400 100644
--- a/libstdc++-v3/include/c_global/cmath
+++ b/libstdc++-v3/include/c_global/cmath
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CMATH
 #define _GLIBCXX_CMATH 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h>
 
diff --git a/libstdc++-v3/include/c_global/csetjmp b/libstdc++-v3/include/c_global/csetjmp
index 6b1a484d539..645d94d8ab1 100644
--- a/libstdc++-v3/include/c_global/csetjmp
+++ b/libstdc++-v3/include/c_global/csetjmp
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSETJMP
 #define _GLIBCXX_CSETJMP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <setjmp.h>
diff --git a/libstdc++-v3/include/c_global/csignal b/libstdc++-v3/include/c_global/csignal
index dc8a3e00b29..6f6613cbde4 100644
--- a/libstdc++-v3/include/c_global/csignal
+++ b/libstdc++-v3/include/c_global/csignal
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSIGNAL
 #define _GLIBCXX_CSIGNAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <signal.h>
diff --git a/libstdc++-v3/include/c_global/cstdalign b/libstdc++-v3/include/c_global/cstdalign
index f7e4191380c..4f610588425 100644
--- a/libstdc++-v3/include/c_global/cstdalign
+++ b/libstdc++-v3/include/c_global/cstdalign
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSTDALIGN
 #define _GLIBCXX_CSTDALIGN 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 #  include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/c_global/cstdarg b/libstdc++-v3/include/c_global/cstdarg
index fd960c8ca4b..f6c50f78ff1 100644
--- a/libstdc++-v3/include/c_global/cstdarg
+++ b/libstdc++-v3/include/c_global/cstdarg
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTDARG
 #define _GLIBCXX_CSTDARG 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #undef __need___va_list
 #include <bits/c++config.h>
diff --git a/libstdc++-v3/include/c_global/cstdbool b/libstdc++-v3/include/c_global/cstdbool
index 5f4bc41739a..8d2e75df33f 100644
--- a/libstdc++-v3/include/c_global/cstdbool
+++ b/libstdc++-v3/include/c_global/cstdbool
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSTDBOOL
 #define _GLIBCXX_CSTDBOOL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 #  include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/c_global/cstddef b/libstdc++-v3/include/c_global/cstddef
index f49f56ae372..19611f35399 100644
--- a/libstdc++-v3/include/c_global/cstddef
+++ b/libstdc++-v3/include/c_global/cstddef
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTDDEF
 #define _GLIBCXX_CSTDDEF 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #undef __need_wchar_t
 #undef __need_ptrdiff_t
diff --git a/libstdc++-v3/include/c_global/cstdint b/libstdc++-v3/include/c_global/cstdint
index d31dc7550fa..e2030824c41 100644
--- a/libstdc++-v3/include/c_global/cstdint
+++ b/libstdc++-v3/include/c_global/cstdint
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CSTDINT
 #define _GLIBCXX_CSTDINT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio
index 2b1f4fe78cd..859b7a5b6ac 100644
--- a/libstdc++-v3/include/c_global/cstdio
+++ b/libstdc++-v3/include/c_global/cstdio
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTDIO
 #define _GLIBCXX_CSTDIO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <stdio.h>
diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib
index 5d83bafc933..a5df4cd9cb1 100644
--- a/libstdc++-v3/include/c_global/cstdlib
+++ b/libstdc++-v3/include/c_global/cstdlib
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTDLIB
 #define _GLIBCXX_CSTDLIB 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/c_global/cstring b/libstdc++-v3/include/c_global/cstring
index eba409fd613..d679c77165b 100644
--- a/libstdc++-v3/include/c_global/cstring
+++ b/libstdc++-v3/include/c_global/cstring
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTRING
 #define _GLIBCXX_CSTRING 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_freestanding_cstring
 #include <bits/version.h>
diff --git a/libstdc++-v3/include/c_global/ctgmath b/libstdc++-v3/include/c_global/ctgmath
index 188a3107e40..79c1a029f41 100644
--- a/libstdc++-v3/include/c_global/ctgmath
+++ b/libstdc++-v3/include/c_global/ctgmath
@@ -26,7 +26,9 @@ 
  *  This is a Standard C++ Library header.
  */
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #ifndef _GLIBCXX_CTGMATH
 #define _GLIBCXX_CTGMATH 1
diff --git a/libstdc++-v3/include/c_global/ctime b/libstdc++-v3/include/c_global/ctime
index da16ba686db..231de0dcf51 100644
--- a/libstdc++-v3/include/c_global/ctime
+++ b/libstdc++-v3/include/c_global/ctime
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CTIME
 #define _GLIBCXX_CTIME 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <time.h>
diff --git a/libstdc++-v3/include/c_global/cuchar b/libstdc++-v3/include/c_global/cuchar
index ebc3077c4eb..0b9f051f15d 100644
--- a/libstdc++-v3/include/c_global/cuchar
+++ b/libstdc++-v3/include/c_global/cuchar
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CUCHAR
 #define _GLIBCXX_CUCHAR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/c_global/cwchar b/libstdc++-v3/include/c_global/cwchar
index fabe178429f..1bdb071002f 100644
--- a/libstdc++-v3/include/c_global/cwchar
+++ b/libstdc++-v3/include/c_global/cwchar
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CWCHAR
 #define _GLIBCXX_CWCHAR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/c_global/cwctype b/libstdc++-v3/include/c_global/cwctype
index 54c8572426a..c6e8d239944 100644
--- a/libstdc++-v3/include/c_global/cwctype
+++ b/libstdc++-v3/include/c_global/cwctype
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CWCTYPE
 #define _GLIBCXX_CWCTYPE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/c_std/cassert b/libstdc++-v3/include/c_std/cassert
index 853cb91a007..5bd10ed6575 100644
--- a/libstdc++-v3/include/c_std/cassert
+++ b/libstdc++-v3/include/c_std/cassert
@@ -38,7 +38,9 @@ 
 
 // No include guards on this header...
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <assert.h>
diff --git a/libstdc++-v3/include/c_std/cctype b/libstdc++-v3/include/c_std/cctype
index 8ecf7822704..aec3dd0e9b9 100644
--- a/libstdc++-v3/include/c_std/cctype
+++ b/libstdc++-v3/include/c_std/cctype
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CCTYPE
 #define _GLIBCXX_CCTYPE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <ctype.h>
diff --git a/libstdc++-v3/include/c_std/cerrno b/libstdc++-v3/include/c_std/cerrno
index f68f8b3a437..cb2c0f4d955 100644
--- a/libstdc++-v3/include/c_std/cerrno
+++ b/libstdc++-v3/include/c_std/cerrno
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CERRNO
 #define _GLIBCXX_CERRNO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <errno.h>
diff --git a/libstdc++-v3/include/c_std/cfloat b/libstdc++-v3/include/c_std/cfloat
index e7c1596c3ee..670bcc1eada 100644
--- a/libstdc++-v3/include/c_std/cfloat
+++ b/libstdc++-v3/include/c_std/cfloat
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CFLOAT
 #define _GLIBCXX_CFLOAT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <float.h>
diff --git a/libstdc++-v3/include/c_std/ciso646 b/libstdc++-v3/include/c_std/ciso646
index d69d4ca15f5..7971f0d0c31 100644
--- a/libstdc++-v3/include/c_std/ciso646
+++ b/libstdc++-v3/include/c_std/ciso646
@@ -32,7 +32,9 @@ 
 #ifndef _GLIBCXX_CISO646
 #define _GLIBCXX_CISO646
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #endif
diff --git a/libstdc++-v3/include/c_std/climits b/libstdc++-v3/include/c_std/climits
index dc38b869502..0976eb1fc15 100644
--- a/libstdc++-v3/include/c_std/climits
+++ b/libstdc++-v3/include/c_std/climits
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CLIMITS
 #define _GLIBCXX_CLIMITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <limits.h>
diff --git a/libstdc++-v3/include/c_std/clocale b/libstdc++-v3/include/c_std/clocale
index d43bddbbf1b..da1d5bad2ce 100644
--- a/libstdc++-v3/include/c_std/clocale
+++ b/libstdc++-v3/include/c_std/clocale
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CLOCALE
 #define _GLIBCXX_CLOCALE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <locale.h>
diff --git a/libstdc++-v3/include/c_std/cmath b/libstdc++-v3/include/c_std/cmath
index 76b04bd4a77..ff7a11ba9f2 100644
--- a/libstdc++-v3/include/c_std/cmath
+++ b/libstdc++-v3/include/c_std/cmath
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CMATH
 #define _GLIBCXX_CMATH 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/cpp_type_traits.h>
diff --git a/libstdc++-v3/include/c_std/csetjmp b/libstdc++-v3/include/c_std/csetjmp
index 49cea5575bc..bba568ffe84 100644
--- a/libstdc++-v3/include/c_std/csetjmp
+++ b/libstdc++-v3/include/c_std/csetjmp
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSETJMP
 #define _GLIBCXX_CSETJMP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <setjmp.h>
diff --git a/libstdc++-v3/include/c_std/csignal b/libstdc++-v3/include/c_std/csignal
index 08ce9a1a4f7..b19d4b8444f 100644
--- a/libstdc++-v3/include/c_std/csignal
+++ b/libstdc++-v3/include/c_std/csignal
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSIGNAL
 #define _GLIBCXX_CSIGNAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <signal.h>
diff --git a/libstdc++-v3/include/c_std/cstdarg b/libstdc++-v3/include/c_std/cstdarg
index 65ddd28b619..4c086954a86 100644
--- a/libstdc++-v3/include/c_std/cstdarg
+++ b/libstdc++-v3/include/c_std/cstdarg
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTDARG
 #define _GLIBCXX_CSTDARG 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <stdarg.h>
diff --git a/libstdc++-v3/include/c_std/cstddef b/libstdc++-v3/include/c_std/cstddef
index 8199fb93df5..2236d52f936 100644
--- a/libstdc++-v3/include/c_std/cstddef
+++ b/libstdc++-v3/include/c_std/cstddef
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTDDEF
 #define _GLIBCXX_CSTDDEF 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <stddef.h>
diff --git a/libstdc++-v3/include/c_std/cstdio b/libstdc++-v3/include/c_std/cstdio
index ee3ca3940e1..d57f2cfec5d 100644
--- a/libstdc++-v3/include/c_std/cstdio
+++ b/libstdc++-v3/include/c_std/cstdio
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTDIO
 #define _GLIBCXX_CSTDIO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <stdio.h>
diff --git a/libstdc++-v3/include/c_std/cstdlib b/libstdc++-v3/include/c_std/cstdlib
index db39abf6cc5..5da1739e07b 100644
--- a/libstdc++-v3/include/c_std/cstdlib
+++ b/libstdc++-v3/include/c_std/cstdlib
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTDLIB
 #define _GLIBCXX_CSTDLIB 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/c_std/cstring b/libstdc++-v3/include/c_std/cstring
index 5489dcd5d6e..c043383fb38 100644
--- a/libstdc++-v3/include/c_std/cstring
+++ b/libstdc++-v3/include/c_std/cstring
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CSTRING
 #define _GLIBCXX_CSTRING 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <string.h>
diff --git a/libstdc++-v3/include/c_std/ctime b/libstdc++-v3/include/c_std/ctime
index 9500823f178..b2c92ece18a 100644
--- a/libstdc++-v3/include/c_std/ctime
+++ b/libstdc++-v3/include/c_std/ctime
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CTIME
 #define _GLIBCXX_CTIME 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <time.h>
diff --git a/libstdc++-v3/include/c_std/cuchar b/libstdc++-v3/include/c_std/cuchar
index 8aa0710c8a6..7a3efd790b4 100644
--- a/libstdc++-v3/include/c_std/cuchar
+++ b/libstdc++-v3/include/c_std/cuchar
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CUCHAR
 #define _GLIBCXX_CUCHAR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/c_std/cwchar b/libstdc++-v3/include/c_std/cwchar
index a16cdf9c018..6608f40307b 100644
--- a/libstdc++-v3/include/c_std/cwchar
+++ b/libstdc++-v3/include/c_std/cwchar
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CWCHAR
 #define _GLIBCXX_CWCHAR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/c_std/cwctype b/libstdc++-v3/include/c_std/cwctype
index ab63bcf0efc..ae90a340d54 100644
--- a/libstdc++-v3/include/c_std/cwctype
+++ b/libstdc++-v3/include/c_std/cwctype
@@ -39,7 +39,9 @@ 
 #ifndef _GLIBCXX_CWCTYPE
 #define _GLIBCXX_CWCTYPE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/debug/array b/libstdc++-v3/include/debug/array
index 9cb3aca5998..8931f0eadf9 100644
--- a/libstdc++-v3/include/debug/array
+++ b/libstdc++-v3/include/debug/array
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_ARRAY
 #define _GLIBCXX_DEBUG_ARRAY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <array>
 
diff --git a/libstdc++-v3/include/debug/bitset b/libstdc++-v3/include/debug/bitset
index a0d62f52822..f464a641999 100644
--- a/libstdc++-v3/include/debug/bitset
+++ b/libstdc++-v3/include/debug/bitset
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_BITSET
 #define _GLIBCXX_DEBUG_BITSET
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bitset>
 #include <debug/safe_sequence.h>
diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque
index 3c642152ce8..8f15ea50309 100644
--- a/libstdc++-v3/include/debug/deque
+++ b/libstdc++-v3/include/debug/deque
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_DEQUE
 #define _GLIBCXX_DEBUG_DEQUE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
diff --git a/libstdc++-v3/include/debug/forward_list b/libstdc++-v3/include/debug/forward_list
index ff793f28c21..3f94a9098e8 100644
--- a/libstdc++-v3/include/debug/forward_list
+++ b/libstdc++-v3/include/debug/forward_list
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_FORWARD_LIST
 #define _GLIBCXX_DEBUG_FORWARD_LIST 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list
index e010a69bf36..60752b4dc8b 100644
--- a/libstdc++-v3/include/debug/list
+++ b/libstdc++-v3/include/debug/list
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_LIST
 #define _GLIBCXX_DEBUG_LIST 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
diff --git a/libstdc++-v3/include/debug/map b/libstdc++-v3/include/debug/map
index 60ca4bd011a..3d8406c4b45 100644
--- a/libstdc++-v3/include/debug/map
+++ b/libstdc++-v3/include/debug/map
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_MAP
 #define _GLIBCXX_DEBUG_MAP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
diff --git a/libstdc++-v3/include/debug/set b/libstdc++-v3/include/debug/set
index 40e7bc89922..0eaf54e7ef7 100644
--- a/libstdc++-v3/include/debug/set
+++ b/libstdc++-v3/include/debug/set
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_SET
 #define _GLIBCXX_DEBUG_SET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string
index 0d39a97a530..1b245dbdfc4 100644
--- a/libstdc++-v3/include/debug/string
+++ b/libstdc++-v3/include/debug/string
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_STRING
 #define _GLIBCXX_DEBUG_STRING 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <string>
 #include <debug/safe_sequence.h>
diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map
index 8a969d81740..1acafd8face 100644
--- a/libstdc++-v3/include/debug/unordered_map
+++ b/libstdc++-v3/include/debug/unordered_map
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_UNORDERED_MAP
 #define _GLIBCXX_DEBUG_UNORDERED_MAP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set
index f6a8b66aff9..7f199a93d2b 100644
--- a/libstdc++-v3/include/debug/unordered_set
+++ b/libstdc++-v3/include/debug/unordered_set
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_UNORDERED_SET
 #define _GLIBCXX_DEBUG_UNORDERED_SET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector
index 216822975a2..fe43a372485 100644
--- a/libstdc++-v3/include/debug/vector
+++ b/libstdc++-v3/include/debug/vector
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_DEBUG_VECTOR
 #define _GLIBCXX_DEBUG_VECTOR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
diff --git a/libstdc++-v3/include/decimal/decimal b/libstdc++-v3/include/decimal/decimal
index a64ddde4756..1d9e0340d7c 100644
--- a/libstdc++-v3/include/decimal/decimal
+++ b/libstdc++-v3/include/decimal/decimal
@@ -31,7 +31,9 @@ 
 #ifndef _GLIBCXX_DECIMAL
 #define _GLIBCXX_DECIMAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // DF suffix
diff --git a/libstdc++-v3/include/experimental/algorithm b/libstdc++-v3/include/experimental/algorithm
index 1953dabfeba..49403c907ee 100644
--- a/libstdc++-v3/include/experimental/algorithm
+++ b/libstdc++-v3/include/experimental/algorithm
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_ALGORITHM
 #define _GLIBCXX_EXPERIMENTAL_ALGORITHM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any
index 3db30df5c75..79b626824fe 100644
--- a/libstdc++-v3/include/experimental/any
+++ b/libstdc++-v3/include/experimental/any
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_ANY
 #define _GLIBCXX_EXPERIMENTAL_ANY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/array b/libstdc++-v3/include/experimental/array
index bb46e0f49a2..14a2e6ee138 100644
--- a/libstdc++-v3/include/experimental/array
+++ b/libstdc++-v3/include/experimental/array
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_ARRAY
 #define _GLIBCXX_EXPERIMENTAL_ARRAY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/buffer b/libstdc++-v3/include/experimental/buffer
index 054150e202a..87137dca25c 100644
--- a/libstdc++-v3/include/experimental/buffer
+++ b/libstdc++-v3/include/experimental/buffer
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_BUFFER
 #define _GLIBCXX_EXPERIMENTAL_BUFFER 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/chrono b/libstdc++-v3/include/experimental/chrono
index c5395ca21e9..61ca839ba79 100644
--- a/libstdc++-v3/include/experimental/chrono
+++ b/libstdc++-v3/include/experimental/chrono
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_CHRONO
 #define _GLIBCXX_EXPERIMENTAL_CHRONO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/contract b/libstdc++-v3/include/experimental/contract
index 84f4433231f..98d42ba1386 100644
--- a/libstdc++-v3/include/experimental/contract
+++ b/libstdc++-v3/include/experimental/contract
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_CONTRACT
 #define _GLIBCXX_CONTRACT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201703L
 
diff --git a/libstdc++-v3/include/experimental/deque b/libstdc++-v3/include/experimental/deque
index de5d46c1320..3ee39dea7b8 100644
--- a/libstdc++-v3/include/experimental/deque
+++ b/libstdc++-v3/include/experimental/deque
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_DEQUE
 #define _GLIBCXX_EXPERIMENTAL_DEQUE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/executor b/libstdc++-v3/include/experimental/executor
index f64783b44c9..cce53478199 100644
--- a/libstdc++-v3/include/experimental/executor
+++ b/libstdc++-v3/include/experimental/executor
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_EXECUTOR
 #define _GLIBCXX_EXPERIMENTAL_EXECUTOR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/filesystem b/libstdc++-v3/include/experimental/filesystem
index 82df0759db5..182b148406f 100644
--- a/libstdc++-v3/include/experimental/filesystem
+++ b/libstdc++-v3/include/experimental/filesystem
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_FILESYSTEM
 #define _GLIBCXX_EXPERIMENTAL_FILESYSTEM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/forward_list b/libstdc++-v3/include/experimental/forward_list
index 35d50f4982b..e1e3b03eaea 100644
--- a/libstdc++-v3/include/experimental/forward_list
+++ b/libstdc++-v3/include/experimental/forward_list
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_FORWARD_LIST
 #define _GLIBCXX_EXPERIMENTAL_FORWARD_LIST 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/functional b/libstdc++-v3/include/experimental/functional
index b1451734631..cf420af39ce 100644
--- a/libstdc++-v3/include/experimental/functional
+++ b/libstdc++-v3/include/experimental/functional
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_FUNCTIONAL
 #define _GLIBCXX_EXPERIMENTAL_FUNCTIONAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/internet b/libstdc++-v3/include/experimental/internet
index 3f5090cfa70..d6b1319adca 100644
--- a/libstdc++-v3/include/experimental/internet
+++ b/libstdc++-v3/include/experimental/internet
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_INTERNET
 #define _GLIBCXX_EXPERIMENTAL_INTERNET
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/io_context b/libstdc++-v3/include/experimental/io_context
index 8b0dba7d5fa..3bcc145f98a 100644
--- a/libstdc++-v3/include/experimental/io_context
+++ b/libstdc++-v3/include/experimental/io_context
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_IO_SERVICE
 #define _GLIBCXX_EXPERIMENTAL_IO_SERVICE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/iterator b/libstdc++-v3/include/experimental/iterator
index 51ecd29f5a3..96dfe84de2a 100644
--- a/libstdc++-v3/include/experimental/iterator
+++ b/libstdc++-v3/include/experimental/iterator
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_ITERATOR
 #define _GLIBCXX_EXPERIMENTAL_ITERATOR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/list b/libstdc++-v3/include/experimental/list
index 5bebf3cb0aa..27c9dfd5051 100644
--- a/libstdc++-v3/include/experimental/list
+++ b/libstdc++-v3/include/experimental/list
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_LIST
 #define _GLIBCXX_EXPERIMENTAL_LIST 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/map b/libstdc++-v3/include/experimental/map
index 414c02361c9..3f0f533f577 100644
--- a/libstdc++-v3/include/experimental/map
+++ b/libstdc++-v3/include/experimental/map
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_MAP
 #define _GLIBCXX_EXPERIMENTAL_MAP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/memory b/libstdc++-v3/include/experimental/memory
index ca6a3648e0d..0f8f1b8eb0b 100644
--- a/libstdc++-v3/include/experimental/memory
+++ b/libstdc++-v3/include/experimental/memory
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_MEMORY
 #define _GLIBCXX_EXPERIMENTAL_MEMORY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/memory_resource b/libstdc++-v3/include/experimental/memory_resource
index bc2fdbf082e..c36bb8884c2 100644
--- a/libstdc++-v3/include/experimental/memory_resource
+++ b/libstdc++-v3/include/experimental/memory_resource
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_MEMORY_RESOURCE
 #define _GLIBCXX_EXPERIMENTAL_MEMORY_RESOURCE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/net b/libstdc++-v3/include/experimental/net
index a84fdf4c100..90c604c7b5e 100644
--- a/libstdc++-v3/include/experimental/net
+++ b/libstdc++-v3/include/experimental/net
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_NET
 #define _GLIBCXX_EXPERIMENTAL_NET
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/netfwd b/libstdc++-v3/include/experimental/netfwd
index e2738100189..17f8676c87f 100644
--- a/libstdc++-v3/include/experimental/netfwd
+++ b/libstdc++-v3/include/experimental/netfwd
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_NETFWD
 #define _GLIBCXX_EXPERIMENTAL_NETFWD 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/numeric b/libstdc++-v3/include/experimental/numeric
index 42580b7d214..7f06d56f38a 100644
--- a/libstdc++-v3/include/experimental/numeric
+++ b/libstdc++-v3/include/experimental/numeric
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_NUMERIC
 #define _GLIBCXX_EXPERIMENTAL_NUMERIC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/propagate_const b/libstdc++-v3/include/experimental/propagate_const
index a3682aeb6c0..829a82dd86e 100644
--- a/libstdc++-v3/include/experimental/propagate_const
+++ b/libstdc++-v3/include/experimental/propagate_const
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST
 #define _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/ratio b/libstdc++-v3/include/experimental/ratio
index 5b96e728e11..1325beaf0e2 100644
--- a/libstdc++-v3/include/experimental/ratio
+++ b/libstdc++-v3/include/experimental/ratio
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_RATIO
 #define _GLIBCXX_EXPERIMENTAL_RATIO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/regex b/libstdc++-v3/include/experimental/regex
index d04dc1e954e..3c7802c6683 100644
--- a/libstdc++-v3/include/experimental/regex
+++ b/libstdc++-v3/include/experimental/regex
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_REGEX
 #define _GLIBCXX_EXPERIMENTAL_REGEX 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/scope b/libstdc++-v3/include/experimental/scope
index ea273e8c095..6e1d342e1b6 100644
--- a/libstdc++-v3/include/experimental/scope
+++ b/libstdc++-v3/include/experimental/scope
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_SCOPE
 #define _GLIBCXX_EXPERIMENTAL_SCOPE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/set b/libstdc++-v3/include/experimental/set
index 4ccbf6fdaf0..6758119acd0 100644
--- a/libstdc++-v3/include/experimental/set
+++ b/libstdc++-v3/include/experimental/set
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_SET
 #define _GLIBCXX_EXPERIMENTAL_SET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/socket b/libstdc++-v3/include/experimental/socket
index 62beb43d269..8fb9c032e6c 100644
--- a/libstdc++-v3/include/experimental/socket
+++ b/libstdc++-v3/include/experimental/socket
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_SOCKET
 #define _GLIBCXX_EXPERIMENTAL_SOCKET
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/string b/libstdc++-v3/include/experimental/string
index d6b18b99b6f..8ab604135f9 100644
--- a/libstdc++-v3/include/experimental/string
+++ b/libstdc++-v3/include/experimental/string
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_STRING
 #define _GLIBCXX_EXPERIMENTAL_STRING 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view
index 4eb1a84afce..8929748b8a8 100644
--- a/libstdc++-v3/include/experimental/string_view
+++ b/libstdc++-v3/include/experimental/string_view
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_STRING_VIEW
 #define _GLIBCXX_EXPERIMENTAL_STRING_VIEW 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/synchronized_value b/libstdc++-v3/include/experimental/synchronized_value
index 9a91da912ca..93755e7c3f4 100644
--- a/libstdc++-v3/include/experimental/synchronized_value
+++ b/libstdc++-v3/include/experimental/synchronized_value
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_SYNCVAL
 #define _GLIBCXX_EXPERIMENTAL_SYNCVAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // for std::mutex
 
diff --git a/libstdc++-v3/include/experimental/system_error b/libstdc++-v3/include/experimental/system_error
index 491b9dcf99d..913995a1388 100644
--- a/libstdc++-v3/include/experimental/system_error
+++ b/libstdc++-v3/include/experimental/system_error
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_SYSTEM_ERROR
 #define _GLIBCXX_EXPERIMENTAL_SYSTEM_ERROR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/timer b/libstdc++-v3/include/experimental/timer
index 8d6e3281294..1b60f70a38c 100644
--- a/libstdc++-v3/include/experimental/timer
+++ b/libstdc++-v3/include/experimental/timer
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_TIMER
 #define _GLIBCXX_EXPERIMENTAL_TIMER 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/tuple b/libstdc++-v3/include/experimental/tuple
index f67f738b0e2..c38eb4ba56d 100644
--- a/libstdc++-v3/include/experimental/tuple
+++ b/libstdc++-v3/include/experimental/tuple
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_TUPLE
 #define _GLIBCXX_EXPERIMENTAL_TUPLE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits
index 3fa88a30997..25bb2174420 100644
--- a/libstdc++-v3/include/experimental/type_traits
+++ b/libstdc++-v3/include/experimental/type_traits
@@ -41,7 +41,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS
 #define _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201402L
 
diff --git a/libstdc++-v3/include/experimental/unordered_map b/libstdc++-v3/include/experimental/unordered_map
index c94bd2cd807..06a439a1078 100644
--- a/libstdc++-v3/include/experimental/unordered_map
+++ b/libstdc++-v3/include/experimental/unordered_map
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_UNORDERED_MAP
 #define _GLIBCXX_EXPERIMENTAL_UNORDERED_MAP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/unordered_set b/libstdc++-v3/include/experimental/unordered_set
index 128312c9e95..e752740e2e8 100644
--- a/libstdc++-v3/include/experimental/unordered_set
+++ b/libstdc++-v3/include/experimental/unordered_set
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_UNORDERED_SET
 #define _GLIBCXX_EXPERIMENTAL_UNORDERED_SET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/experimental/vector b/libstdc++-v3/include/experimental/vector
index a51fdca539b..badfe681624 100644
--- a/libstdc++-v3/include/experimental/vector
+++ b/libstdc++-v3/include/experimental/vector
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_EXPERIMENTAL_VECTOR
 #define _GLIBCXX_EXPERIMENTAL_VECTOR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // experimental is currently omitted
 
diff --git a/libstdc++-v3/include/ext/algorithm b/libstdc++-v3/include/ext/algorithm
index a7324fd85e2..4d70dff69fd 100644
--- a/libstdc++-v3/include/ext/algorithm
+++ b/libstdc++-v3/include/ext/algorithm
@@ -56,7 +56,9 @@ 
 #ifndef _EXT_ALGORITHM
 #define _EXT_ALGORITHM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/cmath b/libstdc++-v3/include/ext/cmath
index a180916c646..d4bab41aef0 100644
--- a/libstdc++-v3/include/ext/cmath
+++ b/libstdc++-v3/include/ext/cmath
@@ -29,7 +29,9 @@ 
 #ifndef _EXT_CMATH
 #define _EXT_CMATH 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/functional b/libstdc++-v3/include/ext/functional
index bc8312a3370..dfc297dc0cf 100644
--- a/libstdc++-v3/include/ext/functional
+++ b/libstdc++-v3/include/ext/functional
@@ -56,7 +56,9 @@ 
 #ifndef _EXT_FUNCTIONAL
 #define _EXT_FUNCTIONAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/iterator b/libstdc++-v3/include/ext/iterator
index d3e5e7edfab..24df891a773 100644
--- a/libstdc++-v3/include/ext/iterator
+++ b/libstdc++-v3/include/ext/iterator
@@ -56,7 +56,9 @@ 
 #ifndef _EXT_ITERATOR
 #define _EXT_ITERATOR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/concept_check.h>
 #include <iterator>
diff --git a/libstdc++-v3/include/ext/memory b/libstdc++-v3/include/ext/memory
index ebbebb673be..363cf691ff4 100644
--- a/libstdc++-v3/include/ext/memory
+++ b/libstdc++-v3/include/ext/memory
@@ -56,7 +56,9 @@ 
 #ifndef _EXT_MEMORY
 #define _EXT_MEMORY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/numeric b/libstdc++-v3/include/ext/numeric
index 1123694e686..797341c9761 100644
--- a/libstdc++-v3/include/ext/numeric
+++ b/libstdc++-v3/include/ext/numeric
@@ -56,7 +56,9 @@ 
 #ifndef _EXT_NUMERIC
 #define _EXT_NUMERIC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/random b/libstdc++-v3/include/ext/random
index 01957599f2f..d3f0cc11131 100644
--- a/libstdc++-v3/include/ext/random
+++ b/libstdc++-v3/include/ext/random
@@ -29,7 +29,9 @@ 
 #ifndef _EXT_RANDOM
 #define _EXT_RANDOM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/rb_tree b/libstdc++-v3/include/ext/rb_tree
index dc1c9f52672..308225dddca 100644
--- a/libstdc++-v3/include/ext/rb_tree
+++ b/libstdc++-v3/include/ext/rb_tree
@@ -56,7 +56,9 @@ 
 #ifndef _RB_TREE
 #define _RB_TREE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/ext/rope b/libstdc++-v3/include/ext/rope
index 19199e82806..fabc0eedfba 100644
--- a/libstdc++-v3/include/ext/rope
+++ b/libstdc++-v3/include/ext/rope
@@ -43,7 +43,9 @@ 
 #ifndef _ROPE
 #define _ROPE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // GNU extensions are currently omitted
 
diff --git a/libstdc++-v3/include/parallel/algorithm b/libstdc++-v3/include/parallel/algorithm
index dc73187c88f..b2606fe2914 100644
--- a/libstdc++-v3/include/parallel/algorithm
+++ b/libstdc++-v3/include/parallel/algorithm
@@ -29,7 +29,9 @@ 
 #ifndef _PARALLEL_ALGORITHM
 #define _PARALLEL_ALGORITHM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <algorithm>
 #include <parallel/algorithmfwd.h>
diff --git a/libstdc++-v3/include/std/algorithm b/libstdc++-v3/include/std/algorithm
index b410e7c281b..0b1b72b6be2 100644
--- a/libstdc++-v3/include/std/algorithm
+++ b/libstdc++-v3/include/std/algorithm
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_ALGORITHM
 #define _GLIBCXX_ALGORITHM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/stl_algobase.h>
 #include <bits/stl_algo.h>
diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index d24260eaace..812d80110dc 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_ANY
 #define _GLIBCXX_ANY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_any
 #include <bits/version.h>
diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
index 8710bf75924..172b3203ccd 100644
--- a/libstdc++-v3/include/std/array
+++ b/libstdc++-v3/include/std/array
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_ARRAY
 #define _GLIBCXX_ARRAY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 36ff89a146c..37fd7103bd9 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -32,7 +32,9 @@ 
 #ifndef _GLIBCXX_ATOMIC
 #define _GLIBCXX_ATOMIC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/std/barrier b/libstdc++-v3/include/std/barrier
index ccc89fbd661..f926651713f 100644
--- a/libstdc++-v3/include/std/barrier
+++ b/libstdc++-v3/include/std/barrier
@@ -38,7 +38,9 @@ 
 #ifndef _GLIBCXX_BARRIER
 #define _GLIBCXX_BARRIER 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // threading primitive
 
diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit
index 3e07dd7907f..a5d50a44e07 100644
--- a/libstdc++-v3/include/std/bit
+++ b/libstdc++-v3/include/std/bit
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_BIT
 #define _GLIBCXX_BIT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus >= 201402L
 
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index 2e82a0e289d..1d0483fff08 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -42,7 +42,9 @@ 
 #ifndef _GLIBCXX_BITSET
 #define _GLIBCXX_BITSET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/functexcept.h>   // For invalid_argument, out_of_range,
                                 // overflow_error
diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv
index de671393b88..5a23ab6ca0b 100644
--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CHARCONV
 #define _GLIBCXX_CHARCONV 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // __int128
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index aa78254dac9..013b5f7adde 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_CHRONO
 #define _GLIBCXX_CHRONO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #ifdef _GLIBCXX_NO_FREESTANDING_CHRONO
 # include <bits/requires_hosted.h> // for <ctime> and clocks
diff --git a/libstdc++-v3/include/std/codecvt b/libstdc++-v3/include/std/codecvt
index 311f902efaf..863bb6ffbcc 100644
--- a/libstdc++-v3/include/std/codecvt
+++ b/libstdc++-v3/include/std/codecvt
@@ -31,7 +31,9 @@ 
 #ifndef _GLIBCXX_CODECVT
 #define _GLIBCXX_CODECVT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index c688d0cb728..5bc6618f7de 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -36,7 +36,9 @@ 
 #ifndef _GLIBCXX_COMPLEX
 #define _GLIBCXX_COMPLEX 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts
index 4f3e059b051..28ef37eedc6 100644
--- a/libstdc++-v3/include/std/concepts
+++ b/libstdc++-v3/include/std/concepts
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_CONCEPTS
 #define _GLIBCXX_CONCEPTS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_concepts
 #include <bits/version.h>
diff --git a/libstdc++-v3/include/std/condition_variable b/libstdc++-v3/include/std/condition_variable
index c8a68d3f83e..616f2c36306 100644
--- a/libstdc++-v3/include/std/condition_variable
+++ b/libstdc++-v3/include/std/condition_variable
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_CONDITION_VARIABLE
 #define _GLIBCXX_CONDITION_VARIABLE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // threading primitive
 
diff --git a/libstdc++-v3/include/std/coroutine b/libstdc++-v3/include/std/coroutine
index 30b4d33711e..7ac1c8c985e 100644
--- a/libstdc++-v3/include/std/coroutine
+++ b/libstdc++-v3/include/std/coroutine
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_COROUTINE
 #define _GLIBCXX_COROUTINE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++17-extensions"
diff --git a/libstdc++-v3/include/std/deque b/libstdc++-v3/include/std/deque
index e45dd069952..33396d180c8 100644
--- a/libstdc++-v3/include/std/deque
+++ b/libstdc++-v3/include/std/deque
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_DEQUE
 #define _GLIBCXX_DEQUE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // containers are hosted only
 
diff --git a/libstdc++-v3/include/std/execution b/libstdc++-v3/include/std/execution
index fc2cb249f11..7ac0b70a22b 100644
--- a/libstdc++-v3/include/std/execution
+++ b/libstdc++-v3/include/std/execution
@@ -25,7 +25,9 @@ 
 #ifndef _GLIBCXX_EXECUTION
 #define _GLIBCXX_EXECUTION 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // execution policies are hosted only
 
diff --git a/libstdc++-v3/include/std/expected b/libstdc++-v3/include/std/expected
index b8217e577fa..9e92339e406 100644
--- a/libstdc++-v3/include/std/expected
+++ b/libstdc++-v3/include/std/expected
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_EXPECTED
 #define _GLIBCXX_EXPECTED
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_expected
 #define __glibcxx_want_freestanding_expected
diff --git a/libstdc++-v3/include/std/filesystem b/libstdc++-v3/include/std/filesystem
index acdcddd700b..222b52902b9 100644
--- a/libstdc++-v3/include/std/filesystem
+++ b/libstdc++-v3/include/std/filesystem
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_FILESYSTEM
 #define _GLIBCXX_FILESYSTEM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h>
 
diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 100a53dfd76..9530365e9b4 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_FORMAT
 #define _GLIBCXX_FORMAT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // for std::string
 
diff --git a/libstdc++-v3/include/std/forward_list b/libstdc++-v3/include/std/forward_list
index 5341d1a8239..851c253be11 100644
--- a/libstdc++-v3/include/std/forward_list
+++ b/libstdc++-v3/include/std/forward_list
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_FORWARD_LIST
 #define _GLIBCXX_FORWARD_LIST 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // containers
 
diff --git a/libstdc++-v3/include/std/fstream b/libstdc++-v3/include/std/fstream
index 1008a275540..665a17afee6 100644
--- a/libstdc++-v3/include/std/fstream
+++ b/libstdc++-v3/include/std/fstream
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_FSTREAM
 #define _GLIBCXX_FSTREAM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostreams
 
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 7788a963757..743defc3cb8 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -43,7 +43,9 @@ 
 #ifndef _GLIBCXX_FUNCTIONAL
 #define _GLIBCXX_FUNCTIONAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/stl_function.h> // std::equal_to, std::unary_function etc.
diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 6ce7d89ca3f..b1e6a5354d8 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_FUTURE
 #define _GLIBCXX_FUTURE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // concurrency
 
diff --git a/libstdc++-v3/include/std/generator b/libstdc++-v3/include/std/generator
index 1d5acc91420..0a14e70064e 100644
--- a/libstdc++-v3/include/std/generator
+++ b/libstdc++-v3/include/std/generator
@@ -30,7 +30,9 @@ 
 #define _GLIBCXX_GENERATOR
 
 #include <ranges>
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/include/std/iomanip b/libstdc++-v3/include/std/iomanip
index 9d8ecea5d65..7c0feeef96d 100644
--- a/libstdc++-v3/include/std/iomanip
+++ b/libstdc++-v3/include/std/iomanip
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_IOMANIP
 #define _GLIBCXX_IOMANIP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions"
diff --git a/libstdc++-v3/include/std/ios b/libstdc++-v3/include/std/ios
index 1aa98c47797..ebed2d96278 100644
--- a/libstdc++-v3/include/std/ios
+++ b/libstdc++-v3/include/std/ios
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_IOS
 #define _GLIBCXX_IOS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostreams
 
diff --git a/libstdc++-v3/include/std/iosfwd b/libstdc++-v3/include/std/iosfwd
index 25eae3c6df3..9051b226d5c 100644
--- a/libstdc++-v3/include/std/iosfwd
+++ b/libstdc++-v3/include/std/iosfwd
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_IOSFWD
 #define _GLIBCXX_IOSFWD 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostreams
 
diff --git a/libstdc++-v3/include/std/iostream b/libstdc++-v3/include/std/iostream
index 4a6dc584d38..25064b322ad 100644
--- a/libstdc++-v3/include/std/iostream
+++ b/libstdc++-v3/include/std/iostream
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_IOSTREAM
 #define _GLIBCXX_IOSTREAM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostreams
 
diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream
index 730e413c290..54a130d82f0 100644
--- a/libstdc++-v3/include/std/istream
+++ b/libstdc++-v3/include/std/istream
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_ISTREAM
 #define _GLIBCXX_ISTREAM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostreams
 
diff --git a/libstdc++-v3/include/std/iterator b/libstdc++-v3/include/std/iterator
index b3a3c3538d5..c98bcf1ac2c 100644
--- a/libstdc++-v3/include/std/iterator
+++ b/libstdc++-v3/include/std/iterator
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_ITERATOR
 #define _GLIBCXX_ITERATOR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/stl_iterator_base_types.h>
diff --git a/libstdc++-v3/include/std/latch b/libstdc++-v3/include/std/latch
index 7a67de60a53..146e1860979 100644
--- a/libstdc++-v3/include/std/latch
+++ b/libstdc++-v3/include/std/latch
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_LATCH
 #define _GLIBCXX_LATCH 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // concurrency
 
diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits
index b0ab57c1ad7..7e040bc6341 100644
--- a/libstdc++-v3/include/std/limits
+++ b/libstdc++-v3/include/std/limits
@@ -37,7 +37,9 @@ 
 #ifndef _GLIBCXX_NUMERIC_LIMITS
 #define _GLIBCXX_NUMERIC_LIMITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpedantic" // Q suffix
diff --git a/libstdc++-v3/include/std/list b/libstdc++-v3/include/std/list
index 7b67cebe74c..ab5dec8c6e0 100644
--- a/libstdc++-v3/include/std/list
+++ b/libstdc++-v3/include/std/list
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_LIST
 #define _GLIBCXX_LIST 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // containers
 
diff --git a/libstdc++-v3/include/std/locale b/libstdc++-v3/include/std/locale
index a6808ea2dd4..0de8277cbda 100644
--- a/libstdc++-v3/include/std/locale
+++ b/libstdc++-v3/include/std/locale
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_LOCALE
 #define _GLIBCXX_LOCALE	1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // locales
 
diff --git a/libstdc++-v3/include/std/map b/libstdc++-v3/include/std/map
index 6520d9f744f..3e05006c7b9 100644
--- a/libstdc++-v3/include/std/map
+++ b/libstdc++-v3/include/std/map
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_MAP
 #define _GLIBCXX_MAP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // containers
 
diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory
index c984436f625..ba8e698f680 100644
--- a/libstdc++-v3/include/std/memory
+++ b/libstdc++-v3/include/std/memory
@@ -44,7 +44,9 @@ 
 #ifndef _GLIBCXX_MEMORY
 #define _GLIBCXX_MEMORY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 /**
  * @defgroup memory Memory
diff --git a/libstdc++-v3/include/std/memory_resource b/libstdc++-v3/include/std/memory_resource
index a2ffd841b15..34a7fb1014b 100644
--- a/libstdc++-v3/include/std/memory_resource
+++ b/libstdc++-v3/include/std/memory_resource
@@ -32,7 +32,9 @@ 
 #ifndef _GLIBCXX_MEMORY_RESOURCE
 #define _GLIBCXX_MEMORY_RESOURCE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // polymorphic allocation
 
diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index 8dd9b23191f..e0cedc4398a 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_MUTEX
 #define _GLIBCXX_MUTEX 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // concurrency
 
diff --git a/libstdc++-v3/include/std/numbers b/libstdc++-v3/include/std/numbers
index f04000f1dd9..d813d986e18 100644
--- a/libstdc++-v3/include/std/numbers
+++ b/libstdc++-v3/include/std/numbers
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_NUMBERS
 #define _GLIBCXX_NUMBERS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_math_constants
 #include <bits/version.h>
diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric
index 201bb8e74a1..dd98f40c7a8 100644
--- a/libstdc++-v3/include/std/numeric
+++ b/libstdc++-v3/include/std/numeric
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_NUMERIC
 #define _GLIBCXX_NUMERIC 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/stl_iterator_base_types.h>
diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional
index 6a8e76f60e3..2e663d13f86 100644
--- a/libstdc++-v3/include/std/optional
+++ b/libstdc++-v3/include/std/optional
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_OPTIONAL
 #define _GLIBCXX_OPTIONAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_freestanding_optional
 #define __glibcxx_want_optional
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index 12be6c4fd17..d8462efe764 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_OSTREAM
 #define _GLIBCXX_OSTREAM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostreams
 
diff --git a/libstdc++-v3/include/std/print b/libstdc++-v3/include/std/print
index 0c259d04de3..ea1aaac4389 100644
--- a/libstdc++-v3/include/std/print
+++ b/libstdc++-v3/include/std/print
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_PRINT
 #define _GLIBCXX_PRINT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // for std::format
 
diff --git a/libstdc++-v3/include/std/queue b/libstdc++-v3/include/std/queue
index 61ea4530084..e357456ea6b 100644
--- a/libstdc++-v3/include/std/queue
+++ b/libstdc++-v3/include/std/queue
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_QUEUE
 #define _GLIBCXX_QUEUE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // containers
 
diff --git a/libstdc++-v3/include/std/random b/libstdc++-v3/include/std/random
index 717e5bb611e..907e5bb5f8c 100644
--- a/libstdc++-v3/include/std/random
+++ b/libstdc++-v3/include/std/random
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_RANDOM
 #define _GLIBCXX_RANDOM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // OS-dependent random
 
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 7169c3a92aa..30f45e0a750 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -32,7 +32,9 @@ 
 
 #if __cplusplus > 201703L
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <concepts>
 
diff --git a/libstdc++-v3/include/std/ratio b/libstdc++-v3/include/std/ratio
index d80a9811c27..aeae5b3f186 100644
--- a/libstdc++-v3/include/std/ratio
+++ b/libstdc++-v3/include/std/ratio
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_RATIO
 #define _GLIBCXX_RATIO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex
index 76da68829cd..124eeaa0987 100644
--- a/libstdc++-v3/include/std/regex
+++ b/libstdc++-v3/include/std/regex
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_REGEX
 #define _GLIBCXX_REGEX 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // string and container heavy
 
diff --git a/libstdc++-v3/include/std/scoped_allocator b/libstdc++-v3/include/std/scoped_allocator
index 532a44691ba..11bdcec3b34 100644
--- a/libstdc++-v3/include/std/scoped_allocator
+++ b/libstdc++-v3/include/std/scoped_allocator
@@ -29,7 +29,9 @@ 
 #ifndef _SCOPED_ALLOCATOR
 #define _SCOPED_ALLOCATOR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/std/semaphore b/libstdc++-v3/include/std/semaphore
index 75d634d0e20..fab3cdb49a9 100644
--- a/libstdc++-v3/include/std/semaphore
+++ b/libstdc++-v3/include/std/semaphore
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_SEMAPHORE
 #define _GLIBCXX_SEMAPHORE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // concurrency
 
diff --git a/libstdc++-v3/include/std/set b/libstdc++-v3/include/std/set
index 95cc8005a19..eebea617f6e 100644
--- a/libstdc++-v3/include/std/set
+++ b/libstdc++-v3/include/std/set
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_SET
 #define _GLIBCXX_SET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // containers
 
diff --git a/libstdc++-v3/include/std/shared_mutex b/libstdc++-v3/include/std/shared_mutex
index 1b6478f30c3..f1bb5d7fe92 100644
--- a/libstdc++-v3/include/std/shared_mutex
+++ b/libstdc++-v3/include/std/shared_mutex
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_SHARED_MUTEX
 #define _GLIBCXX_SHARED_MUTEX 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // concurrency
 
diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span
index b7392a0500e..f1c19b58737 100644
--- a/libstdc++-v3/include/std/span
+++ b/libstdc++-v3/include/std/span
@@ -34,7 +34,9 @@ 
 #ifndef _GLIBCXX_SPAN
 #define _GLIBCXX_SPAN 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_span
 #include <bits/version.h>
diff --git a/libstdc++-v3/include/std/spanstream b/libstdc++-v3/include/std/spanstream
index 1f2d78b79d3..b86bd613489 100644
--- a/libstdc++-v3/include/std/spanstream
+++ b/libstdc++-v3/include/std/spanstream
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_SPANSTREAM
 #define _GLIBCXX_SPANSTREAM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostreams
 
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index dda7096afe4..fd24f655218 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_SSTREAM
 #define _GLIBCXX_SSTREAM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostream
 
diff --git a/libstdc++-v3/include/std/stack b/libstdc++-v3/include/std/stack
index c5b4a933ea8..afdcbae0ec9 100644
--- a/libstdc++-v3/include/std/stack
+++ b/libstdc++-v3/include/std/stack
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_STACK
 #define _GLIBCXX_STACK 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // containers
 
diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace
index cdd1276d212..de7446064c7 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -24,7 +24,9 @@ 
 #ifndef _GLIBCXX_STACKTRACE
 #define _GLIBCXX_STACKTRACE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // std::string bound
 
diff --git a/libstdc++-v3/include/std/stdexcept b/libstdc++-v3/include/std/stdexcept
index b55c19bbfe2..e61a744c06e 100644
--- a/libstdc++-v3/include/std/stdexcept
+++ b/libstdc++-v3/include/std/stdexcept
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_STDEXCEPT
 #define _GLIBCXX_STDEXCEPT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <exception>
 #include <string>
diff --git a/libstdc++-v3/include/std/streambuf b/libstdc++-v3/include/std/streambuf
index 2387846e9b2..979308432f6 100644
--- a/libstdc++-v3/include/std/streambuf
+++ b/libstdc++-v3/include/std/streambuf
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBXX_STREAMBUF
 #define _GLIBXX_STREAMBUF 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostreams
 
diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string
index 44a39da5066..fd69e9cb746 100644
--- a/libstdc++-v3/include/std/string
+++ b/libstdc++-v3/include/std/string
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_STRING
 #define _GLIBCXX_STRING	1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // containers
 
diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view
index 740aa9344f0..96350f96b3c 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -33,7 +33,9 @@ 
 #ifndef _GLIBCXX_STRING_VIEW
 #define _GLIBCXX_STRING_VIEW 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_constexpr_char_traits
 #define __glibcxx_want_constexpr_string_view
diff --git a/libstdc++-v3/include/std/syncstream b/libstdc++-v3/include/std/syncstream
index 08a901b62fd..c4123f6bc21 100644
--- a/libstdc++-v3/include/std/syncstream
+++ b/libstdc++-v3/include/std/syncstream
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_SYNCSTREAM
 #define _GLIBCXX_SYNCSTREAM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // iostreams
 
diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error
index 8dce0960e55..e42cdfc4980 100644
--- a/libstdc++-v3/include/std/system_error
+++ b/libstdc++-v3/include/std/system_error
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_SYSTEM_ERROR
 #define _GLIBCXX_SYSTEM_ERROR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // OS-dependent
 
diff --git a/libstdc++-v3/include/std/text_encoding b/libstdc++-v3/include/std/text_encoding
index 49405a214d5..48742dcb076 100644
--- a/libstdc++-v3/include/std/text_encoding
+++ b/libstdc++-v3/include/std/text_encoding
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TEXT_ENCODING
 #define _GLIBCXX_TEXT_ENCODING
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h>
 
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
index e994d683bff..d8c541000ca 100644
--- a/libstdc++-v3/include/std/thread
+++ b/libstdc++-v3/include/std/thread
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_THREAD
 #define _GLIBCXX_THREAD 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // concurrency
 
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 70cf4dba7b9..0bd5439ad67 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TUPLE
 #define _GLIBCXX_TUPLE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 7415e200e09..6e6778078dc 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TYPE_TRAITS
 #define _GLIBCXX_TYPE_TRAITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/std/typeindex b/libstdc++-v3/include/std/typeindex
index 894b133f551..885b33a8dc8 100644
--- a/libstdc++-v3/include/std/typeindex
+++ b/libstdc++-v3/include/std/typeindex
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TYPEINDEX
 #define _GLIBCXX_TYPEINDEX 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/include/std/unordered_map b/libstdc++-v3/include/std/unordered_map
index f9a948c3873..d201903e12d 100644
--- a/libstdc++-v3/include/std/unordered_map
+++ b/libstdc++-v3/include/std/unordered_map
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_UNORDERED_MAP
 #define _GLIBCXX_UNORDERED_MAP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // container
 
diff --git a/libstdc++-v3/include/std/unordered_set b/libstdc++-v3/include/std/unordered_set
index aa5b702ff4d..cfcb6f409b7 100644
--- a/libstdc++-v3/include/std/unordered_set
+++ b/libstdc++-v3/include/std/unordered_set
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_UNORDERED_SET
 #define _GLIBCXX_UNORDERED_SET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // containers
 
diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility
index 56467160a2f..877e9a85c71 100644
--- a/libstdc++-v3/include/std/utility
+++ b/libstdc++-v3/include/std/utility
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_UTILITY
 #define _GLIBCXX_UTILITY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 /**
  * @defgroup utilities Utilities
diff --git a/libstdc++-v3/include/std/valarray b/libstdc++-v3/include/std/valarray
index 46cd57e7982..5ff44a3ec1a 100644
--- a/libstdc++-v3/include/std/valarray
+++ b/libstdc++-v3/include/std/valarray
@@ -31,7 +31,9 @@ 
 #ifndef _GLIBCXX_VALARRAY
 #define _GLIBCXX_VALARRAY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // <cmath> dependant
 
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 08c5395b54d..cf532126d79 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_VARIANT
 #define _GLIBCXX_VARIANT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_freestanding_variant
 #define __glibcxx_want_variant
diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector
index a9894d7e8a8..705bcdc9c08 100644
--- a/libstdc++-v3/include/std/vector
+++ b/libstdc++-v3/include/std/vector
@@ -55,7 +55,9 @@ 
 #ifndef _GLIBCXX_VECTOR
 #define _GLIBCXX_VECTOR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // container
 
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 47c10d60b60..3c6e5b16a50 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_VERSION_INCLUDED
 #define _GLIBCXX_VERSION_INCLUDED
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_all
 #include <bits/version.h>
diff --git a/libstdc++-v3/include/tr1/array b/libstdc++-v3/include/tr1/array
index b16542c2ee9..31ea546d7fa 100644
--- a/libstdc++-v3/include/tr1/array
+++ b/libstdc++-v3/include/tr1/array
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_ARRAY
 #define _GLIBCXX_TR1_ARRAY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/cfenv b/libstdc++-v3/include/tr1/cfenv
index 2d161d88f77..1f57a3ac841 100644
--- a/libstdc++-v3/include/tr1/cfenv
+++ b/libstdc++-v3/include/tr1/cfenv
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_CFENV
 #define _GLIBCXX_TR1_CFENV 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/cinttypes b/libstdc++-v3/include/tr1/cinttypes
index 3a44937abb4..591f9ec4bed 100644
--- a/libstdc++-v3/include/tr1/cinttypes
+++ b/libstdc++-v3/include/tr1/cinttypes
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_CINTTYPES
 #define _GLIBCXX_TR1_CINTTYPES 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath
index 83677a4e716..bc1e562084a 100644
--- a/libstdc++-v3/include/tr1/cmath
+++ b/libstdc++-v3/include/tr1/cmath
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_CMATH
 #define _GLIBCXX_TR1_CMATH 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/complex b/libstdc++-v3/include/tr1/complex
index 31352818fa6..65ec5ddc56c 100644
--- a/libstdc++-v3/include/tr1/complex
+++ b/libstdc++-v3/include/tr1/complex
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_COMPLEX
 #define _GLIBCXX_TR1_COMPLEX 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/cstdbool b/libstdc++-v3/include/tr1/cstdbool
index 4fa40b32888..b0293ceeaac 100644
--- a/libstdc++-v3/include/tr1/cstdbool
+++ b/libstdc++-v3/include/tr1/cstdbool
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_CSTDBOOL
 #define _GLIBCXX_TR1_CSTDBOOL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/cstdint b/libstdc++-v3/include/tr1/cstdint
index eef17131470..2601105ab8a 100644
--- a/libstdc++-v3/include/tr1/cstdint
+++ b/libstdc++-v3/include/tr1/cstdint
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_CSTDINT
 #define _GLIBCXX_TR1_CSTDINT 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/cstdio b/libstdc++-v3/include/tr1/cstdio
index 4e1277a66b7..7537163ac95 100644
--- a/libstdc++-v3/include/tr1/cstdio
+++ b/libstdc++-v3/include/tr1/cstdio
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_CSTDIO
 #define _GLIBCXX_TR1_CSTDIO 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/cstdlib b/libstdc++-v3/include/tr1/cstdlib
index c519f302a49..c9858de68bb 100644
--- a/libstdc++-v3/include/tr1/cstdlib
+++ b/libstdc++-v3/include/tr1/cstdlib
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_CSTDLIB
 #define _GLIBCXX_TR1_CSTDLIB 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/cwchar b/libstdc++-v3/include/tr1/cwchar
index ce13fc1acde..3ef3ebb2c41 100644
--- a/libstdc++-v3/include/tr1/cwchar
+++ b/libstdc++-v3/include/tr1/cwchar
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_CWCHAR
 #define _GLIBCXX_TR1_CWCHAR 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/cwctype b/libstdc++-v3/include/tr1/cwctype
index 10403abdedd..eca6fbf0f0e 100644
--- a/libstdc++-v3/include/tr1/cwctype
+++ b/libstdc++-v3/include/tr1/cwctype
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_CWCTYPE
 #define _GLIBCXX_TR1_CWCTYPE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/functional b/libstdc++-v3/include/tr1/functional
index f2cd42bed4e..9dc67bc82d7 100644
--- a/libstdc++-v3/include/tr1/functional
+++ b/libstdc++-v3/include/tr1/functional
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_FUNCTIONAL
 #define _GLIBCXX_TR1_FUNCTIONAL 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/memory b/libstdc++-v3/include/tr1/memory
index 8862faf4504..b64a8604f18 100644
--- a/libstdc++-v3/include/tr1/memory
+++ b/libstdc++-v3/include/tr1/memory
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_TR1_MEMORY
 #define _GLIBCXX_TR1_MEMORY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/random b/libstdc++-v3/include/tr1/random
index bca650f3ca1..7df863c2602 100644
--- a/libstdc++-v3/include/tr1/random
+++ b/libstdc++-v3/include/tr1/random
@@ -30,7 +30,9 @@ 
 #ifndef _GLIBCXX_TR1_RANDOM
 #define _GLIBCXX_TR1_RANDOM 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/regex b/libstdc++-v3/include/tr1/regex
index 502bfb0207f..8f363604d15 100644
--- a/libstdc++-v3/include/tr1/regex
+++ b/libstdc++-v3/include/tr1/regex
@@ -31,7 +31,9 @@ 
 #ifndef _GLIBCXX_TR1_REGEX
 #define _GLIBCXX_TR1_REGEX 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/tuple b/libstdc++-v3/include/tr1/tuple
index 40e2d091514..e53fca75944 100644
--- a/libstdc++-v3/include/tr1/tuple
+++ b/libstdc++-v3/include/tr1/tuple
@@ -32,7 +32,9 @@ 
 #ifndef _GLIBCXX_TR1_TUPLE
 #define _GLIBCXX_TR1_TUPLE 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions"
diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits
index 62b30e7d658..c4ce2d7125c 100644
--- a/libstdc++-v3/include/tr1/type_traits
+++ b/libstdc++-v3/include/tr1/type_traits
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_TYPE_TRAITS
 #define _GLIBCXX_TR1_TYPE_TRAITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++11-extensions"
diff --git a/libstdc++-v3/include/tr1/unordered_map b/libstdc++-v3/include/tr1/unordered_map
index 5025153c91f..0df975d4407 100644
--- a/libstdc++-v3/include/tr1/unordered_map
+++ b/libstdc++-v3/include/tr1/unordered_map
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_UNORDERED_MAP
 #define _GLIBCXX_TR1_UNORDERED_MAP 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/unordered_set b/libstdc++-v3/include/tr1/unordered_set
index 63c307e012e..7fa06a879a5 100644
--- a/libstdc++-v3/include/tr1/unordered_set
+++ b/libstdc++-v3/include/tr1/unordered_set
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_UNORDERED_SET
 #define _GLIBCXX_TR1_UNORDERED_SET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr1/utility b/libstdc++-v3/include/tr1/utility
index 8a87eec5329..13209c09ef9 100644
--- a/libstdc++-v3/include/tr1/utility
+++ b/libstdc++-v3/include/tr1/utility
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR1_UTILITY
 #define _GLIBCXX_TR1_UTILITY 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/requires_hosted.h> // TR1
 
diff --git a/libstdc++-v3/include/tr2/bool_set b/libstdc++-v3/include/tr2/bool_set
index 11d1b24e4e7..a1d88ea3b87 100644
--- a/libstdc++-v3/include/tr2/bool_set
+++ b/libstdc++-v3/include/tr2/bool_set
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR2_BOOL_SET
 #define _GLIBCXX_TR2_BOOL_SET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <typeinfo>
 #include <iostream>
diff --git a/libstdc++-v3/include/tr2/dynamic_bitset b/libstdc++-v3/include/tr2/dynamic_bitset
index f0878d7429e..9d55f41c6a1 100644
--- a/libstdc++-v3/include/tr2/dynamic_bitset
+++ b/libstdc++-v3/include/tr2/dynamic_bitset
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR2_DYNAMIC_BITSET
 #define _GLIBCXX_TR2_DYNAMIC_BITSET 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <limits>
 #include <vector>
diff --git a/libstdc++-v3/include/tr2/type_traits b/libstdc++-v3/include/tr2/type_traits
index 603039de894..7a94eb8f944 100644
--- a/libstdc++-v3/include/tr2/type_traits
+++ b/libstdc++-v3/include/tr2/type_traits
@@ -29,7 +29,9 @@ 
 #ifndef _GLIBCXX_TR2_TYPE_TRAITS
 #define _GLIBCXX_TR2_TYPE_TRAITS 1
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 #include <type_traits>
 #include <bits/c++config.h>
 
diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
index ac8ffdb6c5a..bf8a20aa6fd 100644
--- a/libstdc++-v3/libsupc++/compare
+++ b/libstdc++-v3/libsupc++/compare
@@ -30,7 +30,9 @@ 
 #ifndef _COMPARE
 #define _COMPARE
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #define __glibcxx_want_three_way_comparison
 #include <bits/version.h>
diff --git a/libstdc++-v3/libsupc++/exception b/libstdc++-v3/libsupc++/exception
index 1b902e99959..7ed8ce317d4 100644
--- a/libstdc++-v3/libsupc++/exception
+++ b/libstdc++-v3/libsupc++/exception
@@ -30,7 +30,9 @@ 
 #ifndef __EXCEPTION__
 #define __EXCEPTION__
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/exception.h>
diff --git a/libstdc++-v3/libsupc++/initializer_list b/libstdc++-v3/libsupc++/initializer_list
index 91b609cacff..144286bc8c9 100644
--- a/libstdc++-v3/libsupc++/initializer_list
+++ b/libstdc++-v3/libsupc++/initializer_list
@@ -30,7 +30,9 @@ 
 #ifndef _INITIALIZER_LIST
 #define _INITIALIZER_LIST
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #if __cplusplus < 201103L
 # include <bits/c++0x_warning.h>
diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new
index e8b00505cf1..e9a3d9b49a3 100644
--- a/libstdc++-v3/libsupc++/new
+++ b/libstdc++-v3/libsupc++/new
@@ -35,7 +35,9 @@ 
 #ifndef _NEW
 #define _NEW
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/c++config.h>
 #include <bits/exception.h>
diff --git a/libstdc++-v3/libsupc++/typeinfo b/libstdc++-v3/libsupc++/typeinfo
index 35e72bb18ee..71066eb1e46 100644
--- a/libstdc++-v3/libsupc++/typeinfo
+++ b/libstdc++-v3/libsupc++/typeinfo
@@ -29,7 +29,9 @@ 
 #ifndef _TYPEINFO
 #define _TYPEINFO
 
+#ifdef _GLIBCXX_SYSHDR
 #pragma GCC system_header
+#endif
 
 #include <bits/exception.h>
 #if __cplusplus >= 201103L