@@ -52,6 +52,50 @@ template <class T> class C {
52
52
inline void i5 () {} // NON_COMPLIANT - never used in any instantiation
53
53
};
54
54
55
+ #include " test.hpp"
56
+ #include < type_traits>
57
+
58
+ template <typename T1, typename T2>
59
+ constexpr bool aConstExprFunc () noexcept { // COMPLIANT
60
+ static_assert (std::is_trivially_copy_constructible<T1>() &&
61
+ std::is_trivially_copy_constructible<T2>(),
62
+ " assert" );
63
+ return true ;
64
+ }
65
+
66
+ template <typename T, int val> class AClass { T anArr[val]; };
67
+
68
+ void aCalledFunc1 () // COMPLIANT
69
+ {
70
+ struct ANestedClass {
71
+ ANestedClass () noexcept (false ) { // COMPLIANT: False Positive!
72
+ static_cast <void >(0 );
73
+ }
74
+ };
75
+ static_assert (std::is_trivially_copy_constructible<AClass<ANestedClass, 5 >>(),
76
+ " Must be trivially copy constructible" );
77
+ }
78
+
79
+ void anUnusedFunction () // NON_COMPLIANT
80
+ {
81
+ struct AnotherNestedClass {
82
+ AnotherNestedClass () noexcept (false ) { // NON_COMPLAINT
83
+ static_cast <void >(0 );
84
+ }
85
+ };
86
+ AnotherNestedClass d;
87
+ }
88
+
89
+ void aCalledFunc2 () // COMPLIANT
90
+ {
91
+ struct YetAnotherNestedClass {
92
+ YetAnotherNestedClass () noexcept (false ) {
93
+ static_cast <void >(0 );
94
+ } // COMPLIANT
95
+ };
96
+ YetAnotherNestedClass d;
97
+ };
98
+
55
99
int main () { // COMPLIANT - this is a main like function which acts as an entry
56
100
// point
57
101
f3 ();
@@ -88,8 +132,37 @@ int main() { // COMPLIANT - this is a main like function which acts as an entry
88
132
c1.getAT ();
89
133
S s;
90
134
c2.i1 (s);
135
+
136
+ int aVar;
137
+ aConstExprFunc<decltype (aCalledFuncInHeader (aVar)), int >();
138
+ aCalledFunc1 ();
139
+ aCalledFunc2 ();
91
140
}
92
141
class M {
93
142
public:
94
143
M (const M &) = delete ; // COMPLIANT - ignore if deleted
95
- };
144
+ };
145
+
146
+ #include < gtest/gtest.h>
147
+ int called_from_google_test_function (
148
+ int a_param) // COMPLIANT - called from TEST
149
+ {
150
+ int something = a_param;
151
+ something++;
152
+ return something;
153
+ }
154
+
155
+ TEST (sample_test,
156
+ called_from_google_test_function) // COMPLIANT - Google Test function
157
+ {
158
+ bool pass = false ;
159
+ if (called_from_google_test_function (0 ) >= 10 )
160
+ pass = true ;
161
+ struct a_nested_class_in_gtest {
162
+ a_nested_class_in_gtest () noexcept (false ) {
163
+ static_cast <void >(0 );
164
+ } // COMPLIANT
165
+ };
166
+ static_assert (std::is_trivially_copy_constructible<a_nested_class_in_gtest>(),
167
+ " assert" );
168
+ }
0 commit comments