[committed] libstdc++: Define effective-target for net::ip features [PR 100351]

Jonathan Wakely jwakely@redhat.com
Fri Apr 30 13:48:05 GMT 2021


Define a new effective-target keyword so that tests for the Networking
TS <experimental/internet> header can be skipped on targets where none
of it can be usefully defined.

libstdc++-v3/ChangeLog:

	PR libstdc++/100180
	PR libstdc++/100286
	PR libstdc++/100351
	* testsuite/experimental/net/internet/address/v4/comparisons.cc:
	Use new effective-target keyword.
	* testsuite/experimental/net/internet/address/v4/cons.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v4/creation.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v4/members.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v6/members.cc:
	Likewise.
	* testsuite/experimental/net/internet/resolver/base.cc:
	Likewise.
	* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
	Likewise.
	* testsuite/experimental/net/internet/resolver/ops/reverse.cc:
	Likewise.
	* testsuite/experimental/net/internet/socket/opt.cc:
	Likewise.
	* testsuite/experimental/net/internet/tcp.cc:
	Likewise.
	* testsuite/experimental/net/internet/udp.cc:
	Likewise.
	* testsuite/lib/libstdc++.exp (check_effective_target_net_ts_ip):
	New proc to check net_ts_ip et.

Tested powerpc64le-linux. Committed to trunk.

-------------- next part --------------
commit 57028ff2d3f56deec25498f83e99c39478acc02f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Apr 30 11:45:07 2021

    libstdc++: Define effective-target for net::ip features [PR 100351]
    
    Define a new effective-target keyword so that tests for the Networking
    TS <experimental/internet> header can be skipped on targets where none
    of it can be usefully defined.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100180
            PR libstdc++/100286
            PR libstdc++/100351
            * testsuite/experimental/net/internet/address/v4/comparisons.cc:
            Use new effective-target keyword.
            * testsuite/experimental/net/internet/address/v4/cons.cc:
            Likewise.
            * testsuite/experimental/net/internet/address/v4/creation.cc:
            Likewise.
            * testsuite/experimental/net/internet/address/v4/members.cc:
            Likewise.
            * testsuite/experimental/net/internet/address/v6/members.cc:
            Likewise.
            * testsuite/experimental/net/internet/resolver/base.cc:
            Likewise.
            * testsuite/experimental/net/internet/resolver/ops/lookup.cc:
            Likewise.
            * testsuite/experimental/net/internet/resolver/ops/reverse.cc:
            Likewise.
            * testsuite/experimental/net/internet/socket/opt.cc:
            Likewise.
            * testsuite/experimental/net/internet/tcp.cc:
            Likewise.
            * testsuite/experimental/net/internet/udp.cc:
            Likewise.
            * testsuite/lib/libstdc++.exp (check_effective_target_net_ts_ip):
            New proc to check net_ts_ip et.

diff --git a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/comparisons.cc b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/comparisons.cc
index 82cc966b00d..88c56a8eaee 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/comparisons.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/comparisons.cc
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 // { dg-add-options net_ts }
 
 #include <experimental/internet>
