objc: issue error if assigning objects in fragile-abi too.
// rdar://10731065

llvm-svn: 148823
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6c2c4ef..311d9985 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3608,6 +3608,8 @@
 
 def err_assignment_requires_nonfragile_object : Error<
   "cannot assign to class object in non-fragile ABI (%0 invalid)">;
+def err_objc_object_assignment : Error<
+  "cannot assign to class object - use memcpy instead">;
 def err_direct_interface_unsupported : Error<
   "indirection to an interface is not supported (%0 invalid)">;
 def err_typecheck_invalid_operands : Error<
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2d32ea9..9adf22a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7252,10 +7252,14 @@
       ConvTy = Compatible;
 
     if (ConvTy == Compatible &&
-        getLangOptions().ObjCNonFragileABI &&
-        LHSType->isObjCObjectType())
-      Diag(Loc, diag::err_assignment_requires_nonfragile_object)
-        << LHSType;
+        LHSType->isObjCObjectType()) {
+      if (getLangOptions().ObjCNonFragileABI)
+        Diag(Loc, diag::err_assignment_requires_nonfragile_object)
+          << LHSType;
+      else
+        Diag(Loc, diag::err_objc_object_assignment)
+          << LHSType;
+    }
 
     // If the RHS is a unary plus or minus, check to see if they = and + are
     // right next to each other.  If so, the user may have typo'd "x =+ 4"
diff --git a/clang/test/SemaObjCXX/fragile-abi-object-assign.m b/clang/test/SemaObjCXX/fragile-abi-object-assign.m
new file mode 100644
index 0000000..41f961d
--- /dev/null
+++ b/clang/test/SemaObjCXX/fragile-abi-object-assign.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-fragile-abi -verify %s
+// rdar://10731065
+
+@interface MyView {}
+@end
+
+@implementation MyViewTemplate // expected-warning {{cannot find interface declaration for 'MyViewTemplate'}}
+- (id) createRealObject {
+  id realObj;
+  *(MyView *) realObj = *(MyView *) self; // expected-error {{cannot assign to class object - use memcpy instead}}
+}
+@end
+