More type checking for properties, accessors and
use of dot-syntax expression. This is to match gcc's.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71243 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 79c471a..f698620 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2096,8 +2096,21 @@
       // Check whether we can reference this property.
       if (DiagnoseUseOfDecl(PD, MemberLoc))
         return ExprError();
-
-      return Owned(new (Context) ObjCPropertyRefExpr(PD, PD->getType(),
+      QualType ResTy = PD->getType();
+      Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
+      ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Context, Sel);
+      if (Getter) {
+        AssignConvertType result =
+          CheckAssignmentConstraints(PD->getType(), Getter->getResultType());
+        if (result != Compatible) {
+          Diag(MemberLoc, diag::warn_accessor_property_type_mismatch) 
+            << PD->getDeclName() << Sel;
+          Diag(Getter->getLocation(), diag::note_declared_at);
+          ResTy = Getter->getResultType();
+        }
+      }
+      
+      return Owned(new (Context) ObjCPropertyRefExpr(PD, ResTy,
                                                      MemberLoc, BaseExpr));
     }