[PATCH] Make test helper work with non-copyable types

Jonathan Wakely jwakely@redhat.com
Wed Oct 12 13:30:00 GMT 2016


This test utility does: "T t = T();" to guarantee value-init, and then
some std::atomic tests have dg-error directives to handle the errors
that happen because atomics are non-copyable. In C++17 there is no
error, because of guaranteed elision, so the dg-errors FAIL.

For C++11 we can us "T t{};" instead, which means there are no errors
for non-copyable types, and we don't get different errors for C++11
and C++17.

	* testsuite/util/testsuite_common_types.h
	(bitwise_assignment_operators): Use direct-initialization for C++11
	and later, to avoid CopyConstructible requirement.
	* testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust dg-error
	line numbers.
	* testsuite/29_atomics/atomic/cons/copy_neg.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc:
	Adjust expected errors and line numbers.

Tested powerpc64le-linux, committed to trunk.

-------------- next part --------------
commit 588104840e79d4fdad1eba26ac83a511d9b6ab27
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Oct 12 13:17:05 2016 +0100

    Make test helper work with non-copyable types
    
    	* testsuite/util/testsuite_common_types.h
    	(bitwise_assignment_operators): Use direct-initialization for C++11
    	and later, to avoid CopyConstructible requirement.
    	* testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust dg-error
    	line numbers.
    	* testsuite/29_atomics/atomic/cons/copy_neg.cc: Likewise.
    	* testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Likewise.
    	* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Likewise.
    	* testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc:
    	Adjust expected errors and line numbers.

diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc
index eb0111d..4136944 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc
@@ -27,5 +27,5 @@ int main()
   return 0;
 }
 
-// { dg-error "deleted" "" { target *-*-* } 615 }
+// { dg-error "deleted" "" { target *-*-* } 620 }
 // { dg-prune-output "include" }
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc
index 546ac50..ffc2dc2 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc
@@ -27,5 +27,5 @@ int main()
   return 0;
 }
 
-// { dg-error "deleted" "" { target *-*-* } 654 }
+// { dg-error "deleted" "" { target *-*-* } 659 }
 // { dg-prune-output "include" }
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc
index c5b6103..20f263c 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc
@@ -28,5 +28,5 @@ int main()
   return 0;
 }
 
-// { dg-error "deleted" "" { target *-*-* } 615 }
+// { dg-error "deleted" "" { target *-*-* } 620 }
 // { dg-prune-output "include" }
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc
index 49e1eb1..bf7cda8 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc
@@ -28,5 +28,5 @@ int main()
   return 0;
 }
 
-// { dg-error "deleted" "" { target *-*-* } 654 }
+// { dg-error "deleted" "" { target *-*-* } 659 }
 // { dg-prune-output "include" }
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc
index db0c3c1..731513b 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc
@@ -26,10 +26,8 @@ int main()
   return 0;
 }
 
-// { dg-error "deleted" "" { target *-*-* } 469 }
-// { dg-error "deleted" "" { target *-*-* } 470 }
-// { dg-error "operator" "" { target *-*-* } 471 }
-// { dg-error "operator" "" { target *-*-* } 472 }
-// { dg-error "operator" "" { target *-*-* } 473 }
+// { dg-error "operator" "" { target *-*-* } 476 }
+// { dg-error "operator" "" { target *-*-* } 477 }
+// { dg-error "operator" "" { target *-*-* } 478 }
 
 // { dg-prune-output "declared here" }
diff --git a/libstdc++-v3/testsuite/util/testsuite_common_types.h b/libstdc++-v3/testsuite/util/testsuite_common_types.h
index 2f3732e..3233676 100644
--- a/libstdc++-v3/testsuite/util/testsuite_common_types.h
+++ b/libstdc++-v3/testsuite/util/testsuite_common_types.h
@@ -466,8 +466,13 @@ namespace __gnu_test
     void
     bitwise_assignment_operators()
     {
+#if __cplusplus >= 201103L
+      _Tp a{};
+      _Tp b{};
+#else
       _Tp a = _Tp();
       _Tp b = _Tp();
+#endif
       a |= b; // set
       a &= ~b; // clear
       a ^= b;


More information about the Libstdc++ mailing list