Issue a warning in odd case of instance method used
in a 'Class' receiver which is not a root instance
method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70987 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index a463ab8..e8ff18b 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -529,8 +529,17 @@
       if (!isSelfExpr(RExpr)) {
         Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(lbrac,rbrac));
         if (!Method) {
+          // If no class (factory) method was found, check if an _instance_
+          // method of the same name exists in the root class only.
           Method = LookupInstanceMethodInGlobalPool(
                                    Sel, SourceRange(lbrac,rbrac));
+          if (Method)
+              if (const ObjCInterfaceDecl *ID =
+                dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext())) {
+              if (ID->getSuperClass())
+                Diag(lbrac, diag::warn_root_inst_method_not_found)
+                  << Sel << SourceRange(lbrac, rbrac);
+            }
         }
       }
     }