mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 18:38:30 +08:00
[libcxx] Make return value of array<T, 0>.data() checked only for libc++
The section array.zero says: "The return value of data() is unspecified". This patch marks all checks of the array<T, 0>.data() return value as libc++ specific. Reviewed as https://reviews.llvm.org/D55364. Thanks to Andrey Maksimov for the patch. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@348485 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -42,7 +42,7 @@ int main()
|
||||
typedef std::array<T, 0> C;
|
||||
C c = {};
|
||||
T* p = c.data();
|
||||
assert(p != nullptr);
|
||||
LIBCPP_ASSERT(p != nullptr);
|
||||
}
|
||||
{
|
||||
typedef double T;
|
||||
@@ -50,14 +50,14 @@ int main()
|
||||
C c = {{}};
|
||||
const T* p = c.data();
|
||||
static_assert((std::is_same<decltype(c.data()), const T*>::value), "");
|
||||
assert(p != nullptr);
|
||||
LIBCPP_ASSERT(p != nullptr);
|
||||
}
|
||||
{
|
||||
typedef std::max_align_t T;
|
||||
typedef std::array<T, 0> C;
|
||||
const C c = {};
|
||||
const T* p = c.data();
|
||||
assert(p != nullptr);
|
||||
LIBCPP_ASSERT(p != nullptr);
|
||||
std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
|
||||
assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
|
||||
}
|
||||
@@ -66,6 +66,6 @@ int main()
|
||||
typedef std::array<T, 0> C;
|
||||
C c = {};
|
||||
T* p = c.data();
|
||||
assert(p != nullptr);
|
||||
LIBCPP_ASSERT(p != nullptr);
|
||||
}
|
||||
}
|
||||
|
@@ -48,14 +48,14 @@ int main()
|
||||
typedef std::array<T, 0> C;
|
||||
const C c = {};
|
||||
const T* p = c.data();
|
||||
assert(p != nullptr);
|
||||
LIBCPP_ASSERT(p != nullptr);
|
||||
}
|
||||
{
|
||||
typedef std::max_align_t T;
|
||||
typedef std::array<T, 0> C;
|
||||
const C c = {};
|
||||
const T* p = c.data();
|
||||
assert(p != nullptr);
|
||||
LIBCPP_ASSERT(p != nullptr);
|
||||
std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
|
||||
assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user