diff --git a/libcxx/test/std/strings/basic.string/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/strings/basic.string/allocator_mismatch.verify.cpp rename from libcxx/test/std/strings/basic.string/allocator_mismatch.compile.fail.cpp rename to libcxx/test/std/strings/basic.string/allocator_mismatch.verify.cpp --- a/libcxx/test/std/strings/basic.string/allocator_mismatch.compile.fail.cpp +++ b/libcxx/test/std/strings/basic.string/allocator_mismatch.verify.cpp @@ -11,9 +11,4 @@ #include -int main(int, char**) -{ - std::basic_string, std::allocator > s; - - return 0; -} +std::basic_string, std::allocator > s; // expected-error@*:* {{Allocator::value_type must be same type as value_type}} diff --git a/libcxx/test/std/strings/basic.string/char.bad.fail.cpp b/libcxx/test/std/strings/basic.string/char.bad.fail.cpp deleted file mode 100644 --- a/libcxx/test/std/strings/basic.string/char.bad.fail.cpp +++ /dev/null @@ -1,54 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -// -// ... manipulating sequences of any non-array trivial standard-layout types. - -#include -#include "test_traits.h" - -struct NotTrivial { - NotTrivial() : value(3) {} - int value; -}; - -struct NotStandardLayout { -public: - NotStandardLayout() : one(1), two(2) {} - int sum() const { return one + two; } // silences "unused field 'two' warning" - int one; -private: - int two; -}; - -int main(int, char**) -{ - { -// array - typedef char C[3]; - static_assert(std::is_array::value, ""); - std::basic_string > s; -// expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must not be an array"}} - } - - { -// not trivial - static_assert(!std::is_trivial::value, ""); - std::basic_string > s; -// expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must be trivial"}} - } - - { -// not standard layout - static_assert(!std::is_standard_layout::value, ""); - std::basic_string > s; -// expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must be standard-layout"}} - } - - return 0; -} diff --git a/libcxx/test/std/strings/basic.string/char.bad.verify.cpp b/libcxx/test/std/strings/basic.string/char.bad.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/char.bad.verify.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// +// ... manipulating sequences of any non-array trivial standard-layout types. + +#include +#include "test_traits.h" + +struct NotTrivial { + NotTrivial() : value(3) {} + int value; +}; + +struct NotStandardLayout { +public: + NotStandardLayout() : one(1), two(2) {} + int sum() const { return one + two; } // silences "unused field 'two' warning" + int one; +private: + int two; +}; + +void f() { + { + // array + typedef char C[3]; + static_assert(std::is_array::value, ""); + std::basic_string > s; + // expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must not be an array"}} + } + + { + // not trivial + static_assert(!std::is_trivial::value, ""); + std::basic_string > s; + // expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must be trivial"}} + } + + { + // not standard layout + static_assert(!std::is_standard_layout::value, ""); + std::basic_string > s; + // expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must be standard-layout"}} + } +} diff --git a/libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp b/libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp deleted file mode 100644 --- a/libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -// template::value_type>> -// basic_string(InputIterator, InputIterator, Allocator = Allocator()) -// -> basic_string::value_type, -// char_traits::value_type>, -// Allocator>; -// -// The deduction guide shall not participate in overload resolution if InputIterator -// is a type that does not qualify as an input iterator, or if Allocator is a type -// that does not qualify as an allocator. - - -#include -#include -#include -#include - -#include "test_macros.h" - -class NotAnIterator {}; - -template -struct NotAnAllocator { typedef T value_type; }; - -int main(int, char**) -{ - { // Not an iterator at all - std::basic_string s1{NotAnIterator{}, NotAnIterator{}, std::allocator{}}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}} - } - { // Not an input iterator - std::basic_string s0; - std::basic_string s1{std::back_insert_iterator(s0), // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}} - std::back_insert_iterator(s0), - std::allocator{}}; - } - { // Not an allocator - const wchar_t* s = L"12345678901234"; - (void)s; - std::basic_string s1{s, s+10, NotAnAllocator{}}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}} - } - - - return 0; -} diff --git a/libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp @@ -9,10 +9,6 @@ // // UNSUPPORTED: c++03, c++11, c++14 -// template -// basic_string(InputIterator begin, InputIterator end, -// const Allocator& a = Allocator()); - // template::value_type>> // basic_string(InputIterator, InputIterator, Allocator = Allocator()) @@ -24,15 +20,35 @@ // is a type that does not qualify as an input iterator, or if Allocator is a type // that does not qualify as an allocator. -#include -#include #include #include +#include +#include +#include #include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" +class NotAnIterator {}; +using NotAnInputIterator = std::back_insert_iterator>; + +template +struct NotAnAllocator { typedef T value_type; }; + +template +struct CanDeduce : std::false_type { }; + +template +struct CanDeduce(), std::declval(), std::declval()} +)> : std::true_type { }; + +static_assert( CanDeduce>::value); +static_assert(!CanDeduce>::value); +static_assert(!CanDeduce>::value); +static_assert(!CanDeduce>::value); + bool test() { { const char* s = "12345678901234"; @@ -90,6 +106,10 @@ int main(int, char**) { + test(); +#if TEST_STD_VER > 17 + // static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/strings/basic.string/string.cons/string_view.compile.fail.cpp b/libcxx/test/std/strings/basic.string/string.cons/string_view.compile.fail.cpp deleted file mode 100644 --- a/libcxx/test/std/strings/basic.string/string.cons/string_view.compile.fail.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -// - -// explicit basic_string(basic_string_view sv, const Allocator& a = Allocator()); - -#include -#include - -void foo ( const string &s ) {} - -int main(int, char**) -{ - std::string_view sv = "ABCDE"; - foo(sv); // requires implicit conversion from string_view to string - - return 0; -} diff --git a/libcxx/test/std/strings/basic.string/string.cons/string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/string_view.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/string_view.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/string_view.pass.cpp @@ -10,15 +10,19 @@ // explicit basic_string(basic_string_view sv, const Allocator& a = Allocator()); -#include -#include -#include #include #include +#include +#include +#include +#include -#include "test_macros.h" -#include "test_allocator.h" #include "min_allocator.h" +#include "test_allocator.h" +#include "test_macros.h" + +static_assert(!std::is_convertible::value, ""); +static_assert(!std::is_convertible::value, ""); template TEST_CONSTEXPR_CXX20 void diff --git a/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp b/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp deleted file mode 100644 --- a/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -// template -// basic_string(InputIterator begin, InputIterator end, -// const Allocator& a = Allocator()); - -// template -// > -// basic_string(basic_string_view, const Allocator& = Allocator()) -// -> basic_string; -// -// The deduction guide shall not participate in overload resolution if Allocator -// is a type that does not qualify as an allocator. - -#include -#include -#include -#include -#include - -int main(int, char**) -{ - { - std::string_view sv = "12345678901234"; - std::basic_string s1{sv, 23}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}} - } - - return 0; -} diff --git a/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp @@ -9,10 +9,6 @@ // // UNSUPPORTED: c++03, c++11, c++14 -// template -// basic_string(InputIterator begin, InputIterator end, -// const Allocator& a = Allocator()); - // template @@ -35,6 +31,18 @@ #include "test_allocator.h" #include "min_allocator.h" +template +struct CanDeduce : std::false_type { }; + +template +struct CanDeduce(), std::declval()} +)> : std::true_type { }; + +struct NotAnAllocator { }; +static_assert( CanDeduce>::value); +static_assert(!CanDeduce::value); + bool test() { { std::string_view sv = "12345678901234"; diff --git a/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp b/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp deleted file mode 100644 --- a/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -// template -// basic_string(InputIterator begin, InputIterator end, -// const Allocator& a = Allocator()); - -// template -// > -// basic_string(basic_string_view, -// typename see below::size_type, -// typename see below::size_type, -// const Allocator& = Allocator()) -// -> basic_string; -// -// A size_type parameter type in a basic_string deduction guide refers to the size_type -// member type of the type deduced by the deduction guide. -// -// The deduction guide shall not participate in overload resolution if Allocator -// is a type that does not qualify as an allocator. - -#include -#include -#include -#include -#include - -int main(int, char**) -{ - { - std::string_view sv = "12345678901234"; - std::basic_string s1{sv, 0, 4, 23}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}} - } - - return 0; -} diff --git a/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp @@ -9,10 +9,6 @@ // // UNSUPPORTED: c++03, c++11, c++14 -// template -// basic_string(InputIterator begin, InputIterator end, -// const Allocator& a = Allocator()); - // template @@ -39,6 +35,18 @@ #include "test_allocator.h" #include "min_allocator.h" +template +struct CanDeduce : std::false_type { }; + +template +struct CanDeduce(), std::declval(), std::declval(), std::declval()} +)> : std::true_type { }; + +struct NotAnAllocator { }; +static_assert( CanDeduce>::value); +static_assert(!CanDeduce::value); + bool test() { { std::string_view sv = "12345678901234"; diff --git a/libcxx/test/std/strings/basic.string/traits_mismatch.compile.fail.cpp b/libcxx/test/std/strings/basic.string/traits_mismatch.verify.cpp rename from libcxx/test/std/strings/basic.string/traits_mismatch.compile.fail.cpp rename to libcxx/test/std/strings/basic.string/traits_mismatch.verify.cpp --- a/libcxx/test/std/strings/basic.string/traits_mismatch.compile.fail.cpp +++ b/libcxx/test/std/strings/basic.string/traits_mismatch.verify.cpp @@ -11,9 +11,4 @@ #include -int main(int, char**) -{ - std::basic_string> s; - - return 0; -} +std::basic_string > s; // expected-error@*:* {{traits_type::char_type must be the same type as CharT}}