1*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 2*58b9f456SAndroid Build Coastguard Worker // 3*58b9f456SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*58b9f456SAndroid Build Coastguard Worker // 5*58b9f456SAndroid Build Coastguard Worker // This file is dual licensed under the MIT and the University of Illinois Open 6*58b9f456SAndroid Build Coastguard Worker // Source Licenses. See LICENSE.TXT for details. 7*58b9f456SAndroid Build Coastguard Worker // 8*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*58b9f456SAndroid Build Coastguard Worker 10*58b9f456SAndroid Build Coastguard Worker // <string> 11*58b9f456SAndroid Build Coastguard Worker // ... manipulating sequences of any non-array trivial standard-layout types. 12*58b9f456SAndroid Build Coastguard Worker 13*58b9f456SAndroid Build Coastguard Worker #include <string> 14*58b9f456SAndroid Build Coastguard Worker #include "test_traits.h" 15*58b9f456SAndroid Build Coastguard Worker 16*58b9f456SAndroid Build Coastguard Worker struct NotTrivial { NotTrivialNotTrivial17*58b9f456SAndroid Build Coastguard Worker NotTrivial() : value(3) {} 18*58b9f456SAndroid Build Coastguard Worker int value; 19*58b9f456SAndroid Build Coastguard Worker }; 20*58b9f456SAndroid Build Coastguard Worker 21*58b9f456SAndroid Build Coastguard Worker struct NotStandardLayout { 22*58b9f456SAndroid Build Coastguard Worker public: NotStandardLayoutNotStandardLayout23*58b9f456SAndroid Build Coastguard Worker NotStandardLayout() : one(1), two(2) {} sumNotStandardLayout24*58b9f456SAndroid Build Coastguard Worker int sum() const { return one + two; } // silences "unused field 'two' warning" 25*58b9f456SAndroid Build Coastguard Worker int one; 26*58b9f456SAndroid Build Coastguard Worker private: 27*58b9f456SAndroid Build Coastguard Worker int two; 28*58b9f456SAndroid Build Coastguard Worker }; 29*58b9f456SAndroid Build Coastguard Worker main()30*58b9f456SAndroid Build Coastguard Workerint main() 31*58b9f456SAndroid Build Coastguard Worker { 32*58b9f456SAndroid Build Coastguard Worker { 33*58b9f456SAndroid Build Coastguard Worker // array 34*58b9f456SAndroid Build Coastguard Worker typedef char C[3]; 35*58b9f456SAndroid Build Coastguard Worker static_assert(std::is_array<C>::value, ""); 36*58b9f456SAndroid Build Coastguard Worker std::basic_string<C, test_traits<C> > s; 37*58b9f456SAndroid Build Coastguard Worker // expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must not be an array"}} 38*58b9f456SAndroid Build Coastguard Worker } 39*58b9f456SAndroid Build Coastguard Worker 40*58b9f456SAndroid Build Coastguard Worker { 41*58b9f456SAndroid Build Coastguard Worker // not trivial 42*58b9f456SAndroid Build Coastguard Worker static_assert(!std::is_trivial<NotTrivial>::value, ""); 43*58b9f456SAndroid Build Coastguard Worker std::basic_string<NotTrivial, test_traits<NotTrivial> > s; 44*58b9f456SAndroid Build Coastguard Worker // expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must be trivial"}} 45*58b9f456SAndroid Build Coastguard Worker } 46*58b9f456SAndroid Build Coastguard Worker 47*58b9f456SAndroid Build Coastguard Worker { 48*58b9f456SAndroid Build Coastguard Worker // not standard layout 49*58b9f456SAndroid Build Coastguard Worker static_assert(!std::is_standard_layout<NotStandardLayout>::value, ""); 50*58b9f456SAndroid Build Coastguard Worker std::basic_string<NotStandardLayout, test_traits<NotStandardLayout> > s; 51*58b9f456SAndroid Build Coastguard Worker // expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must be standard-layout"}} 52*58b9f456SAndroid Build Coastguard Worker } 53*58b9f456SAndroid Build Coastguard Worker } 54