[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:
Louis Dionne
2018-12-06 13:52:20 +00:00
parent 8bcb9cabcd
commit edfdc498b8
2 changed files with 6 additions and 6 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}