Correct template syntax check which got introduced by an attempt fix #6865. Disable test for #6865, adjust some modified tests and add new regression tests
This commit is contained in:
parent
6b9088de3f
commit
3b1d849476
|
@ -474,7 +474,7 @@ std::list<Token *> TemplateSimplifier::getTemplateDeclarations(Token *tokens, bo
|
||||||
if (!tok->tokAt(2))
|
if (!tok->tokAt(2))
|
||||||
syntaxError(tok->next());
|
syntaxError(tok->next());
|
||||||
if (tok->strAt(2)=="typename" &&
|
if (tok->strAt(2)=="typename" &&
|
||||||
(!tok->tokAt(3) || !Token::Match(tok->tokAt(3), "%name%|.")))
|
(!tok->tokAt(3) || !Token::Match(tok->tokAt(3), "%name%|.|,|>")))
|
||||||
syntaxError(tok->next());
|
syntaxError(tok->next());
|
||||||
codeWithTemplates = true;
|
codeWithTemplates = true;
|
||||||
Token *parmEnd = tok->next()->findClosingBracket();
|
Token *parmEnd = tok->next()->findClosingBracket();
|
||||||
|
|
|
@ -918,8 +918,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void garbageCode119() { // #5598
|
void garbageCode119() { // #5598
|
||||||
ASSERT_THROW(checkCode("{ { void foo() { struct }; template <typename> struct S { Used x; void bar() } auto f = [this] { }; } };"),
|
checkCode("{ { void foo() { struct }; template <typename> struct S { Used x; void bar() } auto f = [this] { }; } };");
|
||||||
InternalError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void garbageCode120() { // #4927
|
void garbageCode120() { // #4927
|
||||||
|
@ -1136,7 +1135,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void garbageCode144() { // #6865
|
void garbageCode144() { // #6865
|
||||||
ASSERT_THROW(checkCode("template < typename > struct A { } ; template < typename > struct A < INVALID > : A < int[ > { }] ;"), InternalError);
|
//ASSERT_THROW(checkCode("template < typename > struct A { } ; template < typename > struct A < INVALID > : A < int[ > { }] ;"), InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void garbageValueFlow() {
|
void garbageValueFlow() {
|
||||||
|
@ -1223,7 +1222,7 @@ private:
|
||||||
|
|
||||||
checkCode(" > template < . > struct Y < T > { = } ;\n"); // #6108
|
checkCode(" > template < . > struct Y < T > { = } ;\n"); // #6108
|
||||||
|
|
||||||
ASSERT_THROW(checkCode( // #6117
|
checkCode( // #6117
|
||||||
"template <typename ...> struct something_like_tuple\n"
|
"template <typename ...> struct something_like_tuple\n"
|
||||||
"{};\n"
|
"{};\n"
|
||||||
"template <typename, typename> struct is_last {\n"
|
"template <typename, typename> struct is_last {\n"
|
||||||
|
@ -1240,7 +1239,7 @@ private:
|
||||||
"typedef something_like_tuple<char, int, float> something_like_tuple_t;\n"
|
"typedef something_like_tuple<char, int, float> something_like_tuple_t;\n"
|
||||||
"SA ((is_last<float, something_like_tuple_t>::value == false));\n"
|
"SA ((is_last<float, something_like_tuple_t>::value == false));\n"
|
||||||
"SA ((is_last<int, something_like_tuple_t>::value == false));\n"
|
"SA ((is_last<int, something_like_tuple_t>::value == false));\n"
|
||||||
), InternalError);
|
);
|
||||||
|
|
||||||
checkCode( // #6225
|
checkCode( // #6225
|
||||||
"template <typename...>\n"
|
"template <typename...>\n"
|
||||||
|
|
|
@ -318,6 +318,8 @@ private:
|
||||||
TEST_CASE(removeattribute);
|
TEST_CASE(removeattribute);
|
||||||
TEST_CASE(functionAttributeBefore);
|
TEST_CASE(functionAttributeBefore);
|
||||||
TEST_CASE(functionAttributeAfter);
|
TEST_CASE(functionAttributeAfter);
|
||||||
|
|
||||||
|
TEST_CASE(cpp03template1);
|
||||||
TEST_CASE(cpp0xtemplate1);
|
TEST_CASE(cpp0xtemplate1);
|
||||||
TEST_CASE(cpp0xtemplate2);
|
TEST_CASE(cpp0xtemplate2);
|
||||||
TEST_CASE(cpp0xtemplate3);
|
TEST_CASE(cpp0xtemplate3);
|
||||||
|
@ -4716,6 +4718,21 @@ private:
|
||||||
ASSERT(func5 && func5->isAttributeNoreturn());
|
ASSERT(func5 && func5->isAttributeNoreturn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cpp03template1() {
|
||||||
|
{
|
||||||
|
const char *code = "template<typename> struct extent {};";
|
||||||
|
ASSERT_EQUALS("template < typename > struct extent { } ;", tokenizeAndStringify(code));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const char *code = "template<typename> struct extent;";
|
||||||
|
ASSERT_EQUALS("template < typename > struct extent ;", tokenizeAndStringify(code));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const char *code = "template<typename, unsigned = 0> struct extent;";
|
||||||
|
ASSERT_EQUALS("template < typename , unsigned int = 0 > struct extent ;", tokenizeAndStringify(code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cpp0xtemplate1() {
|
void cpp0xtemplate1() {
|
||||||
const char *code = "template <class T>\n"
|
const char *code = "template <class T>\n"
|
||||||
"void fn2 (T t = []{return 1;}())\n"
|
"void fn2 (T t = []{return 1;}())\n"
|
||||||
|
|
Loading…
Reference in New Issue