__super inside return statement

Nikola Smiljanic popizdeh at gmail.com
Tue Sep 30 22:54:21 PDT 2014


Lookup needs to be performed in one more place for this to work. Otherwise
lookup is performed in the wrong context which leading to a recursive call.
Provided that both methods have the same name and signature.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141001/cca211bb/attachment.html>
-------------- next part --------------
diff --git lib/Sema/SemaExpr.cpp lib/Sema/SemaExpr.cpp
index 5edabc0..7482677 100644
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -2062,7 +2062,11 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
                                         IsAddressOfOperand, TemplateArgs);
   } else {
     bool IvarLookupFollowUp = II && !SS.isSet() && getCurMethodDecl();
-    LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
+    NestedNameSpecifier *NNS = SS.getScopeRep();
+    if (NNS && NNS->getKind() == NestedNameSpecifier::Super)
+      LookupInSuper(R, NNS->getAsRecordDecl());
+    else
+      LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
 
     // If the result might be in a dependent base class, this is a dependent 
     // id-expression.
diff --git test/SemaCXX/MicrosoftSuper.cpp test/SemaCXX/MicrosoftSuper.cpp
index 1bf97ac..13138ca 100644
--- test/SemaCXX/MicrosoftSuper.cpp
+++ test/SemaCXX/MicrosoftSuper.cpp
@@ -29,12 +29,14 @@ struct Derived : Base1 {
     X = sizeof(__super::XXX)
   };
 
-  void foo(int i) {
-    __super::foo(i);
+  void foo() {
+    __super::foo(1);
 
-    if (i == 0) {
-      __super::foo(i);
+    if (true) {
+      __super::foo(1);
     }
+
+    return __super::foo(1);
   }
 
   static void bar() {


More information about the cfe-commits mailing list