1 // This is a fake system header with divide-by-zero bugs introduced in
2 // c++ std library functions. We use these bugs to test hard-coded
3 // suppression of diagnostics within standard library functions that are known
4 // to produce false positives.
6 #pragma clang system_header
8 typedef unsigned char uint8_t;
10 typedef __typeof__(sizeof(int)) size_t;
11 void *memmove(void *s1
, const void *s2
, size_t n
);
18 void deallocate(void *p
) {
23 template <class _Alloc
>
24 class allocator_traits
{
26 static void deallocate(void *p
) {
27 _Alloc().deallocate(p
);
31 template <class _Tp
, class _Alloc
>
35 template <class _Tp
, class _Alloc
= allocator
<_Tp
> >
37 : private __list_imp
<_Tp
, _Alloc
>
41 // Fake use-after-free.
42 // No warning is expected as we are suppressing warning coming
51 template<class _CharT
, class _Alloc
= allocator
<_CharT
> >
52 class __attribute__ ((__type_visibility__("default"))) basic_string
{
55 _CharT localStorage
[4];
56 _CharT
*externalStorage
;
58 void assignExternal(_CharT
*newExternal
) {
59 externalStorage
= newExternal
;
63 typedef allocator_traits
<_Alloc
> __alloc_traits
;
68 void push_back(int c
) {
69 // Fake error trigger.
70 // No warning is expected as we are suppressing warning coming
71 // out of std::basic_string.
77 return isLong
? storage
.externalStorage
: storage
.localStorage
;
80 basic_string
&operator +=(int c
) {
81 // Fake deallocate stack-based storage.
82 // No warning is expected as we are suppressing warnings within
84 __alloc_traits::deallocate(getBuffer());
87 basic_string
&operator =(const basic_string
&other
) {
88 // Fake deallocate stack-based storage, then use the variable in the
90 // No warning is expected as we are suppressing warnings within
92 __alloc_traits::deallocate(getBuffer());
93 storage
.assignExternal(new _CharT
[4]);
97 template<class _Engine
, class _UIntType
>
98 class __independent_bits_engine
{
100 // constructors and seeding functions
101 __independent_bits_engine(_Engine
& __e
, size_t __w
);
104 template<class _Engine
, class _UIntType
>
105 __independent_bits_engine
<_Engine
, _UIntType
>
106 ::__independent_bits_engine(_Engine
& __e
, size_t __w
)
108 // Fake error trigger.
109 // No warning is expected as we are suppressing warning coming
110 // out of std::__independent_bits_engine.
115 #if __has_feature(cxx_decltype)
116 typedef decltype(nullptr) nullptr_t
;
122 constexpr shared_ptr(nullptr_t
);
123 explicit shared_ptr(_Tp
* __p
);
125 shared_ptr(shared_ptr
&& __r
) { }
129 shared_ptr
& operator=(shared_ptr
&& __r
) {
130 // Fake error trigger.
131 // No warning is expected as we are suppressing warning coming
132 // out of std::shared_ptr.
141 shared_ptr
<_Tp
>::shared_ptr(nullptr_t
) {
144 #endif // __has_feature(cxx_decltype)