Ticket #6181: Normalize '>>' into '> >' when it's closing a C++11 template parameter list.
This commit is contained in:
parent
74417699db
commit
9c6a625f91
|
@ -2315,6 +2315,14 @@ void Tokenizer::simplifyTemplates()
|
|||
tok3->deleteNext(4);
|
||||
tok3->insertToken(MathLib::toString(sizeOfResult));
|
||||
}
|
||||
// Ticket #6181: normalize C++11 template parameter list closing syntax
|
||||
if (tok->str() == "<" && TemplateSimplifier::templateParameters(tok)) {
|
||||
Token *endTok = tok->findClosingBracket();
|
||||
if (endTok && endTok->str() == ">>") {
|
||||
endTok->str(">");
|
||||
endTok->insertToken(">");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TemplateSimplifier::simplifyTemplates(
|
||||
|
|
|
@ -1009,12 +1009,14 @@ private:
|
|||
TODO_ASSERT_EQUALS(wanted, current, tok(code));
|
||||
}
|
||||
{
|
||||
const char code[] = "template<class T, class T2 = A<T>> class B {};\n"
|
||||
"template<class B = A, typename C = C<B>> class C {};\n"
|
||||
"template<class B, typename C> class D { };\n";
|
||||
ASSERT_EQUALS("template < class T , class T2 > class B { } ; "
|
||||
"template < class B , typename C > class C { } ; "
|
||||
"template < class B , typename C > class D { } ;", tok(code));
|
||||
const char code[] = "class A { }; "
|
||||
"template<class T> class B { }; "
|
||||
"template<class T1, class T2 = B<T1>> class C { }; "
|
||||
"template<class T1 = A, typename T2 = B<A>> class D { };";
|
||||
ASSERT_EQUALS("class A { } ; "
|
||||
"template < class T > class B { } ; "
|
||||
"template < class T1 , class T2 > class C { } ; "
|
||||
"template < class T1 , typename T2 > class D { } ;", tok(code));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -828,7 +828,7 @@ private:
|
|||
"void z() {\n"
|
||||
" vector<int> VI;\n"
|
||||
"}\n";
|
||||
ASSERT_THROW(tokenizeAndStringify(code, true), InternalError);
|
||||
tokenizeAndStringify(code, true);
|
||||
}
|
||||
|
||||
void tokenize34() { // #6121
|
||||
|
@ -5185,10 +5185,10 @@ private:
|
|||
}
|
||||
|
||||
void cpp0xtemplate4() { // #6181, #6354, #6414
|
||||
ASSERT_THROW(tokenizeAndStringify("class A; "
|
||||
tokenizeAndStringify("class A; "
|
||||
"template <class T> class Disposer; "
|
||||
"template <typename T, class D = Disposer<T>> class Shim {}; "
|
||||
"class B : public Shim<A> {};"), InternalError);
|
||||
"class B : public Shim<A> {};");
|
||||
tokenizeAndStringify("template <class ELFT> class ELFObjectImage {}; "
|
||||
"ObjectImage *createObjectImage() { "
|
||||
" return new ELFObjectImage<ELFType<little>>(Obj); "
|
||||
|
|
Loading…
Reference in New Issue