diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 9d214c9f146..1cc088120a7 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -499,9 +499,10 @@ unsigned int CppCheck::checkClang(const std::string &path) } try { - std::istringstream ast(output2); - Tokenizer tokenizer(mSettings, this); + Preprocessor preprocessor(mSettings, this); + Tokenizer tokenizer(mSettings, this, &preprocessor); tokenizer.list.appendFileIfNew(path); + std::istringstream ast(output2); clangimport::parseClangAstDump(tokenizer, ast); ValueFlow::setValues(tokenizer.list, const_cast(*tokenizer.getSymbolDatabase()), diff --git a/test/cli/clang-import_test.py b/test/cli/clang-import_test.py index fc98a4cf773..13be3cd05aa 100644 --- a/test/cli/clang-import_test.py +++ b/test/cli/clang-import_test.py @@ -139,4 +139,15 @@ def test_log(tmpdir): 'Checking {} ...'.format(test_file).replace('\\', '/'), ] - assert_cppcheck(args, ec_exp=0, err_exp=[], out_exp=out_lines) \ No newline at end of file + assert_cppcheck(args, ec_exp=0, err_exp=[], out_exp=out_lines) + + +def test_warning(tmpdir): # #12424 + test_file = os.path.join(tmpdir, 'test_2') + with open(test_file, 'wt') as f: + f.write('''void f() {}''') + + exitcode, stdout, stderr = cppcheck(['-q', '--enable=warning', '--clang', test_file]) + assert exitcode == 0, stderr # do not assert + assert stdout == '' + assert stderr == ''