[libcxx] r302944 - [test] Avoid P0138R2, direct-list-init of fixed enums from integers, part 1/3.

Casey Carter via cfe-commits cfe-commits at lists.llvm.org
Fri May 12 13:33:33 PDT 2017


Author: caseycarter
Date: Fri May 12 15:33:32 2017
New Revision: 302944

URL: http://llvm.org/viewvc/llvm-project?rev=302944&view=rev
Log:
[test] Avoid P0138R2, direct-list-init of fixed enums from integers, part 1/3.

This C++17 Core Language feature isn't necessary when testing std::byte.
It's a minor convenience, but it limits test coverage to very new compilers.

This part changes the code.

Fixes D32386.

Modified:
    libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/not.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/or.assign.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/or.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/rshift.fail.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/rshift.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.fail.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/xor.assign.pass.cpp
    libcxx/trunk/test/std/language.support/support.types/byteops/xor.pass.cpp

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp Fri May 12 15:33:32 2017
@@ -26,9 +26,9 @@ constexpr std::byte test(std::byte b1, s
 
 int main () {
 	std::byte b;  // not constexpr, just used in noexcept check
-	constexpr std::byte b1{1};
-	constexpr std::byte b8{8};
-	constexpr std::byte b9{9};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
+	constexpr std::byte b8{static_cast<std::byte>(8)};
+	constexpr std::byte b9{static_cast<std::byte>(9)};
 
 	static_assert(noexcept(b &= b), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp Fri May 12 15:33:32 2017
@@ -18,9 +18,9 @@
 // constexpr byte operator&(byte l, byte r) noexcept;
 
 int main () {
-	constexpr std::byte b1{1};
-	constexpr std::byte b8{8};
-	constexpr std::byte b9{9};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
+	constexpr std::byte b8{static_cast<std::byte>(8)};
+	constexpr std::byte b9{static_cast<std::byte>(9)};
 
 	static_assert(noexcept(b1 & b8), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp Fri May 12 15:33:32 2017
@@ -28,8 +28,8 @@ constexpr std::byte test(std::byte b) {
 
 int main () {
 	std::byte b;  // not constexpr, just used in noexcept check
-	constexpr std::byte b2{2};
-	constexpr std::byte b3{3};
+	constexpr std::byte b2{static_cast<std::byte>(2)};
+	constexpr std::byte b3{static_cast<std::byte>(3)};
 
 	static_assert(noexcept(b <<= 2), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp Fri May 12 15:33:32 2017
@@ -21,6 +21,6 @@
 //   is_integral_v<IntegerType> is true.
 
 int main () {
-	constexpr std::byte b1{1};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
 	constexpr std::byte b2 = b1 << 2.0f;
 }

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp Fri May 12 15:33:32 2017
@@ -21,8 +21,8 @@
 //   is_integral_v<IntegerType> is true.
 
 int main () {
-	constexpr std::byte b1{1};
-	constexpr std::byte b3{3};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
+	constexpr std::byte b3{static_cast<std::byte>(3)};
 
 	static_assert(noexcept(b3 << 2), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/not.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/not.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/not.pass.cpp Fri May 12 15:33:32 2017
@@ -18,9 +18,9 @@
 // constexpr byte operator~(byte b) noexcept;
 
 int main () {
-	constexpr std::byte b1{1};
-	constexpr std::byte b2{2};
-	constexpr std::byte b8{8};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
+	constexpr std::byte b2{static_cast<std::byte>(2)};
+	constexpr std::byte b8{static_cast<std::byte>(8)};
 
 	static_assert(noexcept(~b1), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/or.assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/or.assign.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/or.assign.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/or.assign.pass.cpp Fri May 12 15:33:32 2017
@@ -26,9 +26,9 @@ constexpr std::byte test(std::byte b1, s
 
 int main () {
 	std::byte b;  // not constexpr, just used in noexcept check
-	constexpr std::byte b1{1};
-	constexpr std::byte b2{2};
-	constexpr std::byte b8{8};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
+	constexpr std::byte b2{static_cast<std::byte>(2)};
+	constexpr std::byte b8{static_cast<std::byte>(8)};
 
 	static_assert(noexcept(b |= b), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/or.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/or.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/or.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/or.pass.cpp Fri May 12 15:33:32 2017
@@ -18,9 +18,9 @@
 // constexpr byte operator|(byte l, byte r) noexcept;
 
 int main () {
-	constexpr std::byte b1{1};
-	constexpr std::byte b2{2};
-	constexpr std::byte b8{8};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
+	constexpr std::byte b2{static_cast<std::byte>(2)};
+	constexpr std::byte b8{static_cast<std::byte>(8)};
 
 	static_assert(noexcept(b1 | b2), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp Fri May 12 15:33:32 2017
@@ -28,8 +28,8 @@ constexpr std::byte test(std::byte b) {
 
 int main () {
 	std::byte b;  // not constexpr, just used in noexcept check
-	constexpr std::byte b16{16};
-	constexpr std::byte b192{192};
+	constexpr std::byte b16{static_cast<std::byte>(16)};
+	constexpr std::byte b192{static_cast<std::byte>(192)};
 
 	static_assert(noexcept(b >>= 2), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/rshift.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/rshift.fail.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/rshift.fail.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/rshift.fail.cpp Fri May 12 15:33:32 2017
@@ -21,6 +21,6 @@
 //   is_integral_v<IntegerType> is true.
 
 int main () {
-	constexpr std::byte b1{1};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
 	constexpr std::byte b2 = b1 >> 2.0f;
 }

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/rshift.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/rshift.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/rshift.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/rshift.pass.cpp Fri May 12 15:33:32 2017
@@ -27,8 +27,8 @@ constexpr std::byte test(std::byte b) {
 
 
 int main () {
-	constexpr std::byte b100{100};
-	constexpr std::byte b115{115};
+	constexpr std::byte b100{static_cast<std::byte>(100)};
+	constexpr std::byte b115{static_cast<std::byte>(115)};
 
 	static_assert(noexcept(b100 << 2), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.fail.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.fail.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.fail.cpp Fri May 12 15:33:32 2017
@@ -21,6 +21,6 @@
 //   is_integral_v<IntegerType> is true.
 
 int main () {
-	constexpr std::byte b1{1};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
 	auto f = std::to_integer<float>(b1);
 }

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.pass.cpp Fri May 12 15:33:32 2017
@@ -21,8 +21,8 @@
 //   is_integral_v<IntegerType> is true.
 
 int main () {
-	constexpr std::byte b1{1};
-	constexpr std::byte b3{3};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
+	constexpr std::byte b3{static_cast<std::byte>(3)};
 
 	static_assert(noexcept(std::to_integer<int>(b1)), "" );
 	static_assert(std::is_same<int, decltype(std::to_integer<int>(b1))>::value, "" );

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/xor.assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/xor.assign.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/xor.assign.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/xor.assign.pass.cpp Fri May 12 15:33:32 2017
@@ -26,9 +26,9 @@ constexpr std::byte test(std::byte b1, s
 
 int main () {
 	std::byte b;  // not constexpr, just used in noexcept check
-	constexpr std::byte b1{1};
-	constexpr std::byte b8{8};
-	constexpr std::byte b9{9};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
+	constexpr std::byte b8{static_cast<std::byte>(8)};
+	constexpr std::byte b9{static_cast<std::byte>(9)};
 
 	static_assert(noexcept(b ^= b), "" );
 

Modified: libcxx/trunk/test/std/language.support/support.types/byteops/xor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/xor.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.types/byteops/xor.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/xor.pass.cpp Fri May 12 15:33:32 2017
@@ -18,9 +18,9 @@
 // constexpr byte operator^(byte l, byte r) noexcept;
 
 int main () {
-	constexpr std::byte b1{1};
-	constexpr std::byte b8{8};
-	constexpr std::byte b9{9};
+	constexpr std::byte b1{static_cast<std::byte>(1)};
+	constexpr std::byte b8{static_cast<std::byte>(8)};
+	constexpr std::byte b9{static_cast<std::byte>(9)};
 
 	static_assert(noexcept(b1 ^ b8), "" );
 




More information about the cfe-commits mailing list