From 9239757a9c6e3a6e8d94d56803329d556ec914d7 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Mon, 25 Nov 2024 14:03:27 -0800 Subject: [PATCH] build: Move sstream and memory include above safe-ctype.h [PR124830] This picks r15-5661-gf6e00226a4ca6 to older branches, also moving the include to fix build issues with a C++20 host compiler. sstream in some versions of libstdc++ include locale which might not have been included yet. safe-ctype.h defines the toupper, tolower, etc. as macros so the c++ header files needed to be included before hand as comment in system.h says: /* Include C++ standard headers before "safe-ctype.h" to avoid GCC poisoning the ctype macros through safe-ctype.h */ I don't understand how it was working before when memory was included after safe-ctype.h rather than before. But this makes sstream consistent with the other C++ headers. gcc/ChangeLog: PR target/117771 PR c/124830 * system.h: Move the include of sstream and memory above safe-ctype.h. Signed-off-by: Andrew Pinski (cherry picked from commit 046776dac7cc74bdbab36f450af80644a045858a) Signed-off-by: Marcus Hoffmann Upstream: https://gcc.gnu.org/git?p=gcc.git;a=commit;h=9239757a9c6e3a6e8d94d56803329d556ec914d7 --- gcc/system.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/gcc/system.h b/gcc/system.h index 0354883ed3f..1f013d3ac7a 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -222,6 +222,15 @@ extern int fprintf_unlocked (FILE *, const char *, ...); #ifdef INCLUDE_FUNCTIONAL # include #endif +#ifdef INCLUDE_SSTREAM +# include +#endif +/* Some of the headers included by can use "abort" within a + namespace, e.g. "_VSTD::abort();", which fails after we use the + preprocessor to redefine "abort" as "fancy_abort" below. */ +#ifdef INCLUDE_MEMORY +# include +#endif # include # include # include @@ -736,22 +745,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); #define LIKELY(x) (__builtin_expect ((x), 1)) #define UNLIKELY(x) (__builtin_expect ((x), 0)) -/* Some of the headers included by can use "abort" within a - namespace, e.g. "_VSTD::abort();", which fails after we use the - preprocessor to redefine "abort" as "fancy_abort" below. */ - -#ifdef INCLUDE_MEMORY -# include -#endif - #ifdef INCLUDE_MUTEX # include #endif -#ifdef INCLUDE_SSTREAM -# include -#endif - #ifdef INCLUDE_MALLOC_H #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) #include -- 2.54.0