Skip to content

Commit

Permalink
fix crash in checkclass from unknown template valueType (#3129)
Browse files Browse the repository at this point in the history
  • Loading branch information
IOBYTE authored Feb 13, 2021
1 parent 1eafed9 commit 75e439e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

//---------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/testconstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ class TestConstructors : public TestFixture {
TEST_CASE(uninitComparisonAssignment); // ticket #7429

TEST_CASE(uninitTemplate1); // ticket #7372

TEST_CASE(unknownTemplateType);
}


Expand Down Expand Up @@ -3903,6 +3905,18 @@ class TestConstructors : public TestFixture {
"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)

0 comments on commit 75e439e

Please sign in to comment.