fix crash in checkclass from unknown template valueType (#3129)

This commit is contained in:
IOBYTE 2021-02-13 07:41:12 -05:00 committed by GitHub
parent 1eafed9e75
commit 75e439e56d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -74,7 +74,9 @@ static const char * getFunctionTypeName(Function::Type type)
static bool isVariableCopyNeeded(const Variable &var)
{
return var.isPointer() || (var.type() && var.type()->needInitialization == Type::NeedInitialization::True) || (var.valueType()->type >= ValueType::Type::CHAR);
return var.isPointer() ||
(var.type() && var.type()->needInitialization == Type::NeedInitialization::True) ||
(var.valueType() && var.valueType()->type >= ValueType::Type::CHAR);
}
//---------------------------------------------------------------------------

View File

@ -196,6 +196,8 @@ private:
TEST_CASE(uninitComparisonAssignment); // ticket #7429
TEST_CASE(uninitTemplate1); // ticket #7372
TEST_CASE(unknownTemplateType);
}
@ -3903,6 +3905,18 @@ private:
"A<B<T1, T2>>::A() : m_value(false) {}\n");
ASSERT_EQUALS("", errout.str());
}
void unknownTemplateType() {
check("template <typename T> class A {\n"
"private:\n"
" T m;\n"
"public:\n"
" A& operator=() { return *this; }\n"
"};\n"
"A<decltype(SOMETHING)> a;");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestConstructors)