Fixed #4010 (error (cppcheckError): Internal error. Token::Match called with varid 0)
This commit is contained in:
parent
25fd841b5d
commit
445fd4e6aa
|
@ -206,7 +206,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
|
|||
return 0;
|
||||
|
||||
// * / const
|
||||
while (Token::Match(tok, "*|const"))
|
||||
while (Token::Match(tok, "*|&|const"))
|
||||
tok = tok->next();
|
||||
|
||||
// Function pointer..
|
||||
|
|
|
@ -124,6 +124,7 @@ private:
|
|||
TEST_CASE(template28);
|
||||
TEST_CASE(template29); // #3449 - don't crash for garbage code
|
||||
TEST_CASE(template30); // #3529 - template < template < ..
|
||||
TEST_CASE(template31); // #4010 - reference type
|
||||
TEST_CASE(template_unhandled);
|
||||
TEST_CASE(template_default_parameter);
|
||||
TEST_CASE(template_default_type);
|
||||
|
@ -2144,6 +2145,12 @@ private:
|
|||
ASSERT_EQUALS("template < template < class > class A , class B > void f ( ) { }", tok(code));
|
||||
}
|
||||
|
||||
void template31() {
|
||||
// #4010 - template reference type
|
||||
const char code[] = "template<class T> struct A{}; A<int&> a;";
|
||||
ASSERT_EQUALS("A<int&> a ; struct A<int&> { }", tok(code));
|
||||
}
|
||||
|
||||
void template_unhandled() {
|
||||
// An unhandled template usage should be simplified..
|
||||
ASSERT_EQUALS("x<int> ( ) ;", tok("x<int>();"));
|
||||
|
|
Loading…
Reference in New Issue