From 31148fdfed6cf51a6d4912684a6eb4cc1aa65b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 1 May 2018 15:50:03 +0200 Subject: [PATCH] Fixed #8523 (Clarify warning: noConstructor) --- lib/checkclass.cpp | 2 +- test/testconstructors.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index bb02c9dd3..5b4854d38 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -872,7 +872,7 @@ void CheckClass::noConstructorError(const Token *tok, const std::string &classna // For performance reasons the constructor might be intentionally missing. Therefore this is not a "warning" reportError(tok, Severity::style, "noConstructor", "$symbol:" + classname + "\n" + - "The " + std::string(isStruct ? "struct" : "class") + " '$symbol' does not have a constructor.\n" + "The " + std::string(isStruct ? "struct" : "class") + " '$symbol' does not have a constructor although it has private member variables.\n" "The " + std::string(isStruct ? "struct" : "class") + " '$symbol' does not have a constructor " "although it has private member variables. Member variables of builtin types are left " "uninitialized when the class is instantiated. That may cause bugs or undefined behavior.", CWE398, false); diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 6f6afd0bd..7629b6209 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -208,14 +208,14 @@ private: "private:\n" " int i;\n" "};"); - ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor although it has private member variables.\n", errout.str()); check("struct Fred\n" "{\n" "private:\n" " int i;\n" "};"); - ASSERT_EQUALS("[test.cpp:1]: (style) The struct 'Fred' does not have a constructor.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (style) The struct 'Fred' does not have a constructor although it has private member variables.\n", errout.str()); } @@ -369,8 +369,8 @@ private: check("struct Fred { int x; };\n" "class Barney { Fred fred; };\n" "class Wilma { struct Betty { int x; } betty; };"); - ASSERT_EQUALS("[test.cpp:2]: (style) The class 'Barney' does not have a constructor.\n" - "[test.cpp:3]: (style) The class 'Wilma' does not have a constructor.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) The class 'Barney' does not have a constructor although it has private member variables.\n" + "[test.cpp:3]: (style) The class 'Wilma' does not have a constructor although it has private member variables.\n", errout.str()); } void simple9() { // ticket #4574 @@ -470,7 +470,7 @@ private: "{\n" " int i;\n" "};"); - ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor although it has private member variables.\n", errout.str()); } void noConstructor2() {