Fixed #6547 (Regression - unknown macro causes analysis error)
This commit is contained in:
parent
3add466035
commit
449b88aa0c
|
@ -37,7 +37,7 @@
|
|||
//---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* is token pointing at function head?
|
||||
* is token pointing at function head?
|
||||
* @param tok A '(' or ')' token in a possible function head
|
||||
* @param endsWith string after function head
|
||||
* @return true if syntax seems to be a function head
|
||||
|
@ -57,7 +57,9 @@ static bool isFunctionHead(const Token *tok, const std::string &endsWith)
|
|||
while (tok->isName())
|
||||
tok = tok->next();
|
||||
tok = tok->link()->next();
|
||||
return endsWith.find(tok->str()) != std::string::npos;
|
||||
while (tok && tok->isName())
|
||||
tok = tok->next();
|
||||
return tok && endsWith.find(tok->str()) != std::string::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -4077,8 +4079,14 @@ void Tokenizer::removeMacrosInGlobalScope()
|
|||
}
|
||||
}
|
||||
|
||||
if (tok->str() == "{")
|
||||
tok = tok->link();
|
||||
// Skip executable scopes
|
||||
if (tok->str() == "{") {
|
||||
const Token *prev = tok->previous();
|
||||
while (prev && prev->isName())
|
||||
prev = prev->previous();
|
||||
if (prev && prev->str() == ")")
|
||||
tok = tok->link();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5826,7 +5826,7 @@ private:
|
|||
static const char expected14[] = "class C {\n"
|
||||
"void search ( ) { }\n"
|
||||
"void search ( ) const { }\n"
|
||||
"void search ( ) THROW_MACRO { }\n"
|
||||
"void search ( ) { }\n"
|
||||
"} ;";
|
||||
ASSERT_EQUALS(expected14, tokenizeAndStringify(code14, false));
|
||||
}
|
||||
|
|
|
@ -985,6 +985,13 @@ private:
|
|||
"void fred ( int x@1 ) const throw ( EXCEPT ) { } "
|
||||
"void wilma ( ) { x ++ ; }\n";
|
||||
ASSERT_EQUALS(expected2, tokenize(code2, false, "test.cpp"));
|
||||
|
||||
const char code3[] = "void fred(int x) throw() ABCD {}"
|
||||
"void wilma() { x++; }";
|
||||
const char expected3[] = "\n\n##file 0\n1: "
|
||||
"void fred ( int x@1 ) throw ( ) { } "
|
||||
"void wilma ( ) { x ++ ; }\n";
|
||||
ASSERT_EQUALS(expected3, tokenize(code3, false, "test.cpp"));
|
||||
}
|
||||
|
||||
void varid_cpp_keywords_in_c_code() {
|
||||
|
|
Loading…
Reference in New Issue