This commit is contained in:
parent
9c56e7ea8d
commit
c2fc4973ad
|
@ -2208,7 +2208,7 @@ Function::Function(const Tokenizer *mTokenizer,
|
|||
else
|
||||
type = Function::eConstructor;
|
||||
|
||||
isExplicit(tokenDef->previous()->str() == "explicit");
|
||||
isExplicit(tokenDef->strAt(-1) == "explicit" || tokenDef->strAt(-2) == "explicit");
|
||||
}
|
||||
|
||||
const Token *tok1 = setFlags(tok, scope);
|
||||
|
|
|
@ -444,6 +444,19 @@ private:
|
|||
" A(int, int y=2) {}"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (style) Struct 'A' has a constructor with 1 argument that is not explicit.\n", errout.str());
|
||||
|
||||
checkExplicitConstructors("struct Foo {\n"
|
||||
" template <typename T>\n"
|
||||
" explicit constexpr Foo(T) {}\n"
|
||||
"};\n"
|
||||
"struct Bar {\n"
|
||||
" template <typename T>\n"
|
||||
" constexpr explicit Bar(T) {}\n"
|
||||
"};\n"
|
||||
"struct Baz {\n"
|
||||
" explicit constexpr Baz(int) {}\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
#define checkDuplInheritedMembers(code) checkDuplInheritedMembers_(code, __FILE__, __LINE__)
|
||||
|
|
Loading…
Reference in New Issue