| 3252 | REGISTER_TEST(TestLeakAutoVar) |
| 3253 | |
| 3254 | class TestLeakAutoVarRecursiveCountLimit : public TestFixture { |
| 3255 | public: |
| 3256 | TestLeakAutoVarRecursiveCountLimit() : TestFixture("TestLeakAutoVarRecursiveCountLimit") {} |
| 3257 | |
| 3258 | private: |
| 3259 | const Settings settings = settingsBuilder().library("std.cfg").checkLibrary().build(); |
| 3260 | |
| 3261 | #define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__) |
| 3262 | template<size_t size> |
| 3263 | void checkP_(const char* file, int line, const char (&code)[size]) { |
| 3264 | SimpleTokenizer2 tokenizer(settings, *this, code, "test.c"); |
| 3265 | |
| 3266 | // Tokenizer.. |
| 3267 | ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); |
| 3268 | |
| 3269 | CheckLeakAutoVar check; |
| 3270 | runChecks(check, tokenizer, *this); |
| 3271 | } |
| 3272 | |
| 3273 | void run() override { |
| 3274 | mNewTemplate = true; |
| 3275 | TEST_CASE(recursiveCountLimit); // #5872 #6157 #9097 |
| 3276 | } |
| 3277 | |
| 3278 | void recursiveCountLimit() { // #5872 #6157 #9097 |
| 3279 | ASSERT_THROW_INTERNAL_EQUALS(checkP("#define ONE else if (0) { }\n" |
| 3280 | "#define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE\n" |
| 3281 | "#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN\n" |
| 3282 | "#define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN\n" |
| 3283 | "void foo() {\n" |
| 3284 | " if (0) { }\n" |
| 3285 | " THOU THOU\n" |
| 3286 | "}"), LIMIT, "Internal limit: CheckLeakAutoVar::checkScope() Maximum recursive count of 1000 reached."); |
| 3287 | ASSERT_NO_THROW(checkP("#define ONE if (0) { }\n" |
| 3288 | "#define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE\n" |
| 3289 | "#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN\n" |
| 3290 | "#define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN\n" |
| 3291 | "void foo() {\n" |
| 3292 | " if (0) { }\n" |
| 3293 | " THOU THOU\n" |
| 3294 | "}")); |
| 3295 | } |
| 3296 | }; |
| 3297 | |
| 3298 | #if !defined(__MINGW32__) && !defined(__CYGWIN__) |
| 3299 | // TODO: this crashes with a stack overflow for MinGW and error 2816 for Cygwinin the CI |
nothing calls this directly
no test coverage detected