]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Fix up g++.dg/lto/20091022-2_0.C test [PR124828] master trunk
authorJakub Jelinek <jakub@redhat.com>
Fri, 10 Apr 2026 07:47:36 +0000 (09:47 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 10 Apr 2026 07:47:36 +0000 (09:47 +0200)
From what I can see, this test was added for PR41791 where we didn't stream
in/out the system header flags for LTO.  The test isn't perfect, because
even when we actually do stream those flags, whether it fails or not depends
on the exact decisions of the inliner whether it decides to inline all
inline/constexpr functions or not (maybe it would help to use some
--params to request inlining as few functions as possible).

Anyway, guess at some point we simply started to inline everything that was
used and so whether the test stopped failing even if it would use
-Wsystem-headers.  Now, when not using installed gcc testing, we use
libstdc++-v3/scripts/testsuite_flags script which uses -I options rather
than -isystem, but the headers still had #pragma GCC system_header pragmas.
Except that r15-3859 guarded those pragmas with a macro which isn't defined
by default and needs to be defined only when we want to make sure the
headers are treated as system headers.
And later on the recent changes for C++20 stable string exports started
seeing a constexpr (thus implicitly inline for -Winline purposes) being too
large for default inlining and so the test started to fail again.

The following patch fixes it by making sure the libstdc++ headers are
treated as system headers, so the test tests again what it was supposed to
test.

2026-04-10  Jakub Jelinek  <jakub@redhat.com>

PR lto/124828
* g++.dg/lto/20091022-2_0.C (_GLIBCXX_SYSHDR): Define before including
<string>.

Reviewed-by: Richard Biener <rguenth@suse.de>
gcc/testsuite/g++.dg/lto/20091022-2_0.C

index a1606bc3b627369d0ee7e29bed001d0c069efbea..e9f213de55ddf1efef2cafb28339f4deb63f8b71 100644 (file)
@@ -2,6 +2,7 @@
 // { dg-lto-options {{-O3 -flto -Winline}} }
 // { dg-skip-if "requires hosted libstdc++ for string" { ! hostedlib } }
 
 // { dg-lto-options {{-O3 -flto -Winline}} }
 // { dg-skip-if "requires hosted libstdc++ for string" { ! hostedlib } }
 
+#define _GLIBCXX_SYSHDR
 #include <string>
 
 int
 #include <string>
 
 int