Tokenizer::setVarId: better handling of decltype()
This commit is contained in:
parent
18124fe248
commit
dcee189146
|
@ -2996,6 +2996,11 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
|
|||
if (tok2->isName()) {
|
||||
if (cpp && Token::Match(tok2, "namespace|public|private|protected"))
|
||||
return false;
|
||||
if (cpp && Token::simpleMatch(tok2, "decltype (")) {
|
||||
typeCount = 1;
|
||||
tok2 = tok2->linkAt(1)->next();
|
||||
continue;
|
||||
}
|
||||
if (Token::Match(tok2, "struct|union|enum") || (!c && Token::Match(tok2, "class|typename"))) {
|
||||
hasstruct = true;
|
||||
typeCount = 0;
|
||||
|
|
|
@ -194,6 +194,8 @@ private:
|
|||
TEST_CASE(usingNamespace3);
|
||||
|
||||
TEST_CASE(setVarIdStructMembers1);
|
||||
|
||||
TEST_CASE(decltype1);
|
||||
}
|
||||
|
||||
std::string tokenize(const char code[], bool simplify = false, const char filename[] = "test.cpp") {
|
||||
|
@ -3087,6 +3089,12 @@ private:
|
|||
"5: }\n";
|
||||
ASSERT_EQUALS(expected, tokenize(code));
|
||||
}
|
||||
|
||||
void decltype1() {
|
||||
const char code[] = "void foo(int x, decltype(A::b) *p);";
|
||||
const char expected[] = "1: void foo ( int x@1 , decltype ( A :: b ) * p@2 ) ;\n";
|
||||
ASSERT_EQUALS(expected, tokenize(code));
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestVarID)
|
||||
|
|
Loading…
Reference in New Issue