[test] Avoid P0138R2, direct-list-init of fixed enums from integers, part 1/3.
authorCasey Carter <Casey@Carter.net>
Fri, 12 May 2017 20:33:32 +0000 (20:33 +0000)
committerCasey Carter <Casey@Carter.net>
Fri, 12 May 2017 20:33:32 +0000 (20:33 +0000)
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.

llvm-svn: 302944

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

index dec241e..1c9790e 100644 (file)
@@ -26,9 +26,9 @@ constexpr std::byte test(std::byte b1, std::byte b2) {
 
 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), "" );
 
index 22da6e3..7ed80a0 100644 (file)
@@ -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), "" );
 
index dad692e..f19a021 100644 (file)
@@ -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), "" );
 
index 6b1a68f..e2f7c95 100644 (file)
@@ -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;
 }
index 39d6590..831673a 100644 (file)
@@ -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), "" );
 
index 734780f..55f26f7 100644 (file)
@@ -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), "" );
 
index 75d6ab4..51d9835 100644 (file)
@@ -26,9 +26,9 @@ constexpr std::byte test(std::byte b1, std::byte b2) {
 
 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), "" );
 
index 02c547f..24e6fe7 100644 (file)
@@ -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), "" );
 
index b7e9a24..23db61c 100644 (file)
@@ -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), "" );
 
index a030953..74f19fd 100644 (file)
@@ -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;
 }
index 8767325..9b1c258 100644 (file)
@@ -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), "" );
 
index 426ceb7..add3168 100644 (file)
@@ -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);
 }
index 21dff01..353ef3a 100644 (file)
@@ -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, "" );
index c9b4017..0d2e7cf 100644 (file)
@@ -26,9 +26,9 @@ constexpr std::byte test(std::byte b1, std::byte b2) {
 
 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), "" );
 
index 3d0402b..fed71df 100644 (file)
@@ -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), "" );