Fix for clang crash when instantiating a template with qualified lookup for members in non-class types
Details
Diff Detail
Event Timeline
lib/Sema/SemaCXXScopeSpec.cpp | ||
---|---|---|
144–146 | No need to repeat TagType, we know what it is from the right hand side. I'd recommend: if (const auto *Tag = NNS->getAsType()->getAs<TagType>()) | |
lib/Sema/SemaExprMember.cpp | ||
599–605 | This is unusual in clang's codebase, I'd recommend: DC = SemaRef.computeDeclContext(SS, /*EnteringContext=*/false); if (!DC) { |
David, thanks. I'll fix this.
Best regards,
Alexey Bataev
Software Engineer
Intel Compiler Team
14.10.2014 12:59, David Majnemer пишет:
Comment at: lib/Sema/SemaCXXScopeSpec.cpp:144
@@ -143,4 +143,3 @@case NestedNameSpecifier::TypeSpecWithTemplate: {
- const TagType *Tag = NNS->getAsType()->getAs<TagType>();
- assert(Tag && "Non-tag type in nested-name-specifier");
- return Tag->getDecl();
+ if (const TagType *Tag = NNS->getAsType()->getAs<TagType>())
+ return Tag->getDecl();
No need to repeat TagType, we know what it is from the right hand side. I'd recommend:
if (const auto *Tag = NNS->getAsType()->getAs<TagType>())Comment at: lib/Sema/SemaExprMember.cpp:599
@@ -598,2 +598,3 @@// nested-name-specifier.
- DC = SemaRef.computeDeclContext(SS, false);
+ if ((DC = SemaRef.computeDeclContext(SS, false)) == nullptr) {
+ SemaRef.Diag(SS.getBeginLoc(), diag::err_expected_class_or_namespace)
This is unusual in clang's codebase, I'd recommend:
DC = SemaRef.computeDeclContext(SS, /*EnteringContext=*/false); if (!DC) {
This is the wrong fix. The bug is that TreeTransform::RebuildCXXPseudoDestructorExpr is building a bogus CXXScopeSpec here:
// The scope type is now known to be a valid nested name specifier // component. Tack it on to the end of the nested name specifier. if (ScopeType) SS.Extend(SemaRef.Context, SourceLocation(), ScopeType->getTypeLoc(), CCLoc);
If ScopeType is not a class type, we should reject it at this point.
Please add tests for the case where the type before the ::~ instantiates as an enum type, in both C++98 and C++11.
Otherwise, this looks fine. Thanks!
No need to repeat TagType, we know what it is from the right hand side. I'd recommend: