Merge pull request #871 from simartin/ticket_7465

Ticket #7465: Added test case highlighting the issue has been fixed
This commit is contained in:
amai2012 2017-02-11 21:49:44 +01:00 committed by GitHub
commit f1bf5cc4e2
1 changed files with 24 additions and 0 deletions

View File

@ -258,6 +258,30 @@ private:
" virtual int i() = 0;\n"
"};");
ASSERT_EQUALS("", errout.str());
// #7465: Error properly reported in templates
checkExplicitConstructors("template <class T> struct Test {\n"
" Test(int) : fData(0) {}\n"
" T fData;\n"
"};\n"
"int main() {\n"
" Test <int> 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 <class T> struct Test {\n"
" Test() : fData(0) {}\n"
" Test (const Test<T>& aOther) : fData(aOther.fData) {}\n"
" Test (Test<T>&& aOther) : fData(std::move(aOther.fData)) {}\n"
" T fData;\n"
"};\n"
"int main() {\n"
" Test <int> test;\n"
" return 0;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void checkDuplInheritedMembers(const char code[]) {