Fixed ValueType for auto variable
This commit is contained in:
parent
032020c40d
commit
226f0c7544
|
@ -4837,6 +4837,9 @@ void SymbolDatabase::setValueType(Token *tok, const Variable &var)
|
|||
valuetype.bits = var.nameToken()->bits();
|
||||
valuetype.pointer = var.dimensions().size();
|
||||
valuetype.typeScope = var.typeScope();
|
||||
if (var.valueType()) {
|
||||
valuetype.container = var.valueType()->container;
|
||||
}
|
||||
if (parsedecl(var.typeStartToken(), &valuetype, mDefaultSignedness, mSettings)) {
|
||||
if (tok->str() == "." && tok->astOperand1()) {
|
||||
const ValueType * const vt = tok->astOperand1()->valueType();
|
||||
|
|
|
@ -381,6 +381,7 @@ private:
|
|||
TEST_CASE(auto9); // #8044 (segmentation fault)
|
||||
TEST_CASE(auto10); // #8020
|
||||
TEST_CASE(auto11); // #8964 - const auto startX = x;
|
||||
TEST_CASE(auto12); // #8993 - const std::string &x; auto y = x; if (y.empty()) ..
|
||||
|
||||
TEST_CASE(unionWithConstructor);
|
||||
}
|
||||
|
@ -6833,6 +6834,22 @@ private:
|
|||
ASSERT(v2tok && v2tok->variable() && !v2tok->variable()->isConst());
|
||||
}
|
||||
|
||||
void auto12() {
|
||||
GET_SYMBOL_DB("void f(const std::string &x) {\n"
|
||||
" auto y = x;\n"
|
||||
" if (y.empty()) {}\n"
|
||||
"}");
|
||||
(void)db;
|
||||
|
||||
const Token *tok;
|
||||
|
||||
tok = Token::findsimplematch(tokenizer.tokens(), "y =");
|
||||
ASSERT(tok && tok->valueType() && tok->valueType()->container);
|
||||
|
||||
tok = Token::findsimplematch(tokenizer.tokens(), "y .");
|
||||
ASSERT(tok && tok->valueType() && tok->valueType()->container);
|
||||
}
|
||||
|
||||
void unionWithConstructor() {
|
||||
GET_SYMBOL_DB("union Fred {\n"
|
||||
" Fred(int x) : i(x) { }\n"
|
||||
|
|
Loading…
Reference in New Issue