libstdc++: Explicitly pass -Wsystem-headers to tests that need it

Message ID 20250916153455.239844-1-ppalka@redhat.com
State New
Headers
Series libstdc++: Explicitly pass -Wsystem-headers to tests that need it |

Commit Message

Patrick Palka Sept. 16, 2025, 3:34 p.m. UTC
  Tested on x86_64-pc-linux-gnu, does thsi look OK for trunk and
perhaps 15/14?

-- >8 --

When running libstdc++ tests using an installed gcc (as opposed to
an in-tree gcc), warnings from within system headers are suppressed,
so tests that check for such warnings need to pass -Wsystem-headers
explicitly in order for them not to spuriously FAIL.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/bind/dangling_ref.cc: Compile with
	-Wsystem-headers.
	* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.
	* testsuite/20_util/unique_ptr/lwg4148.cc: Likewise.
	* testsuite/29_atomics/atomic/operators/pointer_partial_void.cc:
	Likewise.
	* testsuite/30_threads/packaged_task/cons/dangling_ref.cc:
	Likewise.
---
 libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc              | 1 +
 .../testsuite/20_util/ratio/operations/ops_overflow_neg.cc       | 1 +
 libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc             | 1 +
 .../29_atomics/atomic/operators/pointer_partial_void.cc          | 1 +
 .../testsuite/30_threads/packaged_task/cons/dangling_ref.cc      | 1 +
 5 files changed, 5 insertions(+)
  

Comments

Jonathan Wakely Sept. 16, 2025, 3:37 p.m. UTC | #1
On Tue, 16 Sept 2025 at 16:36, Patrick Palka <ppalka@redhat.com> wrote:
>
> Tested on x86_64-pc-linux-gnu, does thsi look OK for trunk and
> perhaps 15/14?

OK for trunk/15/14


>
> -- >8 --
>
> When running libstdc++ tests using an installed gcc (as opposed to
> an in-tree gcc), warnings from within system headers are suppressed,
> so tests that check for such warnings need to pass -Wsystem-headers
> explicitly in order for them not to spuriously FAIL.
>
> libstdc++-v3/ChangeLog:
>
>         * testsuite/20_util/bind/dangling_ref.cc: Compile with
>         -Wsystem-headers.
>         * testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.
>         * testsuite/20_util/unique_ptr/lwg4148.cc: Likewise.
>         * testsuite/29_atomics/atomic/operators/pointer_partial_void.cc:
>         Likewise.
>         * testsuite/30_threads/packaged_task/cons/dangling_ref.cc:
>         Likewise.
> ---
>  libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc              | 1 +
>  .../testsuite/20_util/ratio/operations/ops_overflow_neg.cc       | 1 +
>  libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc             | 1 +
>  .../29_atomics/atomic/operators/pointer_partial_void.cc          | 1 +
>  .../testsuite/30_threads/packaged_task/cons/dangling_ref.cc      | 1 +
>  5 files changed, 5 insertions(+)
>
> diff --git a/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc b/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc
> index 17e7b21c45cb..32af0a27b8fe 100644
> --- a/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc
> +++ b/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc
> @@ -1,4 +1,5 @@
>  // { dg-do compile { target c++11 } }
> +// { dg-additional-options "-Wsystem-headers" }
>  #include <functional>
>
>  int f();
> 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 5eff8e31f82a..cdc46f4a7ea2 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
> @@ -1,5 +1,6 @@
>  // { dg-do compile { target c++11 } }
>  // { dg-require-cstdint "" }
> +// { dg-additional-options "-Wsystem-headers" }
>
>  // 2008-07-03 Chris Fairles <chris.fairles@gmail.com>
>
> diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc
> index c70d7a60631b..f5697e4e4021 100644
> --- a/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc
> +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc
> @@ -1,4 +1,5 @@
>  // { dg-do compile { target c++11 } }
> +// { dg-additional-options "-Wsystem-headers" }
>
>  // LWG 4148. unique_ptr::operator* should not allow dangling references
>
> diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc b/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc
> index e959418a1c3c..1e2f71e9c628 100644
> --- a/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc
> +++ b/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc
> @@ -1,6 +1,7 @@
>  // { dg-do run { target { c++11_only || c++14_only } } }
>  // { dg-require-atomic-builtins "" }
>  // { dg-require-effective-target hosted }
> +// { dg-additional-options "-Wsystem-headers" }
>
>  // Copyright (C) 2012-2025 Free Software Foundation, Inc.
>  //
> diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc
> index 8cc3f78da9f0..30e05b0391a1 100644
> --- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc
> +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc
> @@ -1,4 +1,5 @@
>  // { dg-do compile { target c++11 } }
> +// { dg-additional-options "-Wsystem-headers" }
>  #include <future>
>
>  // C++20 [futures.task.members]
> --
> 2.51.0.268.ga483264b01
>
  

Patch

diff --git a/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc b/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc
index 17e7b21c45cb..32af0a27b8fe 100644
--- a/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc
+++ b/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc
@@ -1,4 +1,5 @@ 
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wsystem-headers" }
 #include <functional>
 
 int f();
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 5eff8e31f82a..cdc46f4a7ea2 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
@@ -1,5 +1,6 @@ 
 // { dg-do compile { target c++11 } }
 // { dg-require-cstdint "" }
+// { dg-additional-options "-Wsystem-headers" }
 
 // 2008-07-03 Chris Fairles <chris.fairles@gmail.com>
 
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc
index c70d7a60631b..f5697e4e4021 100644
--- a/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4148.cc
@@ -1,4 +1,5 @@ 
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wsystem-headers" }
 
 // LWG 4148. unique_ptr::operator* should not allow dangling references
 
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc b/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc
index e959418a1c3c..1e2f71e9c628 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc
@@ -1,6 +1,7 @@ 
 // { dg-do run { target { c++11_only || c++14_only } } }
 // { dg-require-atomic-builtins "" }
 // { dg-require-effective-target hosted }
+// { dg-additional-options "-Wsystem-headers" }
 
 // Copyright (C) 2012-2025 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc
index 8cc3f78da9f0..30e05b0391a1 100644
--- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc
@@ -1,4 +1,5 @@ 
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wsystem-headers" }
 #include <future>
 
 // C++20 [futures.task.members]