Co-authored-by: Robert Reif <reif@FX6840>
This commit is contained in:
parent
c4190d1741
commit
7fc03c6030
|
@ -357,8 +357,10 @@ void TemplateSimplifier::checkComplicatedSyntaxErrorsInTemplates()
|
|||
;
|
||||
else if (level == 0 && Token::Match(tok2->previous(), "%type%")) {
|
||||
// @todo add better expression detection
|
||||
if (!Token::Match(tok2->next(), "*| %type%|%num% ;"))
|
||||
if (!(Token::Match(tok2->next(), "*| %type%|%num% ;") ||
|
||||
Token::Match(tok2->next(), "*| %type% . %type% ;"))) {
|
||||
inclevel = true;
|
||||
}
|
||||
} else if (tok2->next() && tok2->next()->isStandardType() && !Token::Match(tok2->tokAt(2), "(|{"))
|
||||
inclevel = true;
|
||||
else if (Token::simpleMatch(tok2, "< typename"))
|
||||
|
|
|
@ -207,6 +207,7 @@ private:
|
|||
TEST_CASE(template162);
|
||||
TEST_CASE(template163); // #9685 syntax error
|
||||
TEST_CASE(template164); // #9394
|
||||
TEST_CASE(template162); // #10032 syntax error
|
||||
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||
TEST_CASE(template_specialization_2); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
|
||||
|
@ -4161,6 +4162,22 @@ private:
|
|||
ASSERT_EQUALS(exp, tok(code));
|
||||
}
|
||||
|
||||
void template165() { // #10032 syntax error
|
||||
const char code[] = "struct MyStruct {\n"
|
||||
" template<class T>\n"
|
||||
" bool operator()(const T& l, const T& r) const {\n"
|
||||
" return l.first < r.first;\n"
|
||||
" }\n"
|
||||
"};";
|
||||
const char exp[] = "struct MyStruct { "
|
||||
"template < class T > "
|
||||
"bool operator() ( const T & l , const T & r ) const { "
|
||||
"return l . first < r . first ; "
|
||||
"} "
|
||||
"} ;";
|
||||
ASSERT_EQUALS(exp, tok(code));
|
||||
}
|
||||
|
||||
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||
const char code[] = "template <typename T> struct C {};\n"
|
||||
"template <typename T> struct S {a};\n"
|
||||
|
|
Loading…
Reference in New Issue