From 36981b17ed939300f6f8fc2355a255f711fcef71 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 20 Oct 2011 21:14:49 +0000 Subject: Vendor import of clang release_30 branch r142614: http://llvm.org/svn/llvm-project/cfe/branches/release_30@142614 --- lib/Sema/SemaCXXScopeSpec.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'lib/Sema/SemaCXXScopeSpec.cpp') diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index 5f8c9c62a4092..360a0404b8f4e 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -137,8 +137,7 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS, switch (NNS->getKind()) { case NestedNameSpecifier::Identifier: - assert(false && "Dependent nested-name-specifier has no DeclContext"); - break; + llvm_unreachable("Dependent nested-name-specifier has no DeclContext"); case NestedNameSpecifier::Namespace: return NNS->getAsNamespace(); @@ -238,7 +237,7 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS, // until we see a definition, so awkwardly pull out this special // case. if (const EnumType *enumType = dyn_cast_or_null(tagType)) { - if (!enumType->getDecl()->isDefinition()) { + if (!enumType->getDecl()->isCompleteDefinition()) { Diag(loc, diag::err_incomplete_nested_name_spec) << type << SS.getRange(); SS.SetInvalid(SS.getRange()); @@ -615,6 +614,31 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, LookupName(Found, S); } + // In Microsoft mode, if we are within a templated function and we can't + // resolve Identifier, then extend the SS with Identifier. This will have + // the effect of resolving Identifier during template instantiation. + // The goal is to be able to resolve a function call whose + // nested-name-specifier is located inside a dependent base class. + // Example: + // + // class C { + // public: + // static void foo2() { } + // }; + // template class A { public: typedef C D; }; + // + // template class B : public A { + // public: + // void foo() { D::foo2(); } + // }; + if (getLangOptions().MicrosoftExt) { + DeclContext *DC = LookupCtx ? LookupCtx : CurContext; + if (DC->isDependentContext() && DC->isFunctionOrMethod()) { + SS.Extend(Context, &Identifier, IdentifierLoc, CCLoc); + return false; + } + } + unsigned DiagID; if (!Found.empty()) DiagID = diag::err_expected_class_or_namespace; -- cgit v1.2.3