@@ -26,8 +27,6 @@ using std::experimental::net::ip::address_v4;
 void
 test01()
 {
-  bool test __attribute__((unused)) = false;
-
   address_v4 addrs[] = {
     address_v4::any(), address_v4::loopback(), address_v4::broadcast(),
     address_v4{0x11001100}, address_v4{0xEFEFEFEF}
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/cons.cc b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/cons.cc
index 28bf3bd989c..848839f7c61 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/cons.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/cons.cc
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 // { dg-add-options net_ts }
 
 #include <experimental/internet>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/creation.cc b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/creation.cc
index 81c087faaf2..bf233065c7d 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/creation.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/creation.cc
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 // { dg-add-options net_ts }
 
 #include <experimental/internet>
@@ -27,8 +28,6 @@ using net::ip::address_v4;
 void
 test01()
 {
-  bool test __attribute__((unused)) = false;
-
   auto a0 = make_address_v4( address_v4::bytes_type{} );
   VERIFY( a0.to_uint() == 0 );
   VERIFY( a0.to_bytes() == address_v4::bytes_type{} );
@@ -42,8 +41,6 @@ test01()
 void
 test02()
 {
-  bool test __attribute__((unused)) = false;
-
   auto a0 = net::ip::make_address_v4(0u);
   VERIFY( a0.to_uint() == 0 );
   VERIFY( a0.to_bytes() == address_v4::bytes_type{} );
@@ -57,8 +54,6 @@ test02()
 void
 test03()
 {
-  bool test __attribute__((unused)) = false;
-
   auto a1 = net::ip::make_address_v4("127.0.0.1");
   VERIFY( a1.is_loopback() );
   auto a2 = net::ip::make_address_v4(std::string{"127.0.0.2"});
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/members.cc b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/members.cc
index f644c0847ab..ac66f864ca5 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/address/v4/members.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/address/v4/members.cc
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 // { dg-add-options net_ts }
 
 #include <experimental/internet>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/address/v6/members.cc b/libstdc++-v3/testsuite/experimental/net/internet/address/v6/members.cc
index b77d6a29e3d..3d9d653f457 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/address/v6/members.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/address/v6/members.cc
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 // { dg-add-options net_ts }
 
 #include <experimental/internet>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/resolver/base.cc b/libstdc++-v3/testsuite/experimental/net/internet/resolver/base.cc
index 23af4464b72..4c36b03ebcc 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/resolver/base.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/resolver/base.cc
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 // { dg-add-options net_ts }
 
 #include <experimental/internet>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
index 321f96fb37f..ca8f0899ccd 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 // { dg-add-options net_ts }
 
 #include <experimental/internet>
@@ -26,8 +27,6 @@ using namespace std::experimental::net;
 void
 test01()
 {
-  bool test __attribute__((unused)) = false;
-
   std::error_code ec;
   io_context ctx;
   ip::tcp::resolver resolv(ctx);
@@ -44,8 +43,6 @@ test01()
 void
 test02()
 {
-  bool test __attribute__((unused)) = false;
-
   std::error_code ec;
   io_context ctx;
   ip::tcp::resolver resolv(ctx);
@@ -83,8 +80,6 @@ test02()
 void
 test03()
 {
-  bool test __attribute__((unused)) = false;
-
   std::error_code ec;
   io_context ctx;
   ip::tcp::resolver resolv(ctx);
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/reverse.cc b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/reverse.cc
index fce04d4fe2f..b50b2ee36a4 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/reverse.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/reverse.cc
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 // { dg-add-options net_ts }
 
 #include <experimental/internet>
@@ -26,8 +27,6 @@ using namespace std::experimental::net;
 void
 test01()
 {
-  bool test __attribute__((unused)) = false;
-
   std::error_code ec;
   io_context ctx;
   ip::tcp::resolver resolv(ctx);
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/socket/opt.cc b/libstdc++-v3/testsuite/experimental/net/internet/socket/opt.cc
index cfbc00f9da8..a4efeb4e233 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/socket/opt.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/socket/opt.cc
@@ -1,4 +1,5 @@
 // { dg-do run { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 
 #include <experimental/internet>
 #include <testsuite_common_types.h>
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/tcp.cc b/libstdc++-v3/testsuite/experimental/net/internet/tcp.cc
index 87d042377a0..d583f22f508 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/tcp.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/tcp.cc
@@ -1,9 +1,9 @@
 // { dg-do compile { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 
 #include <experimental/internet>
 #include <type_traits>
 
-#if __has_include(<netinet/in.h>)
 using namespace std;
 using std::experimental::net::ip::tcp;
 using std::experimental::net::ip::basic_endpoint;
@@ -42,4 +42,3 @@ test01()
   static_assert( tcp::v4().protocol() == IPPROTO_TCP, "" );
   static_assert( tcp::v6().protocol() == IPPROTO_TCP, "" );
 }
-#endif
diff --git a/libstdc++-v3/testsuite/experimental/net/internet/udp.cc b/libstdc++-v3/testsuite/experimental/net/internet/udp.cc
index d5f42c7575e..300f735d834 100644
--- a/libstdc++-v3/testsuite/experimental/net/internet/udp.cc
+++ b/libstdc++-v3/testsuite/experimental/net/internet/udp.cc
@@ -1,9 +1,9 @@
 // { dg-do compile { target c++14 } }
+// { dg-require-effective-target net_ts_ip }
 
 #include <experimental/internet>
 #include <type_traits>
 
-#if __has_include(<netinet/in.h>)
 using namespace std;
 using std::experimental::net::ip::udp;
 using std::experimental::net::ip::basic_endpoint;
@@ -40,4 +40,3 @@ test01()
   static_assert( udp::v4().protocol() == IPPROTO_UDP, "" );
   static_assert( udp::v6().protocol() == IPPROTO_UDP, "" );
 }
-#endif
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 7f9580db8ed..73b202ce212 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1331,6 +1331,14 @@ proc check_effective_target_ieee-floats { } {
     }]
 }
 
+# Return 1 if Networking TS net::ip features are available.
+proc check_effective_target_net_ts_ip { } {
+    return [check_v3_target_prop_cached et_net_ts_ip {
+	set cond "__has_include(<netinet/in.h>)"
+	return [v3_check_preprocessor_condition net_ts_ip $cond]
+    }]
+}
+
 set additional_prunes ""
 
 if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \


More information about the Libstdc++ mailing list