diff options
author | Abramo Bagnara <abramo.bagnara@gmail.com> | 2010-08-13 12:56:25 +0000 |
---|---|---|
committer | Abramo Bagnara <abramo.bagnara@gmail.com> | 2010-08-13 12:56:25 +0000 |
commit | 7bd067635df79f6ce4b9ffee394ea6d9e86e4290 (patch) | |
tree | 4294e3dac239aae03f8e4d9b37461b7feadb9d03 /lib/Sema/SemaType.cpp | |
parent | 3cdfc4d1862b7195159c376a4542b440037dac6a (diff) |
Fixed NNS insertion in MemberPointerType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111013 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r-- | lib/Sema/SemaType.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 92534e3f5a..28d1f13775 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1294,19 +1294,19 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, } case DeclaratorChunk::MemberPointer: // The scope spec must refer to a class, or be dependent. + CXXScopeSpec &SS = DeclType.Mem.Scope(); QualType ClsType; - if (DeclType.Mem.Scope().isInvalid()) { + if (SS.isInvalid()) { // Avoid emitting extra errors if we already errored on the scope. D.setInvalidType(true); - } else if (isDependentScopeSpecifier(DeclType.Mem.Scope()) - || dyn_cast_or_null<CXXRecordDecl>( - computeDeclContext(DeclType.Mem.Scope()))) { + } else if (isDependentScopeSpecifier(SS) || + dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS))) { NestedNameSpecifier *NNS - = (NestedNameSpecifier *)DeclType.Mem.Scope().getScopeRep(); + = static_cast<NestedNameSpecifier*>(SS.getScopeRep()); NestedNameSpecifier *NNSPrefix = NNS->getPrefix(); switch (NNS->getKind()) { case NestedNameSpecifier::Identifier: - ClsType = Context.getDependentNameType(ETK_None, NNSPrefix, + ClsType = Context.getDependentNameType(ETK_None, NNSPrefix, NNS->getAsIdentifier()); break; @@ -1314,12 +1314,16 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, case NestedNameSpecifier::Global: llvm_unreachable("Nested-name-specifier must name a type"); break; - + case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpecWithTemplate: - // Note: NNSPrefix (if any) is included in ClsType - // (hence, no need to wrap ClsType in an elaborated type). ClsType = QualType(NNS->getAsType(), 0); + // Note: if NNS is dependent, then its prefix (if any) is already + // included in ClsType; this does not hold if the NNS is + // nondependent: in this case (if there is indeed a prefix) + // ClsType needs to be wrapped into an elaborated type. + if (NNSPrefix && !NNS->isDependent()) + ClsType = Context.getElaboratedType(ETK_None, NNSPrefix, ClsType); break; } } else { |