Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions test/testbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4283,8 +4283,9 @@ class TestBufferOverrun : public TestFixture {
" <arg nr=\"3\"/>\n"
" </function>\n"
"</def>";
/*const*/ Settings settings = settingsBuilder().libraryxml(xmldata).severity(Severity::warning).build();
settings.platform.sizeof_wchar_t = 4;
// use a platform which has wchar_t with a sizeof 4
const Settings settings = settingsBuilder().libraryxml(xmldata).severity(Severity::warning).platform(Platform::Unix32).build();
ASSERT_EQUALS(4, settings.platform.sizeof_wchar_t);

check("void f() {\n"
" char c[10];\n"
Expand Down
136 changes: 75 additions & 61 deletions test/testpreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1989,9 +1989,9 @@ class TestPreprocessor : public TestFixture {
}

void inline_suppressions() {
/*const*/ Settings settings;
settings.inlineSuppressions = true;
settings.checks.enable(Checks::missingInclude);
const auto settings = dinit(Settings,
$.inlineSuppressions = true,
$.checks.enable (Checks::missingInclude));

const char code[] = "// cppcheck-suppress missingInclude\n"
"#include \"missing.h\"\n"
Expand Down Expand Up @@ -2430,10 +2430,11 @@ class TestPreprocessor : public TestFixture {

// test for existing local include
void testMissingInclude() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

ScopedFile header("header.h", "");
Expand All @@ -2446,10 +2447,11 @@ class TestPreprocessor : public TestFixture {

// test for missing local include
void testMissingInclude2() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

const char code[] = "#include \"header.h\"";
Expand All @@ -2460,10 +2462,11 @@ class TestPreprocessor : public TestFixture {

// test for missing local include - no include path given
void testMissingInclude3() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

ScopedFile header("header.h", "", "inc");
Expand All @@ -2476,11 +2479,12 @@ class TestPreprocessor : public TestFixture {

// test for existing local include - include path provided
void testMissingInclude4() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.includePaths.emplace_back("inc");
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.includePaths.emplace_back ("inc"),
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

ScopedFile header("header.h", "", "inc");
Expand All @@ -2493,11 +2497,12 @@ class TestPreprocessor : public TestFixture {

// test for existing local include - absolute path
void testMissingInclude5() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.includePaths.emplace_back("inc");
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.includePaths.emplace_back ("inc"),
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

ScopedFile header("header.h", "", Path::getCurrentPath());
Expand All @@ -2510,10 +2515,11 @@ class TestPreprocessor : public TestFixture {

// test for missing local include - absolute path
void testMissingInclude6() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

const std::string header = Path::join(Path::getCurrentPath(), "header.h");
Expand All @@ -2526,10 +2532,11 @@ class TestPreprocessor : public TestFixture {

// test for missing system include - system includes are not searched for in relative path
void testMissingSystemInclude() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

ScopedFile header("header.h", "");
Expand All @@ -2542,10 +2549,11 @@ class TestPreprocessor : public TestFixture {

// test for missing system include
void testMissingSystemInclude2() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

const char code[] = "#include <header.h>";
Expand All @@ -2556,28 +2564,30 @@ class TestPreprocessor : public TestFixture {

// test for existing system include in system include path
void testMissingSystemInclude3() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.templateFormat = "simple", // has no effect
$.includePaths.emplace_back ("system")
);
setTemplateFormat("simple");
settings.includePaths.emplace_back("system");

ScopedFile header("header.h", "", "system");

const char code[] = "#include <header.h>";
(void)getcodeforcfg(settings0, *this, code, "", "test.c");
(void)getcodeforcfg(settings, *this, code, "", "test.c");
Comment on lines -2569 to +2578
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was using the wrong settings. Having it initialized in a single call lead to a compiler warning about the local object being unused.


ASSERT_EQUALS("", errout_str());
}

// test for existing system include - absolute path
void testMissingSystemInclude4() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.includePaths.emplace_back("inc");
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.includePaths.emplace_back ("inc");
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

ScopedFile header("header.h", "", Path::getCurrentPath());
Expand All @@ -2590,10 +2600,11 @@ class TestPreprocessor : public TestFixture {

// test for missing system include - absolute path
void testMissingSystemInclude5() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

const std::string header = Path::join(Path::getCurrentPath(), "header.h");
Expand All @@ -2606,10 +2617,12 @@ class TestPreprocessor : public TestFixture {

// test for missing local and system include
void testMissingIncludeMixed() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),

$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

ScopedFile header("header.h", "");
Expand All @@ -2627,11 +2640,12 @@ class TestPreprocessor : public TestFixture {
}

void testMissingIncludeCheckConfig() {
/*const*/ Settings settings;
settings.clearIncludeCache = true;
settings.checks.enable(Checks::missingInclude);
settings.includePaths.emplace_back("system");
settings.templateFormat = "simple"; // has no effect
const auto settings = dinit(Settings,
$.clearIncludeCache = true,
$.checks.enable (Checks::missingInclude),
$.includePaths.emplace_back ("system");
$.templateFormat = "simple" // has no effect
);
setTemplateFormat("simple");

ScopedFile header("header.h", "");
Expand Down
12 changes: 6 additions & 6 deletions test/testsuppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ class TestSuppressions : public TestFixture {
fileSettings.emplace_back("test.cpp", Standards::Language::CPP, strlen(code));
}

/*const*/ auto settings = dinit(Settings,
$.jobs = 2,
$.quiet = true,
$.inlineSuppressions = true);
settings.severity.enable(Severity::information);
settings.templateFormat = templateFormat;
const auto settings = dinit(Settings,
$.jobs = 2,
$.quiet = true,
$.inlineSuppressions = true,
$.severity.enable (Severity::information),
$.templateFormat = templateFormat);

Suppressions supprs;
if (!suppression.empty()) {
Expand Down
Loading