fix daca2 paraview crash from uninstantiated recursive template (#3237)

This commit is contained in:
Robert Reif 2021-04-29 05:09:51 -04:00 committed by GitHub
parent 9aa131a12e
commit e1e822275d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -1871,6 +1871,9 @@ namespace {
// check in base types base types
for (const std::string & base : baseTypes) {
const ScopeInfo3 * baseScope = findScope(base);
// bail on uninstantiated recursive template
if (baseScope == this)
return false;
if (baseScope && baseScope->fullName == scope)
return true;
if (baseScope && baseScope->findTypeInBase(scope))

View File

@ -71,6 +71,7 @@ private:
TEST_CASE(simplifyUsing22);
TEST_CASE(simplifyUsing23);
TEST_CASE(simplifyUsing24);
TEST_CASE(simplifyUsing25);
TEST_CASE(simplifyUsing8970);
TEST_CASE(simplifyUsing8971);
@ -593,6 +594,24 @@ private:
ASSERT_EQUALS(expected, tok(code, false));
}
void simplifyUsing25() {
const char code[] = "struct UnusualType {\n"
" using T = vtkm::Id;\n"
" T X;\n"
"};\n"
"namespace vtkm {\n"
"template <>\n"
"struct VecTraits<UnusualType> : VecTraits<UnusualType::T> { };\n"
"}";
const char expected[] = "struct UnusualType { "
"vtkm :: Id X ; "
"} ; "
"namespace vtkm { "
"struct VecTraits<UnusualType> : VecTraits < vtkm :: Id > { } ; "
"}";
ASSERT_EQUALS(expected, tok(code, false));
}
void simplifyUsing8970() {
const char code[] = "using V = std::vector<int>;\n"
"struct A {\n"