Index: libcxx/test/std/containers/views/span.cons/array.pass.cpp =================================================================== --- libcxx/test/std/containers/views/span.cons/array.pass.cpp +++ libcxx/test/std/containers/views/span.cons/array.pass.cpp @@ -74,50 +74,48 @@ } } - -template -constexpr bool testConstexprSpan() +template +constexpr bool testSpan() { - constexpr T val[2] = {}; + T val[2] = {}; - ASSERT_NOEXCEPT(std::span {val}); + ASSERT_NOEXCEPT(std::span{val}); + ASSERT_NOEXCEPT(std::span{val}); + ASSERT_NOEXCEPT(std::span{val}); ASSERT_NOEXCEPT(std::span{val}); - std::span s1{val}; - std::span s2{val}; - return - s1.data() == &val[0] && s1.size() == 2 - && s2.data() == &val[0] && s2.size() == 2; -} - -template -void testRuntimeSpan() -{ - T val[2] = {}; - ASSERT_NOEXCEPT(std::span {val}); - ASSERT_NOEXCEPT(std::span{val}); - std::span s1{val}; - std::span s2{val}; - assert(s1.data() == &val[0] && s1.size() == 2); - assert(s2.data() == &val[0] && s2.size() == 2); + std::span s1 = val; + std::span s2 = val; + std::span s3 = val; + std::span s4 = val; + assert(s1.data() == val && s1.size() == 2); + assert(s2.data() == val && s2.size() == 2); + assert(s3.data() == val && s3.size() == 2); + assert(s4.data() == val && s4.size() == 2); + + std::span s5 = {{1,2}}; + std::span s6 = {{1,2}}; + assert(s5.size() == 2); // and it dangles + assert(s6.size() == 2); // and it dangles + + return true; } -struct A{}; + +struct A {}; int main(int, char**) { - static_assert(testConstexprSpan(), ""); - static_assert(testConstexprSpan(), ""); - static_assert(testConstexprSpan(), ""); - static_assert(testConstexprSpan(), ""); + testSpan(); + testSpan(); + testSpan(); + testSpan(); - testRuntimeSpan(); - testRuntimeSpan(); - testRuntimeSpan(); - testRuntimeSpan(); - testRuntimeSpan(); + static_assert(testSpan()); + static_assert(testSpan()); + static_assert(testSpan()); checkCV(); - return 0; + return 0; } Index: libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +#include +#include + +struct Sink { + constexpr Sink() = default; + constexpr Sink(Sink*) {} +}; + +constexpr int count(std::span sp) { + return sp.size(); +} + +template +constexpr int countn(std::span sp) { + return sp.size(); +} + +constexpr bool test() { + Sink a[10]; + assert(count({a}) == 10); + assert(count({a, a+10}) == 10); + assert(countn<10>({a}) == 10); + return true; +} + +int main(int, char**) +{ + test(); + static_assert(test()); + + return 0; +} Index: libcxx/test/std/containers/views/span.cons/iterator_len.verify.cpp =================================================================== --- libcxx/test/std/containers/views/span.cons/iterator_len.verify.cpp +++ libcxx/test/std/containers/views/span.cons/iterator_len.verify.cpp @@ -31,7 +31,10 @@ int arr[] = {1, 2, 3}; createImplicitSpan(arr, 3); - std::span sp = {0, 0}; // expected-error {{no matching constructor for initialization of 'std::span'}} + std::span sp = {0, 0}; // expected-error {{no matching constructor for initialization of 'std::span'}} + std::span sp2 = {0, 0}; // expected-error {{no matching constructor for initialization of 'std::span'}} + std::span csp = {0, 0}; // expected-error {{no matching constructor for initialization of 'std::span'}} + std::span csp2 = {0, 0}; // expected-error {{no matching constructor for initialization of 'std::span'}} return 0; }