STL_MSFT created this revision.
[libcxx] [test] Avoid P0138R2, direct-list-init of fixed enums from integers.
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.
(I encountered this because C1XX currently has a bug in this feature, and our
Clang/C2 is still 3.8 and missing this feature. But these tests had UNSUPPORTED
comments knocking out several versions of Clang, so the impact isn't just
limited to us.)
https://reviews.llvm.org/D32386
Files:
test/std/language.support/support.types/byteops/and.assign.pass.cpp
test/std/language.support/support.types/byteops/and.pass.cpp
test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
test/std/language.support/support.types/byteops/lshift.fail.cpp
test/std/language.support/support.types/byteops/lshift.pass.cpp
test/std/language.support/support.types/byteops/not.pass.cpp
test/std/language.support/support.types/byteops/or.assign.pass.cpp
test/std/language.support/support.types/byteops/or.pass.cpp
test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
test/std/language.support/support.types/byteops/rshift.fail.cpp
test/std/language.support/support.types/byteops/rshift.pass.cpp
test/std/language.support/support.types/byteops/to_integer.fail.cpp
test/std/language.support/support.types/byteops/to_integer.pass.cpp
test/std/language.support/support.types/byteops/xor.assign.pass.cpp
test/std/language.support/support.types/byteops/xor.pass.cpp
Index: test/std/language.support/support.types/byteops/xor.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/xor.pass.cpp
+++ test/std/language.support/support.types/byteops/xor.pass.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// 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: test/std/language.support/support.types/byteops/xor.assign.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/xor.assign.pass.cpp
+++ test/std/language.support/support.types/byteops/xor.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte& operator ^=(byte l, byte r) noexcept;
@@ -26,9 +23,9 @@
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: test/std/language.support/support.types/byteops/to_integer.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/to_integer.pass.cpp
+++ test/std/language.support/support.types/byteops/to_integer.pass.cpp
@@ -11,18 +11,15 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr IntegerType to_integer(byte b) noexcept;
// This function shall not participate in overload resolution unless
// 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: test/std/language.support/support.types/byteops/to_integer.fail.cpp
===================================================================
--- test/std/language.support/support.types/byteops/to_integer.fail.cpp
+++ test/std/language.support/support.types/byteops/to_integer.fail.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr IntegerType to_integer(byte b) noexcept;
// This function shall not participate in overload resolution unless
// 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: test/std/language.support/support.types/byteops/rshift.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/rshift.pass.cpp
+++ test/std/language.support/support.types/byteops/rshift.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte operator <<(byte b, IntegerType shift) noexcept;
@@ -27,8 +24,8 @@
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: test/std/language.support/support.types/byteops/rshift.fail.cpp
===================================================================
--- test/std/language.support/support.types/byteops/rshift.fail.cpp
+++ test/std/language.support/support.types/byteops/rshift.fail.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte operator >>(byte b, IntegerType shift) noexcept;
// These functions shall not participate in overload resolution unless
// 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: test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
+++ test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept;
@@ -28,8 +25,8 @@
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: test/std/language.support/support.types/byteops/or.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/or.pass.cpp
+++ test/std/language.support/support.types/byteops/or.pass.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// 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: test/std/language.support/support.types/byteops/or.assign.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/or.assign.pass.cpp
+++ test/std/language.support/support.types/byteops/or.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte& operator |=(byte l, byte r) noexcept;
@@ -26,9 +23,9 @@
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: test/std/language.support/support.types/byteops/not.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/not.pass.cpp
+++ test/std/language.support/support.types/byteops/not.pass.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// 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: test/std/language.support/support.types/byteops/lshift.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/lshift.pass.cpp
+++ test/std/language.support/support.types/byteops/lshift.pass.cpp
@@ -11,18 +11,15 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte operator <<(byte b, IntegerType shift) noexcept;
// These functions shall not participate in overload resolution unless
// 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: test/std/language.support/support.types/byteops/lshift.fail.cpp
===================================================================
--- test/std/language.support/support.types/byteops/lshift.fail.cpp
+++ test/std/language.support/support.types/byteops/lshift.fail.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte operator <<(byte b, IntegerType shift) noexcept;
// These functions shall not participate in overload resolution unless
// 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: test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
+++ test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept;
@@ -28,8 +25,8 @@
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: test/std/language.support/support.types/byteops/and.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/and.pass.cpp
+++ test/std/language.support/support.types/byteops/and.pass.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// 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: test/std/language.support/support.types/byteops/and.assign.pass.cpp
===================================================================
--- test/std/language.support/support.types/byteops/and.assign.pass.cpp
+++ test/std/language.support/support.types/byteops/and.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte& operator &=(byte l, byte r) noexcept;
@@ -26,9 +23,9 @@
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), "" );
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits