14a6f3c47SMarshall Clow //===----------------------------------------------------------------------===//
24a6f3c47SMarshall Clow //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
64a6f3c47SMarshall Clow //
74a6f3c47SMarshall Clow //===----------------------------------------------------------------------===//
84a6f3c47SMarshall Clow 
94fc50236SJoe Loser // UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14)
104fc50236SJoe Loser 
114a6f3c47SMarshall Clow // <string_view>
124a6f3c47SMarshall Clow //   ... manipulating sequences of any non-array trivial standard-layout types.
134a6f3c47SMarshall Clow 
144a6f3c47SMarshall Clow #include <string>
154a6f3c47SMarshall Clow #include "../basic.string/test_traits.h"
164a6f3c47SMarshall Clow 
174a6f3c47SMarshall Clow struct NotTrivial {
NotTrivialNotTrivial184a6f3c47SMarshall Clow     NotTrivial() : value(3) {}
194a6f3c47SMarshall Clow     int value;
204a6f3c47SMarshall Clow };
214a6f3c47SMarshall Clow 
224a6f3c47SMarshall Clow struct NotStandardLayout {
234a6f3c47SMarshall Clow public:
NotStandardLayoutNotStandardLayout244a6f3c47SMarshall Clow     NotStandardLayout() : one(1), two(2) {}
sumNotStandardLayout254a6f3c47SMarshall Clow     int sum() const { return one + two; } // silences "unused field 'two' warning"
264a6f3c47SMarshall Clow     int one;
274a6f3c47SMarshall Clow private:
284a6f3c47SMarshall Clow     int two;
294a6f3c47SMarshall Clow };
304a6f3c47SMarshall Clow 
main(int,char **)312df59c50SJF Bastien int main(int, char**)
324a6f3c47SMarshall Clow {
334a6f3c47SMarshall Clow     {
344a6f3c47SMarshall Clow //  array
354a6f3c47SMarshall Clow     typedef char C[3];
364a6f3c47SMarshall Clow     static_assert(std::is_array<C>::value, "");
374a6f3c47SMarshall Clow     std::basic_string_view<C, test_traits<C> > sv;
38*76476efdSMuhammad Usman Shahid //  expected-error-re@string_view:* {{{{(static_assert|static assertion)}} failed{{.*}}Character type of basic_string_view must not be an array}}
394a6f3c47SMarshall Clow     }
404a6f3c47SMarshall Clow 
414a6f3c47SMarshall Clow     {
424a6f3c47SMarshall Clow //  not trivial
434a6f3c47SMarshall Clow     static_assert(!std::is_trivial<NotTrivial>::value, "");
444a6f3c47SMarshall Clow     std::basic_string_view<NotTrivial, test_traits<NotTrivial> > sv;
45*76476efdSMuhammad Usman Shahid //  expected-error-re@string_view:* {{{{(static_assert|static assertion)}} failed{{.*}}Character type of basic_string_view must be trivial}}
464a6f3c47SMarshall Clow     }
474a6f3c47SMarshall Clow 
484a6f3c47SMarshall Clow     {
494a6f3c47SMarshall Clow //  not standard layout
504a6f3c47SMarshall Clow     static_assert(!std::is_standard_layout<NotStandardLayout>::value, "");
514a6f3c47SMarshall Clow     std::basic_string_view<NotStandardLayout, test_traits<NotStandardLayout> > sv;
52*76476efdSMuhammad Usman Shahid //  expected-error-re@string_view:* {{{{(static_assert|static assertion)}} failed{{.*}}Character type of basic_string_view must be standard-layout}}
534a6f3c47SMarshall Clow     }
542df59c50SJF Bastien 
552df59c50SJF Bastien   return 0;
564a6f3c47SMarshall Clow }
57