[cfe-commits] r155935 - in /cfe/trunk/lib/Sema: SemaCXXScopeSpec.cpp SemaTemplate.cpp

Douglas Gregor dgregor at apple.com
Tue May 1 13:33:06 PDT 2012


On May 1, 2012, at 1:31 PM, Matt Beaumont-Gay <matthewbg at google.com> wrote:

> Testcase?

r155940.

	- Doug

> On Tue, May 1, 2012 at 1:23 PM, Douglas Gregor <dgregor at apple.com> wrote:
>> Author: dgregor
>> Date: Tue May  1 15:23:02 2012
>> New Revision: 155935
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=155935&view=rev
>> Log:
>> 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>.
>> 
>> Modified:
>>    cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
>>    cfe/trunk/lib/Sema/SemaTemplate.cpp
>> 
>> Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=155935&r1=155934&r2=155935&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Tue May  1 15:23:02 2012
>> @@ -539,8 +539,9 @@
>> 
>>   NamedDecl *SD = Found.getAsSingle<NamedDecl>();
>>   if (isAcceptableNestedNameSpecifier(SD)) {
>> -    if (!ObjectType.isNull() && !ObjectTypeSearchedInScope) {
>> -      // C++ [basic.lookup.classref]p4:
>> +    if (!ObjectType.isNull() && !ObjectTypeSearchedInScope &&
>> +        !getLangOpts().CPlusPlus0x) {
>> +      // C++03 [basic.lookup.classref]p4:
>>       //   [...] If the name is found in both contexts, the
>>       //   class-name-or-namespace-name shall refer to the same entity.
>>       //
>> @@ -548,6 +549,8 @@
>>       // 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
>>       // scope, reconstruct the result from the template instantiation itself.
>> +      //
>> +      // Note that C++11 does *not* perform this redundant lookup.
>>       NamedDecl *OuterDecl;
>>       if (S) {
>>         LookupResult FoundOuter(*this, &Identifier, IdentifierLoc,
>> 
>> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=155935&r1=155934&r2=155935&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue May  1 15:23:02 2012
>> @@ -354,12 +354,14 @@
>>     return;
>>   }
>> 
>> -  if (S && !ObjectType.isNull() && !ObjectTypeSearchedInScope) {
>> -    // C++ [basic.lookup.classref]p1:
>> +  if (S && !ObjectType.isNull() && !ObjectTypeSearchedInScope &&
>> +      !(getLangOpts().CPlusPlus0x && !Found.empty())) {
>> +    // C++03 [basic.lookup.classref]p1:
>>     //   [...] 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
>>     //   postfix-expression and [...]
>>     //
>> +    // Note: C++11 does not perform this second lookup.
>>     LookupResult FoundOuter(*this, Found.getLookupName(), Found.getNameLoc(),
>>                             LookupOrdinaryName);
>>     LookupName(FoundOuter, S);
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list