Make code less strict that looks for garbage template code. Before a template there might be unknown macros.
This commit is contained in:
parent
7d2450e445
commit
fa42a08a71
|
@ -8369,28 +8369,12 @@ const Token * Tokenizer::findGarbageCode() const
|
|||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (!Token::simpleMatch(tok, "template <"))
|
||||
continue;
|
||||
if (tok->previous() && !Token::Match(tok->previous(), "[:;{}]"))
|
||||
if (tok->previous() && !Token::Match(tok->previous(), "[:;{})]"))
|
||||
return tok;
|
||||
const Token *tok1 = tok;
|
||||
tok = tok->tokAt(2);
|
||||
while (Token::Match(tok,"%name%|*|,|.|(")) {
|
||||
if (tok->str() == "(")
|
||||
tok = tok->link();
|
||||
tok = tok->next();
|
||||
}
|
||||
if (tok && tok->str() == "=") {
|
||||
while (tok && !Token::Match(tok, "[;{}]") && !Token::Match(tok, ">|>> %name%")) {
|
||||
if (tok->str() == "(")
|
||||
tok = tok->link();
|
||||
tok = tok->next();
|
||||
}
|
||||
}
|
||||
const Token * const tok1 = tok;
|
||||
tok = tok->next()->findClosingBracket();
|
||||
if (!tok)
|
||||
return tok1;
|
||||
if (Token::simpleMatch(tok->previous(), "template <"))
|
||||
continue;
|
||||
if (!Token::Match(tok, ">|>>"))
|
||||
return tok1;
|
||||
if (!Token::Match(tok, ">|>> %name%"))
|
||||
return tok->next() ? tok->next() : tok1;
|
||||
}
|
||||
|
|
|
@ -1008,13 +1008,13 @@ private:
|
|||
void garbageCode134() {
|
||||
// Ticket #5605, #5759, #5762, #5774, #5823, #6059
|
||||
ASSERT_THROW(checkCode("foo() template<typename T1 = T2 = typename = unused, T5 = = unused> struct tuple Args> tuple<Args...> { } main() { foo<int,int,int,int,int,int>(); }"), InternalError);
|
||||
ASSERT_THROW(checkCode("( ) template < T1 = typename = unused> struct Args { } main ( ) { foo < int > ( ) ; }"), InternalError);
|
||||
ASSERT_THROW(checkCode("() template < T = typename = x > struct a {} { f <int> () }"), InternalError);
|
||||
checkCode("( ) template < T1 = typename = unused> struct Args { } main ( ) { foo < int > ( ) ; }");
|
||||
checkCode("() template < T = typename = x > struct a {} { f <int> () }");
|
||||
checkCode("template < T = typename = > struct a { f <int> }");
|
||||
ASSERT_THROW(checkCode("struct S { int i, j; }; "
|
||||
"template<int S::*p, typename U> struct X {}; "
|
||||
"X<&S::i, int> x = X<&S::i, int>(); "
|
||||
"X<&S::j, int> y = X<&S::j, int>(); "), InternalError);
|
||||
checkCode("struct S { int i, j; }; "
|
||||
"template<int S::*p, typename U> struct X {}; "
|
||||
"X<&S::i, int> x = X<&S::i, int>(); "
|
||||
"X<&S::j, int> y = X<&S::j, int>(); ");
|
||||
checkCode("template <typename T> struct A {}; "
|
||||
"template <> struct A<void> {}; "
|
||||
"void foo(const void* f = 0) {}");
|
||||
|
|
Loading…
Reference in New Issue