Fixed #3152 (Tokenizer: template constructor is removed)
This commit is contained in:
parent
a09011630d
commit
acaa9c456f
|
@ -2624,6 +2624,13 @@ static void removeTemplates(Token *tok)
|
|||
tok->str(";");
|
||||
break;
|
||||
}
|
||||
// don't remove constructor
|
||||
if (tok2->str() == "explicit")
|
||||
{
|
||||
Token::eraseTokens(tok, tok2);
|
||||
tok->str(";");
|
||||
break;
|
||||
}
|
||||
if (tok2->str() == "(") {
|
||||
tok2 = tok2->link();
|
||||
if (!tok2)
|
||||
|
|
|
@ -120,6 +120,7 @@ private:
|
|||
TEST_CASE(template_default_parameter);
|
||||
TEST_CASE(template_default_type);
|
||||
TEST_CASE(template_typename);
|
||||
TEST_CASE(template_constructor); // #3152 - template constructor is removed
|
||||
|
||||
TEST_CASE(namespaces);
|
||||
|
||||
|
@ -2255,6 +2256,15 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void template_constructor() {
|
||||
// #3152 - if template constructor is removed then there might be
|
||||
// "no constructor" false positives
|
||||
const char code[] = "class Fred {\n"
|
||||
" template<class T> explicit Fred(T t) { }\n"
|
||||
"}";
|
||||
ASSERT_EQUALS("class Fred { ; explicit Fred ( T t ) { } }", tok(code));
|
||||
}
|
||||
|
||||
void namespaces() {
|
||||
{
|
||||
const char code[] = "using namespace std; namespace a{ namespace b{ void f(){} } }";
|
||||
|
|
Loading…
Reference in New Issue