зеркало из https://github.com/microsoft/clang-1.git
In C++11 mode, implement the C++11 semantics for
[basic.lookup.classref]p1 and p4, which concerns name lookup for nested-name-specifiers and template names, respectively, in a member access expression. C++98/03 forces us to look both in the scope of the object and in the current scope, then compare the results. C++11 just takes the result from the scope of the object, if something is found. Fixes <rdar://problem/11328502>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155935 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d53f6971a7
Коммит
05e6076f0a
|
@ -539,8 +539,9 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
|
||||||
|
|
||||||
NamedDecl *SD = Found.getAsSingle<NamedDecl>();
|
NamedDecl *SD = Found.getAsSingle<NamedDecl>();
|
||||||
if (isAcceptableNestedNameSpecifier(SD)) {
|
if (isAcceptableNestedNameSpecifier(SD)) {
|
||||||
if (!ObjectType.isNull() && !ObjectTypeSearchedInScope) {
|
if (!ObjectType.isNull() && !ObjectTypeSearchedInScope &&
|
||||||
// C++ [basic.lookup.classref]p4:
|
!getLangOpts().CPlusPlus0x) {
|
||||||
|
// C++03 [basic.lookup.classref]p4:
|
||||||
// [...] If the name is found in both contexts, the
|
// [...] If the name is found in both contexts, the
|
||||||
// class-name-or-namespace-name shall refer to the same entity.
|
// class-name-or-namespace-name shall refer to the same entity.
|
||||||
//
|
//
|
||||||
|
@ -548,6 +549,8 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
|
||||||
// into the current scope (the scope of the postfix-expression) to
|
// into the current scope (the scope of the postfix-expression) to
|
||||||
// see if we can find the same name there. As above, if there is no
|
// see if we can find the same name there. As above, if there is no
|
||||||
// scope, reconstruct the result from the template instantiation itself.
|
// scope, reconstruct the result from the template instantiation itself.
|
||||||
|
//
|
||||||
|
// Note that C++11 does *not* perform this redundant lookup.
|
||||||
NamedDecl *OuterDecl;
|
NamedDecl *OuterDecl;
|
||||||
if (S) {
|
if (S) {
|
||||||
LookupResult FoundOuter(*this, &Identifier, IdentifierLoc,
|
LookupResult FoundOuter(*this, &Identifier, IdentifierLoc,
|
||||||
|
|
|
@ -354,12 +354,14 @@ void Sema::LookupTemplateName(LookupResult &Found,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S && !ObjectType.isNull() && !ObjectTypeSearchedInScope) {
|
if (S && !ObjectType.isNull() && !ObjectTypeSearchedInScope &&
|
||||||
// C++ [basic.lookup.classref]p1:
|
!(getLangOpts().CPlusPlus0x && !Found.empty())) {
|
||||||
|
// C++03 [basic.lookup.classref]p1:
|
||||||
// [...] If the lookup in the class of the object expression finds a
|
// [...] If the lookup in the class of the object expression finds a
|
||||||
// template, the name is also looked up in the context of the entire
|
// template, the name is also looked up in the context of the entire
|
||||||
// postfix-expression and [...]
|
// postfix-expression and [...]
|
||||||
//
|
//
|
||||||
|
// Note: C++11 does not perform this second lookup.
|
||||||
LookupResult FoundOuter(*this, Found.getLookupName(), Found.getNameLoc(),
|
LookupResult FoundOuter(*this, Found.getLookupName(), Found.getNameLoc(),
|
||||||
LookupOrdinaryName);
|
LookupOrdinaryName);
|
||||||
LookupName(FoundOuter, S);
|
LookupName(FoundOuter, S);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче