diff options
| author | Francois Pichet <pichet2000@gmail.com> | 2011-07-27 01:05:24 +0000 |
|---|---|---|
| committer | Francois Pichet <pichet2000@gmail.com> | 2011-07-27 01:05:24 +0000 |
| commit | b23dc0950b61d560b276d25654a4627dbbb666e7 (patch) | |
| tree | b08f2358b2040e61aa2df8c991d34615738625a5 /clang/lib/Sema | |
| parent | 8b5277c6cf63d93a0d8da48b235eacdb1af9f93b (diff) | |
| download | bcm5719-llvm-b23dc0950b61d560b276d25654a4627dbbb666e7.tar.gz bcm5719-llvm-b23dc0950b61d560b276d25654a4627dbbb666e7.zip | |
In Microsoft mode, if we are within a templated function and we can't resolve Identifier during BuildCXXNestedNameSpecifier, 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.
class C {
public:
static void foo2() { }
};
template <class T> class A {
public:
typedef C D;
};
template <class T> class B : public A<T> {
public:
void foo() { D::foo2(); }
};
Note that this won't work if the NestedNameSpecifier refers to a type.
This fixes 1 error when parsing the MSVC 2010 standard headers file with clang.
llvm-svn: 136203
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaCXXScopeSpec.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp index 5f8c9c62a40..d5bcb712553 100644 --- a/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -615,6 +615,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 T> class A { public: typedef C D; }; + // + // template <class T> class B : public A<T> { + // public: + // void foo() { D::foo2(); } + // }; + if (getLangOptions().Microsoft) { + 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; |

