diff --git a/test/testclass.cpp b/test/testclass.cpp index be786e327..3e1539cae 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -258,6 +258,30 @@ private: " virtual int i() = 0;\n" "};"); ASSERT_EQUALS("", errout.str()); + + // #7465: Error properly reported in templates + checkExplicitConstructors("template struct Test {\n" + " Test(int) : fData(0) {}\n" + " T fData;\n" + "};\n" + "int main() {\n" + " Test test;\n" + " return 0;\n" + "}"); + ASSERT_EQUALS("[test.cpp:2]: (style) Struct 'Test < int >' has a constructor with 1 argument that is not explicit.\n", errout.str()); + + // #7465: No error for copy or move constructors + checkExplicitConstructors("template struct Test {\n" + " Test() : fData(0) {}\n" + " Test (const Test& aOther) : fData(aOther.fData) {}\n" + " Test (Test&& aOther) : fData(std::move(aOther.fData)) {}\n" + " T fData;\n" + "};\n" + "int main() {\n" + " Test test;\n" + " return 0;\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void checkDuplInheritedMembers(const char code[]) {