Fixed #6548 (Tokenizer: Wrong varid set after function which is throw())
This commit is contained in:
parent
cd4811061e
commit
acbf48c7fa
|
@ -2779,7 +2779,7 @@ void CheckMemoryLeakNoVar::checkForUnsafeArgAlloc(const Scope *scope)
|
||||||
// Scan through the arguments to the function call
|
// Scan through the arguments to the function call
|
||||||
for (const Token *tok2 = tok->tokAt(2); tok2 && tok2 != endParamToken; tok2 = tok2->nextArgument()) {
|
for (const Token *tok2 = tok->tokAt(2); tok2 && tok2 != endParamToken; tok2 = tok2->nextArgument()) {
|
||||||
const Function *pFunc = tok2->function();
|
const Function *pFunc = tok2->function();
|
||||||
const bool isNothrow = pFunc && pFunc->isAttributeNothrow();
|
const bool isNothrow = pFunc && (pFunc->isAttributeNothrow() || pFunc->isThrow());
|
||||||
|
|
||||||
if (Token::Match(tok2, "shared_ptr|unique_ptr < %name% > ( new %name%")) {
|
if (Token::Match(tok2, "shared_ptr|unique_ptr < %name% > ( new %name%")) {
|
||||||
pointerType = tok2->str();
|
pointerType = tok2->str();
|
||||||
|
|
|
@ -2562,7 +2562,11 @@ void Tokenizer::setVarId()
|
||||||
// scope info to handle shadow variables..
|
// scope info to handle shadow variables..
|
||||||
bool newScope = false;
|
bool newScope = false;
|
||||||
if (!initListEndToken && tok->str() == "(") {
|
if (!initListEndToken && tok->str() == "(") {
|
||||||
if (Token::simpleMatch(tok->link(), ") {") || Token::Match(tok->link(), ") %type% {"))
|
if (Token::simpleMatch(tok->tokAt(-2), ") throw ( ) {")) {
|
||||||
|
tok = tok->next();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Token::Match(tok->link(), ") %name%| {") || Token::simpleMatch(tok->link(), ") throw ( ) {"))
|
||||||
newScope = true;
|
newScope = true;
|
||||||
else {
|
else {
|
||||||
initListEndToken = findInitListEndToken(tok->link());
|
initListEndToken = findInitListEndToken(tok->link());
|
||||||
|
|
|
@ -88,6 +88,7 @@ private:
|
||||||
TEST_CASE(varid53); // #4172 - Template instantiation: T<&functionName> list[4];
|
TEST_CASE(varid53); // #4172 - Template instantiation: T<&functionName> list[4];
|
||||||
TEST_CASE(varid54); // hang
|
TEST_CASE(varid54); // hang
|
||||||
TEST_CASE(varid55); // #5868: Function::addArgument with varid 0 for argument named the same as a typedef
|
TEST_CASE(varid55); // #5868: Function::addArgument with varid 0 for argument named the same as a typedef
|
||||||
|
TEST_CASE(varid56); // function with a throw()
|
||||||
TEST_CASE(varid_cpp_keywords_in_c_code);
|
TEST_CASE(varid_cpp_keywords_in_c_code);
|
||||||
TEST_CASE(varid_cpp_keywords_in_c_code2); // #5373: varid=0 for argument called "delete"
|
TEST_CASE(varid_cpp_keywords_in_c_code2); // #5373: varid=0 for argument called "delete"
|
||||||
TEST_CASE(varidFunctionCall1);
|
TEST_CASE(varidFunctionCall1);
|
||||||
|
@ -970,6 +971,15 @@ private:
|
||||||
ASSERT_EQUALS(expected, tokenize(code, false, "test.cpp"));
|
ASSERT_EQUALS(expected, tokenize(code, false, "test.cpp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void varid56() { // Ticket #6548 - function with a throw()
|
||||||
|
const char code[] = "void fred(int x) throw() {}"
|
||||||
|
"void wilma() { x++; }";
|
||||||
|
const char expected[] = "\n\n##file 0\n1: "
|
||||||
|
"void fred ( int x@1 ) throw ( ) { } "
|
||||||
|
"void wilma ( ) { x ++ ; }\n";
|
||||||
|
ASSERT_EQUALS(expected, tokenize(code, false, "test.cpp"));
|
||||||
|
}
|
||||||
|
|
||||||
void varid_cpp_keywords_in_c_code() {
|
void varid_cpp_keywords_in_c_code() {
|
||||||
const char code[] = "void f() {\n"
|
const char code[] = "void f() {\n"
|
||||||
" delete d;\n"
|
" delete d;\n"
|
||||||
|
|
Loading…
Reference in New Issue