Wrong lookup performed for __super

Nikola Smiljanic popizdeh at gmail.com
Thu Oct 23 17:35:16 PDT 2014


It seems that there's one more place where we need to call LookupInSuper.
I've modified the relevant tests to catch this by having different
signature for the method and making sure the right one is called.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141024/c0005208/attachment.html>
-------------- next part --------------
diff --git lib/Sema/SemaExprMember.cpp lib/Sema/SemaExprMember.cpp
index ef78982..3fd23c5 100644
--- lib/Sema/SemaExprMember.cpp
+++ lib/Sema/SemaExprMember.cpp
@@ -614,7 +614,11 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
   }
 
   // The record definition is complete, now look up the member.
-  SemaRef.LookupQualifiedName(R, DC);
+  NestedNameSpecifier *NNS = SS.getScopeRep();
+  if (NNS && NNS->getKind() == NestedNameSpecifier::Super)
+    SemaRef.LookupInSuper(R, NNS->getAsRecordDecl());
+  else
+    SemaRef.LookupQualifiedName(R, DC);
 
   if (!R.empty())
     return false;
diff --git test/SemaCXX/MicrosoftSuper.cpp test/SemaCXX/MicrosoftSuper.cpp
index 13138ca..cb21656 100644
--- test/SemaCXX/MicrosoftSuper.cpp
+++ test/SemaCXX/MicrosoftSuper.cpp
@@ -88,14 +88,14 @@ template <typename T>
 struct BaseTemplate {
   typedef int XXX;
 
-  void foo() {}
+  int foo() { return 0; }
 };
 
 struct DerivedFromKnownSpecialization : BaseTemplate<int> {
   __super::XXX a;
   typedef __super::XXX b;
 
-  void test() {
+  void foo() {
     __super::XXX c;
     typedef __super::XXX d;
 
@@ -111,14 +111,14 @@ struct DerivedFromDependentBase : BaseTemplate<T> {
   __super::XXX c;         // expected-error {{missing 'typename'}}
   typedef __super::XXX d; // expected-error {{missing 'typename'}}
 
-  void test() {
+  void foo() {
     typename __super::XXX e;
     typedef typename __super::XXX f;
 
     __super::XXX g;         // expected-error {{missing 'typename'}}
     typedef __super::XXX h; // expected-error {{missing 'typename'}}
 
-    __super::foo();
+    int x = __super::foo();
   }
 };
 
@@ -130,7 +130,7 @@ struct DerivedFromTemplateParameter : T {
   __super::XXX c;         // expected-error {{missing 'typename'}}
   typedef __super::XXX d; // expected-error {{missing 'typename'}}
 
-  void test() {
+  void foo() {
     typename __super::XXX e;
     typedef typename __super::XXX f;
 
@@ -143,7 +143,7 @@ struct DerivedFromTemplateParameter : T {
 
 void instantiate() {
   DerivedFromDependentBase<int> d;
-  d.test();
+  d.foo();
   DerivedFromTemplateParameter<Base1> t;
-  t.test();
+  t.foo();
 }


More information about the cfe-commits mailing list