From 0c0fe4605a709ede3b98da1dd37944495666bf3d Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sat, 11 Feb 2017 17:55:51 +0100 Subject: [PATCH] Ticket #7465: Added test case highlighting the issue has been fixed since it's been reported. --- test/testclass.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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[]) {