Fix syntax error in issue 9155 (#1885)
This commit is contained in:
parent
75720528b0
commit
b466415bb4
|
@ -523,12 +523,15 @@ bool TemplateSimplifier::removeTemplate(Token *tok)
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (tok2->str() == "{") {
|
else if (tok2->str() == "{") {
|
||||||
tok2 = tok2->link()->next();
|
tok2 = tok2->link();
|
||||||
if (tok2 && tok2->str() == ";" && tok2->next())
|
if (indentlevel < 2) {
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
eraseTokens(tok, tok2);
|
if (tok2 && tok2->str() == ";" && tok2->next())
|
||||||
deleteToken(tok);
|
tok2 = tok2->next();
|
||||||
return true;
|
eraseTokens(tok, tok2);
|
||||||
|
deleteToken(tok);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else if (tok2->str() == "}") { // garbage code! (#3449)
|
} else if (tok2->str() == "}") { // garbage code! (#3449)
|
||||||
eraseTokens(tok,tok2);
|
eraseTokens(tok,tok2);
|
||||||
deleteToken(tok);
|
deleteToken(tok);
|
||||||
|
@ -1971,7 +1974,7 @@ void TemplateSimplifier::expandTemplate(
|
||||||
mTokenList.addtoken(tokSemicolon, tokSemicolon->linenr(), tokSemicolon->fileIndex());
|
mTokenList.addtoken(tokSemicolon, tokSemicolon->linenr(), tokSemicolon->fileIndex());
|
||||||
}
|
}
|
||||||
brackets.pop();
|
brackets.pop();
|
||||||
if (brackets.empty()) {
|
if (brackets.empty() && !Token::Match(tok3, "} >|,|%cop%")) {
|
||||||
inTemplateDefinition = false;
|
inTemplateDefinition = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2684,17 +2684,30 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void template114() { // #9155
|
void template114() { // #9155
|
||||||
const char code[] = "template <typename a, a> struct b {};\n"
|
{
|
||||||
"template <typename> struct c;\n"
|
const char code[] = "template <typename a, a> struct b {};\n"
|
||||||
"template <typename> struct d : b<bool, std::is_polymorphic<int>{}> {};\n"
|
"template <typename> struct c;\n"
|
||||||
"template <bool> struct e;\n"
|
"template <typename> struct d : b<bool, std::is_polymorphic<int>{}> {};\n"
|
||||||
"template <typename a> using f = typename e<c<d<a>>::g>::h;";
|
"template <bool> struct e;\n"
|
||||||
const char exp[] = "template < typename a , a > struct b { } ; "
|
"template <typename a> using f = typename e<c<d<a>>::g>::h;";
|
||||||
"template < typename > struct c ; "
|
const char exp[] = "template < typename a , a > struct b { } ; "
|
||||||
"template < typename > struct d : b < bool , std :: is_polymorphic < int > { } > { } ; "
|
"template < typename > struct c ; "
|
||||||
"template < bool > struct e ; "
|
"template < typename > struct d : b < bool , std :: is_polymorphic < int > { } > { } ; "
|
||||||
"template < typename a > using f = typename e < c < d < a > > :: g > :: h ;";
|
"template < bool > struct e ; "
|
||||||
ASSERT_EQUALS(exp, tok(code));
|
"template < typename a > using f = typename e < c < d < a > > :: g > :: h ;";
|
||||||
|
ASSERT_EQUALS(exp, tok(code));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const char code[] = "template <typename a, a> struct b;\n"
|
||||||
|
"template <bool, typename> struct c;\n"
|
||||||
|
"template <typename a> struct d : b<bool, std::is_empty<a>{}> {};\n"
|
||||||
|
"template <typename a> using e = typename c<std::is_final<a>{}, d<a>>::f;\n";
|
||||||
|
const char exp[] = "template < typename a , a > struct b ; "
|
||||||
|
"template < bool , typename > struct c ; "
|
||||||
|
"struct d<a> ; "
|
||||||
|
"template < typename a > using e = typename c < std :: is_final < a > { } , d<a> > :: f ; struct d<a> : b < bool , std :: is_empty < a > { } > { } ;";
|
||||||
|
ASSERT_EQUALS(exp, tok(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void template115() { // #9153
|
void template115() { // #9153
|
||||||
|
|
Loading…
Reference in New Issue