parent
eb6203cee3
commit
0e4efea530
|
@ -824,7 +824,7 @@ void TemplateSimplifier::getTemplateInstantiations()
|
||||||
Token *tok2 = Token::findsimplematch(tok->tokAt(2), ";");
|
Token *tok2 = Token::findsimplematch(tok->tokAt(2), ";");
|
||||||
if (tok2)
|
if (tok2)
|
||||||
tok = tok2;
|
tok = tok2;
|
||||||
} else if (Token::Match(tok->previous(), "(|{|}|;|=|>|<<|:|.|*|&|return|<|,|! %name% ::|<|(") ||
|
} else if (Token::Match(tok->previous(), "(|{|}|;|=|>|<<|:|.|*|&|return|<|,|!|[ %name% ::|<|(") ||
|
||||||
Token::Match(tok->previous(), "%type% %name% ::|<") ||
|
Token::Match(tok->previous(), "%type% %name% ::|<") ||
|
||||||
Token::Match(tok->tokAt(-2), "[,:] private|protected|public %name% ::|<")) {
|
Token::Match(tok->tokAt(-2), "[,:] private|protected|public %name% ::|<")) {
|
||||||
std::string scopeName = tok->scopeInfo()->name;
|
std::string scopeName = tok->scopeInfo()->name;
|
||||||
|
|
|
@ -9347,7 +9347,7 @@ void Tokenizer::findGarbageCode() const
|
||||||
prev = prev->previous();
|
prev = prev->previous();
|
||||||
if (Token::Match(prev, "%op%|%num%|%str%|%char%")) {
|
if (Token::Match(prev, "%op%|%num%|%str%|%char%")) {
|
||||||
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if") &&
|
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if") &&
|
||||||
!Token::simpleMatch(tok->tokAt(-2), "extern \"C\"") )
|
!Token::simpleMatch(tok->tokAt(-2), "extern \"C\""))
|
||||||
syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str()));
|
syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9448,7 +9448,7 @@ void Tokenizer::findGarbageCode() const
|
||||||
syntaxError(tok);
|
syntaxError(tok);
|
||||||
if (Token::Match(tok, ";|(|[ %comp%"))
|
if (Token::Match(tok, ";|(|[ %comp%"))
|
||||||
syntaxError(tok);
|
syntaxError(tok);
|
||||||
if (Token::Match(tok, "%cop%|= ]") && !(isCPP() && Token::Match(tok->previous(), "[|, &|= ]")))
|
if (Token::Match(tok, "%cop%|= ]") && !(isCPP() && Token::Match(tok->previous(), "[|,|%num% &|=|> ]")))
|
||||||
syntaxError(tok);
|
syntaxError(tok);
|
||||||
if (Token::Match(tok, "[+-] [;,)]}]") && !(isCPP() && Token::Match(tok->previous(), "operator [+-] ;")))
|
if (Token::Match(tok, "[+-] [;,)]}]") && !(isCPP() && Token::Match(tok->previous(), "operator [+-] ;")))
|
||||||
syntaxError(tok);
|
syntaxError(tok);
|
||||||
|
|
|
@ -192,6 +192,7 @@ private:
|
||||||
TEST_CASE(template152); // #9467
|
TEST_CASE(template152); // #9467
|
||||||
TEST_CASE(template153); // #9483
|
TEST_CASE(template153); // #9483
|
||||||
TEST_CASE(template154); // #9495
|
TEST_CASE(template154); // #9495
|
||||||
|
TEST_CASE(template155); // #9539
|
||||||
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
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_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)
|
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
|
||||||
|
@ -2799,12 +2800,6 @@ private:
|
||||||
ASSERT_EQUALS(exp, tok(code));
|
ASSERT_EQUALS(exp, tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
void template154() { // #9495
|
|
||||||
const char code[] = "template <typename S, enable_if_t<(is_compile_string<S>::value), int>> void i(S s);";
|
|
||||||
const char exp[] = "template < typename S , enable_if_t < ( is_compile_string < S > :: value ) , int > > void i ( S s ) ;";
|
|
||||||
ASSERT_EQUALS(exp, tok(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
void template116() { // #9178
|
void template116() { // #9178
|
||||||
{
|
{
|
||||||
const char code[] = "template <class, class a> auto b() -> decltype(a{}.template b<void(int, int)>);\n"
|
const char code[] = "template <class, class a> auto b() -> decltype(a{}.template b<void(int, int)>);\n"
|
||||||
|
@ -3666,6 +3661,33 @@ private:
|
||||||
ASSERT_EQUALS(exp, tok(code));
|
ASSERT_EQUALS(exp, tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void template154() { // #9495
|
||||||
|
const char code[] = "template <typename S, enable_if_t<(is_compile_string<S>::value), int>> void i(S s);";
|
||||||
|
const char exp[] = "template < typename S , enable_if_t < ( is_compile_string < S > :: value ) , int > > void i ( S s ) ;";
|
||||||
|
ASSERT_EQUALS(exp, tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
void template155() { // #9539
|
||||||
|
const char code[] = "template <int> int a = 0;\n"
|
||||||
|
"struct b {\n"
|
||||||
|
" void operator[](int);\n"
|
||||||
|
"};\n"
|
||||||
|
"void c() {\n"
|
||||||
|
" b d;\n"
|
||||||
|
" d[a<0>];\n"
|
||||||
|
"}";
|
||||||
|
const char exp[] = "int a<0> ; "
|
||||||
|
"a<0> = 0 ; "
|
||||||
|
"struct b { "
|
||||||
|
"void operator[] ( int ) ; "
|
||||||
|
"} ; "
|
||||||
|
"void c ( ) { "
|
||||||
|
"b d ; "
|
||||||
|
"d [ a<0> ] ; "
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS(exp, tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||||
const char code[] = "template <typename T> struct C {};\n"
|
const char code[] = "template <typename T> struct C {};\n"
|
||||||
"template <typename T> struct S {a};\n"
|
"template <typename T> struct S {a};\n"
|
||||||
|
|
Loading…
Reference in New Issue