Fix #11163 Hang on smart pointer with auto type deduction (#4250)

* Fix #11163 Hang on smart pointer with auto type deduction

* Format

* Format
This commit is contained in:
chrchr-github 2022-07-08 12:37:53 +02:00 committed by GitHub
parent a65f6952dc
commit bd92e7411c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -6508,7 +6508,7 @@ static const Token* parsedecl(const Token* type,
} else if (const Library::SmartPointer* smartPointer = settings->library.detectSmartPointer(type)) {
const Token* argTok = Token::findsimplematch(type, "<");
if (!argTok)
continue;
break;
valuetype->smartPointer = smartPointer;
valuetype->smartPointerTypeToken = argTok->next();
valuetype->smartPointerType = argTok->next()->type();

View File

@ -490,6 +490,7 @@ private:
TEST_CASE(auto14);
TEST_CASE(auto15); // C++17 auto deduction from braced-init-list
TEST_CASE(auto16);
TEST_CASE(auto17); // #11163
TEST_CASE(unionWithConstructor);
@ -8601,6 +8602,18 @@ private:
ASSERT_EQUALS(ValueType::Type::RECORD, i->valueType()->type);
}
void auto17() { // #11163 don't hang
GET_SYMBOL_DB("void f() {\n"
" std::shared_ptr<int> s1;\n"
" auto s2 = std::shared_ptr(s1);\n"
"}\n"
"void g() {\n"
" std::shared_ptr<int> s;\n"
" auto w = std::weak_ptr(s);\n"
"}\n");
ASSERT_EQUALS(5, db->variableList().size());
}
void unionWithConstructor() {
GET_SYMBOL_DB("union Fred {\n"
" Fred(int x) : i(x) { }\n"