ValueType: handle new nothrow
This commit is contained in:
parent
115ea08544
commit
e02b2c4483
|
@ -4861,10 +4861,13 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens, bool cpp, const Sett
|
|||
} else if (tok->enumerator()) {
|
||||
setValueType(tok, *tok->enumerator(), cpp, defsign, settings);
|
||||
} else if (cpp && tok->str() == "new") {
|
||||
if (Token::Match(tok, "new %type% ;|[")) {
|
||||
if (Token::Match(tok, "new %type% ;|[") ||
|
||||
Token::Match(tok, "new ( std| ::| nothrow ) %type% ;|[")) {
|
||||
ValueType vt;
|
||||
vt.pointer = 1;
|
||||
const Token * const typeTok = tok->next();
|
||||
const Token * typeTok = tok->next();
|
||||
if (typeTok->str() == "(")
|
||||
typeTok = typeTok->link()->next();
|
||||
vt.type = ValueType::typeFromString(typeTok->str(), typeTok->isLong());
|
||||
if (vt.type == ValueType::Type::UNKNOWN_TYPE)
|
||||
vt.fromLibraryType(typeTok->str(), settings);
|
||||
|
|
|
@ -4313,6 +4313,8 @@ private:
|
|||
ASSERT_EQUALS("signed int", typeOf("; auto x = 3;", "x"));
|
||||
ASSERT_EQUALS("signed int *", typeOf("; auto *p = (int *)0;", "p"));
|
||||
ASSERT_EQUALS("signed int *", typeOf("; auto data = new int[100];", "data"));
|
||||
ASSERT_EQUALS("signed int *", typeOf("; auto data = new (nothrow) int[100];", "data"));
|
||||
ASSERT_EQUALS("signed int *", typeOf("; auto data = new (std::nothrow) int[100];", "data"));
|
||||
ASSERT_EQUALS("const signed short", typeOf("short values[10]; void f() { for (const auto *x : values); }", "x"));
|
||||
ASSERT_EQUALS("signed int *", typeOf("MACRO(test) void test() { auto x = (int*)y; }", "x")); // #7931 (garbage?)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue