@@ -44,9 +44,6 @@ class Test64BitPortability : public TestFixture {
4444
4545#define check (code ) check_(code, __FILE__, __LINE__)
4646 void check_ (const char code[], const char * file, int line) {
47- // Clear the error buffer..
48- errout.str (" " );
49-
5047 // Tokenize..
5148 Tokenizer tokenizer (settings, this );
5249 std::istringstream istr (code);
@@ -63,13 +60,13 @@ class Test64BitPortability : public TestFixture {
6360 " void f() {\n "
6461 " CharArray foo = \"\" ;\n "
6562 " }" );
66- ASSERT_EQUALS (" " , errout. str ());
63+ ASSERT_EQUALS (" " , errout_str ());
6764
6865 check (" struct T { std::vector<int>*a[2][2]; };\n " // #11560
6966 " void f(T& t, int i, int j) {\n "
7067 " t.a[i][j] = new std::vector<int>;\n "
7168 " }\n " );
72- ASSERT_EQUALS (" " , errout. str ());
69+ ASSERT_EQUALS (" " , errout_str ());
7370 }
7471
7572 void novardecl () {
@@ -78,7 +75,7 @@ class Test64BitPortability : public TestFixture {
7875 " {\n "
7976 " a = p;\n "
8077 " }" );
81- ASSERT_EQUALS (" " , errout. str ());
78+ ASSERT_EQUALS (" " , errout_str ());
8279 }
8380
8481 void functionpar () {
@@ -87,65 +84,65 @@ class Test64BitPortability : public TestFixture {
8784 " int a = p;\n "
8885 " return a + 4;\n "
8986 " }" );
90- ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n " , errout. str ());
87+ ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n " , errout_str ());
9188
9289 check (" int foo(int p[])\n "
9390 " {\n "
9491 " int a = p;\n "
9592 " return a + 4;\n "
9693 " }" );
97- ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n " , errout. str ());
94+ ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n " , errout_str ());
9895
9996 check (" int foo(int p[])\n "
10097 " {\n "
10198 " int *a = p;\n "
10299 " return a;\n "
103100 " }" );
104- ASSERT_EQUALS (" [test.cpp:4]: (portability) Returning an address value in a function with integer return type is not portable.\n " , errout. str ());
101+ ASSERT_EQUALS (" [test.cpp:4]: (portability) Returning an address value in a function with integer return type is not portable.\n " , errout_str ());
105102
106103 check (" void foo(int x)\n "
107104 " {\n "
108105 " int *p = x;\n "
109106 " *p = 0;\n "
110107 " }" );
111- ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning an integer to a pointer is not portable.\n " , errout. str ());
108+ ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning an integer to a pointer is not portable.\n " , errout_str ());
112109
113110 check (" int f(const char *p) {\n " // #4659
114111 " return 6 + p[2] * 256;\n "
115112 " }" );
116- ASSERT_EQUALS (" " , errout. str ());
113+ ASSERT_EQUALS (" " , errout_str ());
117114
118115 check (" int foo(int *p) {\n " // #6096
119116 " bool a = p;\n "
120117 " return a;\n "
121118 " }" );
122- ASSERT_EQUALS (" " , errout. str ());
119+ ASSERT_EQUALS (" " , errout_str ());
123120
124121 check (" std::array<int,2> f();\n "
125122 " void g() {\n "
126123 " std::array<int, 2> a = f();\n "
127124 " }" );
128- ASSERT_EQUALS (" " , errout. str ());
125+ ASSERT_EQUALS (" " , errout_str ());
129126
130127 check (" std::array<int,2> f(int x);\n "
131128 " void g(int i) {\n "
132129 " std::array<int, 2> a = f(i);\n "
133130 " }" );
134- ASSERT_EQUALS (" " , errout. str ());
131+ ASSERT_EQUALS (" " , errout_str ());
135132
136133 check (" typedef std::array<int, 2> Array;\n "
137134 " Array f(int x);\n "
138135 " void g(int i) {\n "
139136 " Array a = f(i);\n "
140137 " }" );
141- ASSERT_EQUALS (" " , errout. str ());
138+ ASSERT_EQUALS (" " , errout_str ());
142139
143140 check (" typedef std::array<int, 2> Array;\n "
144141 " Array f();\n "
145142 " void g(int i) {\n "
146143 " Array a = f();\n "
147144 " }" );
148- ASSERT_EQUALS (" " , errout. str ());
145+ ASSERT_EQUALS (" " , errout_str ());
149146
150147 check (" struct S {\n " // #9951
151148 " enum E { E0 };\n "
@@ -154,20 +151,20 @@ class Test64BitPortability : public TestFixture {
154151 " void f() {\n "
155152 " std::array<double, 1> a = S::g(S::E::E0);\n "
156153 " }\n " );
157- ASSERT_EQUALS (" " , errout. str ());
154+ ASSERT_EQUALS (" " , errout_str ());
158155
159156 check (" char* f(char* p) {\n "
160157 " return p ? p : 0;\n "
161158 " }\n " );
162- ASSERT_EQUALS (" " , errout. str ());
159+ ASSERT_EQUALS (" " , errout_str ());
163160 }
164161
165162 void structmember () {
166163 check (" struct Foo { int *p; };\n "
167164 " void f(struct Foo *foo) {\n "
168165 " int i = foo->p;\n "
169166 " }" );
170- ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n " , errout. str ());
167+ ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n " , errout_str ());
171168
172169 check (" struct S {\n " // #10145
173170 " enum class E { e1, e2 };\n "
@@ -177,15 +174,15 @@ class Test64BitPortability : public TestFixture {
177174 " void f(S& s) {\n "
178175 " s.e = S::E::e1;\n "
179176 " }\n " );
180- ASSERT_EQUALS (" " , errout. str ());
177+ ASSERT_EQUALS (" " , errout_str ());
181178 }
182179
183180 void ptrcompare () {
184181 // Ticket #2892
185182 check (" void foo(int *p) {\n "
186183 " int a = (p != NULL);\n "
187184 " }" );
188- ASSERT_EQUALS (" " , errout. str ());
185+ ASSERT_EQUALS (" " , errout_str ());
189186 }
190187
191188 void ptrarithmetic () {
@@ -194,104 +191,104 @@ class Test64BitPortability : public TestFixture {
194191 " int x = 10;\n "
195192 " int *a = p + x;\n "
196193 " }" );
197- ASSERT_EQUALS (" " , errout. str ());
194+ ASSERT_EQUALS (" " , errout_str ());
198195
199196 check (" void foo(int *p) {\n "
200197 " int x = 10;\n "
201198 " int *a = x + p;\n "
202199 " }" );
203- ASSERT_EQUALS (" " , errout. str ());
200+ ASSERT_EQUALS (" " , errout_str ());
204201
205202 check (" void foo(int *p) {\n "
206203 " int x = 10;\n "
207204 " int *a = x * x;\n "
208205 " }" );
209- ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning an integer to a pointer is not portable.\n " , errout. str ());
206+ ASSERT_EQUALS (" [test.cpp:3]: (portability) Assigning an integer to a pointer is not portable.\n " , errout_str ());
210207
211208 check (" void foo(int *start, int *end) {\n "
212209 " int len;\n "
213210 " int len = end + 10 - start;\n "
214211 " }" );
215- ASSERT_EQUALS (" " , errout. str ());
212+ ASSERT_EQUALS (" " , errout_str ());
216213 }
217214
218215 void returnIssues () {
219216 check (" void* foo(int i) {\n "
220217 " return i;\n "
221218 " }" );
222- ASSERT_EQUALS (" [test.cpp:2]: (portability) Returning an integer in a function with pointer return type is not portable.\n " , errout. str ());
219+ ASSERT_EQUALS (" [test.cpp:2]: (portability) Returning an integer in a function with pointer return type is not portable.\n " , errout_str ());
223220
224221 check (" void* foo(int* i) {\n "
225222 " return i;\n "
226223 " }" );
227- ASSERT_EQUALS (" " , errout. str ());
224+ ASSERT_EQUALS (" " , errout_str ());
228225
229226 check (" void* foo() {\n "
230227 " return 0;\n "
231228 " }" );
232- ASSERT_EQUALS (" " , errout. str ());
229+ ASSERT_EQUALS (" " , errout_str ());
233230
234231 check (" int foo(int i) {\n "
235232 " return i;\n "
236233 " }" );
237- ASSERT_EQUALS (" " , errout. str ());
234+ ASSERT_EQUALS (" " , errout_str ());
238235
239236 check (" struct Foo {};\n "
240237 " \n "
241238 " int* dostuff(Foo foo) {\n "
242239 " return foo;\n "
243240 " }" );
244- ASSERT_EQUALS (" " , errout. str ());
241+ ASSERT_EQUALS (" " , errout_str ());
245242
246243 check (" int foo(char* c) {\n "
247244 " return c;\n "
248245 " }" );
249- ASSERT_EQUALS (" [test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n " , errout. str ());
246+ ASSERT_EQUALS (" [test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n " , errout_str ());
250247
251248 check (" int foo(char* c) {\n "
252249 " return 1+c;\n "
253250 " }" );
254- ASSERT_EQUALS (" [test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n " , errout. str ());
251+ ASSERT_EQUALS (" [test.cpp:2]: (portability) Returning an address value in a function with integer return type is not portable.\n " , errout_str ());
255252
256253 check (" std::string foo(char* c) {\n "
257254 " return c;\n "
258255 " }" );
259- ASSERT_EQUALS (" " , errout. str ());
256+ ASSERT_EQUALS (" " , errout_str ());
260257
261258 check (" int foo(char *a, char *b) {\n " // #4486
262259 " return a + 1 - b;\n "
263260 " }" );
264- ASSERT_EQUALS (" " , errout. str ());
261+ ASSERT_EQUALS (" " , errout_str ());
265262
266263 check (" struct s {\n " // 4642
267264 " int i;\n "
268265 " };\n "
269266 " int func(struct s *p) {\n "
270267 " return 1 + p->i;\n "
271268 " }" );
272- ASSERT_EQUALS (" " , errout. str ());
269+ ASSERT_EQUALS (" " , errout_str ());
273270
274271 check (" static void __iomem *f(unsigned int port_no) {\n "
275272 " void __iomem *mmio = hpriv->mmio;\n "
276273 " return mmio + (port_no * 0x80);\n "
277274 " }" );
278- ASSERT_EQUALS (" " , errout. str ());
275+ ASSERT_EQUALS (" " , errout_str ());
279276
280277 // #7247: don't check return statements in nested functions..
281278 check (" int foo() {\n "
282279 " struct {\n "
283280 " const char * name() { return \" abc\" ; }\n "
284281 " } table;\n "
285282 " }" );
286- ASSERT_EQUALS (" " , errout. str ());
283+ ASSERT_EQUALS (" " , errout_str ());
287284
288285 // #7451: Lambdas
289286 check (" const int* test(std::vector<int> outputs, const std::string& text) {\n "
290287 " auto it = std::find_if(outputs.begin(), outputs.end(),\n "
291288 " [&](int ele) { return \" test\" == text; });\n "
292289 " return nullptr;\n "
293290 " }" );
294- ASSERT_EQUALS (" " , errout. str ());
291+ ASSERT_EQUALS (" " , errout_str ());
295292
296293 check (" struct S {\n " // #12159
297294 " std::future<int> f() const {\n "
@@ -303,7 +300,7 @@ class Test64BitPortability : public TestFixture {
303300 " auto x = s->f();\n "
304301 " return x.get();\n "
305302 " }\n " );
306- ASSERT_EQUALS (" " , errout. str ());
303+ ASSERT_EQUALS (" " , errout_str ());
307304 }
308305};
309306
0 commit comments