Browse Source

Fixed an assert when parsing nested types which use template instantiations of void.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
cpp_module_crash
Dimitar Dobrev 9 years ago
parent
commit
f29e3a2240
  1. 23
      src/CppParser/Parser.cpp
  2. 9
      tests/Common/Common.h

23
src/CppParser/Parser.cpp

@ -2241,14 +2241,9 @@ static const clang::Type* GetFinalType(const clang::Type* Ty) @@ -2241,14 +2241,9 @@ static const clang::Type* GetFinalType(const clang::Type* Ty)
}
}
static bool CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty)
static bool CheckTypeIfRecord(const clang::Type* Ty)
{
auto FinalType = GetFinalType(Ty);
if (FinalType->isDependentType() || FinalType->isInstantiationDependentType())
return false;
if (auto RT = FinalType->getAs<clang::RecordType>())
if (auto RT = Ty->getAs<clang::RecordType>())
{
if (RT->getDecl()->isInvalidDecl() || RT->getDecl()->isDependentContext() ||
!RT->getDecl()->getDefinition())
@ -2257,15 +2252,23 @@ static bool CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty) @@ -2257,15 +2252,23 @@ static bool CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty)
for (const auto& F : RT->getDecl()->fields())
{
auto FT = GetFinalType(F->getType().getTypePtr());
const clang::RecordType* FR;
if ((FR = FT->getAs<clang::RecordType>()) && FR->getDecl()->isInvalidDecl())
if (FT != Ty && !CheckTypeIfRecord(FT))
return false;
}
}
return true;
}
static bool CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty)
{
auto FinalType = GetFinalType(Ty);
if (FinalType->isDependentType() || FinalType->isInstantiationDependentType())
return false;
return CheckTypeIfRecord(FinalType);
}
void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F,
bool IsDependent)
{

9
tests/Common/Common.h

@ -1101,8 +1101,17 @@ private: @@ -1101,8 +1101,17 @@ private:
T t;
};
template <class T>
class SpecialisesVoidInUnion
{
union {
SpecialisesVoid<T>* e;
}* u;
};
class UsesSpecialisationOfVoid
{
private:
SpecialisesVoid<void>* s;
SpecialisesVoidInUnion<void>* h;
};

Loading…
Cancel
Save