1 | /* |
2 | Copyright (c) 2005-2019 Intel Corporation |
3 | |
4 | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | you may not use this file except in compliance with the License. |
6 | You may obtain a copy of the License at |
7 | |
8 | http://www.apache.org/licenses/LICENSE-2.0 |
9 | |
10 | Unless required by applicable law or agreed to in writing, software |
11 | distributed under the License is distributed on an "AS IS" BASIS, |
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | See the License for the specific language governing permissions and |
14 | limitations under the License. |
15 | */ |
16 | |
17 | #include "tbb/tbb_stddef.h" |
18 | |
19 | void TestInsideFunction(){ |
20 | __TBB_STATIC_ASSERT(sizeof(char)>=1,"" ); |
21 | } |
22 | void TestTwiceAtTheSameLine(){ |
23 | // for current implementation it is not possible to use |
24 | // two __TBB_STATIC_ASSERT on a same line |
25 | // __TBB_STATIC_ASSERT(true,""); __TBB_STATIC_ASSERT(true,""); |
26 | } |
27 | |
28 | void TestInsideStructure(){ |
29 | struct helper{ |
30 | __TBB_STATIC_ASSERT(true,"" ); |
31 | }; |
32 | } |
33 | |
34 | void TestTwiceInsideStructure(){ |
35 | struct helper{ |
36 | //for current implementation it is not possible to use |
37 | //two __TBB_STATIC_ASSERT on a same line inside a class definition |
38 | //__TBB_STATIC_ASSERT(true,"");__TBB_STATIC_ASSERT(true,""); |
39 | |
40 | __TBB_STATIC_ASSERT(true,"" ); |
41 | __TBB_STATIC_ASSERT(true,"" ); |
42 | }; |
43 | } |
44 | |
45 | namespace TestTwiceInsideNamespaceHelper{ |
46 | __TBB_STATIC_ASSERT(true,"" ); |
47 | __TBB_STATIC_ASSERT(true,"" ); |
48 | } |
49 | |
50 | namespace TestTwiceInsideClassTemplateHelper{ |
51 | template <typename T> |
52 | struct template_struct{ |
53 | __TBB_STATIC_ASSERT(true,"" ); |
54 | __TBB_STATIC_ASSERT(true,"" ); |
55 | }; |
56 | } |
57 | |
58 | void TestTwiceInsideTemplateClass(){ |
59 | using namespace TestTwiceInsideClassTemplateHelper; |
60 | typedef template_struct<int> template_struct_int_typedef; |
61 | typedef template_struct<char> template_struct_char_typedef; |
62 | tbb::internal::suppress_unused_warning(template_struct_int_typedef(), template_struct_char_typedef()); |
63 | } |
64 | |
65 | template<typename T> |
66 | void TestTwiceInsideTemplateFunction(){ |
67 | __TBB_STATIC_ASSERT(sizeof(T)>=1,"" ); |
68 | __TBB_STATIC_ASSERT(true,"" ); |
69 | } |
70 | |
71 | #include "harness.h" |
72 | int TestMain() { |
73 | #if __TBB_STATIC_ASSERT_PRESENT |
74 | REPORT("Known issue: %s\n" , "no need to test ad-hoc implementation as native feature of C++11 is used" ); |
75 | return Harness::Skipped; |
76 | #else |
77 | TestInsideFunction(); |
78 | TestInsideStructure(); |
79 | TestTwiceAtTheSameLine(); |
80 | TestTwiceInsideStructure(); |
81 | TestTwiceInsideTemplateClass(); |
82 | TestTwiceInsideTemplateFunction<char>(); |
83 | return Harness::Done; |
84 | #endif |
85 | } |
86 | |