Fixed #3648 (Internal error: Token::Match called with varid 0)

This commit is contained in:
Daniel Marjamäki 2012-03-20 19:05:24 +01:00
parent d6c8de104c
commit a2351ba44f
2 changed files with 10 additions and 1 deletions

View File

@ -2867,7 +2867,7 @@ void Tokenizer::setVarId()
if (tok->str() == "unsigned")
tok = tok->next();
if (Token::Match(tok, "using namespace %type% ;")) {
if (Token::Match(tok, "using namespace| %type% ;")) {
tok = tok->next();
continue;
}

View File

@ -224,6 +224,7 @@ private:
TEST_CASE(varid_operator);
TEST_CASE(varid_throw);
TEST_CASE(varid_unknown_macro); // #2638 - unknown macro is not type
TEST_CASE(varid_using); // ticket #3648
TEST_CASE(varidclass1);
TEST_CASE(varidclass2);
@ -3635,6 +3636,14 @@ private:
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void varid_using() {
// #3648
const char code[] = "using std::size_t;";
const char expected[] = "\n\n##file 0\n"
"1: using long ;\n";
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void varidclass1() {
const std::string actual = tokenizeDebugListing(
"class Fred\n"