From a2351ba44f3cdb9c8da2f4990be1e533d03b33cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 20 Mar 2012 19:05:24 +0100 Subject: [PATCH] Fixed #3648 (Internal error: Token::Match called with varid 0) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 4c44d07f7..bbf668717 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ef70f6a08..f616920e2 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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"