Fixed #3855 (false positive: (error) Instance of 'locale' object destroyed immediately)
This commit is contained in:
parent
cc5e06b5d2
commit
4b6e1c6946
|
@ -3454,32 +3454,41 @@ void Tokenizer::removeMacrosInGlobalScope()
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "[;{}] %type% (") && CheckNullPointer::isUpper(tok->next()->str())) {
|
if (Token::Match(tok, "[;{}] %type%") && CheckNullPointer::isUpper(tok->next()->str())) {
|
||||||
unsigned int par = 0;
|
const Token *tok2 = tok->tokAt(2);
|
||||||
const Token *tok2;
|
if (tok2 && tok2->str() == "(") {
|
||||||
for (tok2 = tok; tok2; tok2 = tok2->next()) {
|
unsigned int par = 0;
|
||||||
if (tok2->str() == "(")
|
for (; tok2; tok2 = tok2->next()) {
|
||||||
++par;
|
if (tok2->str() == "(")
|
||||||
else if (tok2->str() == ")") {
|
++par;
|
||||||
if (par <= 1)
|
else if (tok2->str() == ")") {
|
||||||
break;
|
if (par <= 1)
|
||||||
--par;
|
break;
|
||||||
|
--par;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (tok2 && tok2->str() == ")")
|
||||||
|
tok2 = tok2->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove unknown macros before namespace|class|struct|union
|
// remove unknown macros before namespace|class|struct|union
|
||||||
if (Token::Match(tok2, ") namespace|class|struct|union")) {
|
if (Token::Match(tok2, "namespace|class|struct|union")) {
|
||||||
Token::eraseTokens(tok, tok2->next());
|
// is there a "{" for?
|
||||||
|
const Token *tok3 = tok2;
|
||||||
|
while (tok3 && !Token::Match(tok3,"[;{}()]"))
|
||||||
|
tok3 = tok3->next();
|
||||||
|
if (tok3 && tok3->str() == "{")
|
||||||
|
Token::eraseTokens(tok, tok2);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove unknown macros before foo::foo(
|
// remove unknown macros before foo::foo(
|
||||||
if (Token::Match(tok2, ") %type% :: %type%")) {
|
if (Token::Match(tok2, "%type% :: %type%")) {
|
||||||
const Token *tok3 = tok2->next();
|
const Token *tok3 = tok2;
|
||||||
while (Token::Match(tok3, "%type% :: %type% ::"))
|
while (Token::Match(tok3, "%type% :: %type% ::"))
|
||||||
tok3 = tok3->tokAt(2);
|
tok3 = tok3->tokAt(2);
|
||||||
if (Token::Match(tok3, "%type% :: %type% (") && tok3->str() == tok3->strAt(2))
|
if (Token::Match(tok3, "%type% :: %type% (") && tok3->str() == tok3->strAt(2))
|
||||||
Token::eraseTokens(tok, tok2->next());
|
Token::eraseTokens(tok, tok2);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6525,6 +6525,12 @@ private:
|
||||||
// #3750
|
// #3750
|
||||||
ASSERT_EQUALS("; foo :: foo ( ) { }",
|
ASSERT_EQUALS("; foo :: foo ( ) { }",
|
||||||
tokenizeAndStringify("; AB(foo*) foo::foo() { }"));
|
tokenizeAndStringify("; AB(foo*) foo::foo() { }"));
|
||||||
|
|
||||||
|
// #3855
|
||||||
|
ASSERT_EQUALS("; class foo { }",
|
||||||
|
tokenizeAndStringify("; AB class foo { }"));
|
||||||
|
ASSERT_EQUALS("; CONST struct ABC abc ;",
|
||||||
|
tokenizeAndStringify("; CONST struct ABC abc ;"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void multipleAssignment() {
|
void multipleAssignment() {
|
||||||
|
|
Loading…
Reference in New Issue