diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 836c740f3..5ccb42f3f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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)) diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 332182bfc..d6e4846e0 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -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 : VecTraits { };\n" + "}"; + const char expected[] = "struct UnusualType { " + "vtkm :: Id X ; " + "} ; " + "namespace vtkm { " + "struct VecTraits : VecTraits < vtkm :: Id > { } ; " + "}"; + ASSERT_EQUALS(expected, tok(code, false)); + } + void simplifyUsing8970() { const char code[] = "using V = std::vector;\n" "struct A {\n"