[committed,1/2] libstdc++: Require c++98_only effective target for some tests

Message ID 20200702203057.GA3976703@redhat.com
State New
Headers show
Series
  • [committed,1/2] libstdc++: Require c++98_only effective target for some tests
Related show

Commit Message

Peter Bergner via Gcc-patches July 2, 2020, 8:30 p.m.
These tests verify that including C++11 headers fails to compile in
C++98 mode. They use { dg-options "-std=gnu++98" } so that they are
explicitly run in C++98 mode. This change also adds a target selector so
that the tests will be skipped even if the dg-options directive is
filtered out or overridden. This is in preparation for a desired future
change where tests do not use -std options, so that they can be tested
with e.g. --target_board=unix\"{-std=gnu++17,-std=gnu++20}\"

In some cases the dg-options and dg-do directives need to be reordered,
so that the -std=gnu++98 option is already added to the options before
the target selector is checked.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc: Add
	c++98_only target selector.
	* testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc:
	Likewise.
	* testsuite/18_support/headers/cstdint/std_c++0x_neg.cc:
	Likewise.
	* testsuite/18_support/headers/new/synopsis_cxx98.cc: Likewise.
	* testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc:
	Likewise.
	* testsuite/20_util/headers/type_traits/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/array/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/tuple/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/c99_classification_macros_c++98.cc:
	Likewise.
	* testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/random/std_c++0x_neg.cc:
	Likewise.
	* testsuite/27_io/headers/cinttypes/std_c++0x_neg.cc: Likewise.
	* testsuite/28_regex/headers/regex/std_c++0x_neg.cc: Likewise.
	* testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc:
	Likewise.
	* testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc:
	Likewise.
	* testsuite/30_threads/headers/future/std_c++0x_neg.cc:
	Likewise.
	* testsuite/30_threads/headers/mutex/std_c++0x_neg.cc: Likewise.
	* testsuite/30_threads/headers/thread/std_c++0x_neg.cc:
	Likewise.

Tested x86_64-linux, committed to trunk.
commit b857b179772951677cb12781f892454cd09d7831
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jul 2 21:27:12 2020 +0100

    libstdc++: Require c++98_only effective target for some tests
    
    These tests verify that including C++11 headers fails to compile in
    C++98 mode. They use { dg-options "-std=gnu++98" } so that they are
    explicitly run in C++98 mode. This change also adds a target selector so
    that the tests will be skipped even if the dg-options directive is
    filtered out or overridden. This is in preparation for a desired future
    change where tests do not use -std options, so that they can be tested
    with e.g. --target_board=unix\"{-std=gnu++17,-std=gnu++20}\"
    
    In some cases the dg-options and dg-do directives need to be reordered,
    so that the -std=gnu++98 option is already added to the options before
    the target selector is checked.
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc: Add
            c++98_only target selector.
            * testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc:
            Likewise.
            * testsuite/18_support/headers/cstdint/std_c++0x_neg.cc:
            Likewise.
            * testsuite/18_support/headers/new/synopsis_cxx98.cc: Likewise.
            * testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc:
            Likewise.
            * testsuite/20_util/headers/type_traits/std_c++0x_neg.cc:
            Likewise.
            * testsuite/23_containers/headers/array/std_c++0x_neg.cc:
            Likewise.
            * testsuite/23_containers/headers/tuple/std_c++0x_neg.cc:
            Likewise.
            * testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc:
            Likewise.
            * testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc:
            Likewise.
            * testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc:
            Likewise.
            * testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc:
            Likewise.
            * testsuite/26_numerics/headers/cmath/c99_classification_macros_c++98.cc:
            Likewise.
            * testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc:
            Likewise.
            * testsuite/26_numerics/headers/random/std_c++0x_neg.cc:
            Likewise.
            * testsuite/27_io/headers/cinttypes/std_c++0x_neg.cc: Likewise.
            * testsuite/28_regex/headers/regex/std_c++0x_neg.cc: Likewise.
            * testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc:
            Likewise.
            * testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc:
            Likewise.
            * testsuite/30_threads/headers/future/std_c++0x_neg.cc:
            Likewise.
            * testsuite/30_threads/headers/mutex/std_c++0x_neg.cc: Likewise.
            * testsuite/30_threads/headers/thread/std_c++0x_neg.cc:
            Likewise.

Patch

diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc b/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc
index 8fb895a2133..ac75d95228b 100644
--- a/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2011-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc b/libstdc++-v3/testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc
index 84ba059b219..1cfafdbdd54 100644
--- a/libstdc++-v3/testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdint/std_c++0x_neg.cc b/libstdc++-v3/testsuite/18_support/headers/cstdint/std_c++0x_neg.cc
index f3d91edfd08..2b1cb1f4788 100644
--- a/libstdc++-v3/testsuite/18_support/headers/cstdint/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/18_support/headers/cstdint/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/18_support/headers/new/synopsis_cxx98.cc b/libstdc++-v3/testsuite/18_support/headers/new/synopsis_cxx98.cc
index 92518df3453..159c5c54def 100644
--- a/libstdc++-v3/testsuite/18_support/headers/new/synopsis_cxx98.cc
+++ b/libstdc++-v3/testsuite/18_support/headers/new/synopsis_cxx98.cc
@@ -1,5 +1,5 @@ 
 // { dg-options "-std=gnu++98" }
-// { dg-do compile }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc
index ae82952a29e..1d95740c89d 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc b/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc
index 31048a1c85c..a43e6133551 100644
--- a/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/23_containers/headers/array/std_c++0x_neg.cc b/libstdc++-v3/testsuite/23_containers/headers/array/std_c++0x_neg.cc
index a3b436d6a85..9a31fb8e2e3 100644
--- a/libstdc++-v3/testsuite/23_containers/headers/array/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/headers/array/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/23_containers/headers/tuple/std_c++0x_neg.cc b/libstdc++-v3/testsuite/23_containers/headers/tuple/std_c++0x_neg.cc
index f7412f685c1..396f3da1366 100644
--- a/libstdc++-v3/testsuite/23_containers/headers/tuple/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/headers/tuple/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc b/libstdc++-v3/testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc
index c0317186d6a..35a03df8869 100644
--- a/libstdc++-v3/testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc b/libstdc++-v3/testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc
index 98f25d8d4e6..aaac26e6d24 100644
--- a/libstdc++-v3/testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc
index dcf99911b66..ecfd806116a 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc
index 7dd1e386a58..127b81226d3 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++98.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++98.cc
index 4dfa418df9d..ff845ae25b0 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++98.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++98.cc
@@ -18,7 +18,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-options "-std=gnu++98" }
-// { dg-do compile }
+// { dg-do compile { target c++98_only } }
 // { dg-excess-errors "" { target uclibc } }
 
 #include <cmath>
@@ -55,7 +55,7 @@  template <typename _Tp>
     fp_type f1 = 1.0;
     fp_type f2 = 3.0;
     int res = 0;
-    
+
     res = std::fpclassify(f1);
     res = std::isfinite(f2);
     res = std::isinf(f1);
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc
index 6cf99fd15a2..42942798e1f 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc
index 9944ec09f1e..6ffe66c7407 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/27_io/headers/cinttypes/std_c++0x_neg.cc b/libstdc++-v3/testsuite/27_io/headers/cinttypes/std_c++0x_neg.cc
index 8ade9030f28..e7d78b0498f 100644
--- a/libstdc++-v3/testsuite/27_io/headers/cinttypes/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/27_io/headers/cinttypes/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/28_regex/headers/regex/std_c++0x_neg.cc b/libstdc++-v3/testsuite/28_regex/headers/regex/std_c++0x_neg.cc
index 52b9509fb03..f07e4385dd9 100644
--- a/libstdc++-v3/testsuite/28_regex/headers/regex/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/28_regex/headers/regex/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc b/libstdc++-v3/testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc
index 0fba21b6fde..08b05ddd0ff 100644
--- a/libstdc++-v3/testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2008-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc b/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc
index 6b47420ab67..0b615988a77 100644
--- a/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2008-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc b/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc
index f3e4b23a236..22463f4bc55 100644
--- a/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2009-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc b/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc
index 95a738ca6cd..c179a5887f3 100644
--- a/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/headers/mutex/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 
 // Copyright (C) 2008-2020 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc b/libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc
index a6e14124143..dd39c87bea2 100644
--- a/libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/headers/thread/std_c++0x_neg.cc
@@ -1,5 +1,5 @@ 
-// { dg-do compile }
 // { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
 // { dg-require-gthreads "" }
 
 // Copyright (C) 2008-2020 Free Software Foundation, Inc.