]> granicus.if.org Git - clang/commitdiff
Diagnose assiging to an interface object in
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 16 Aug 2010 21:51:12 +0000 (21:51 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 16 Aug 2010 21:51:12 +0000 (21:51 +0000)
non-fragile abi mode as sizes are not statically known.
Fixes radar 8315734.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111191 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/SemaObjC/deref-interface.m

index 52c81c1676d1953086ce298c995ac0baf5a43ff3..47c0afffcfac49210f42cd60013d14b8df41e00a 100644 (file)
@@ -2133,8 +2133,8 @@ def warn_indirection_through_null : Warning<
 def note_indirection_through_null : Note<
   "consider using __builtin_trap() or qualifying pointer with 'volatile'">;
 
-def err_indirection_requires_nonfragile_object : Error<
-  "indirection cannot be to an interface in non-fragile ABI (%0 invalid)">;
+def err_assignment_requires_nonfragile_object : Error<
+  "cannot assign to class object in non-fragile ABI (%0 invalid)">;
 def err_direct_interface_unsupported : Error<
   "indirection to an interface is not supported (%0 invalid)">;
 def err_typecheck_invalid_operands : Error<
index 59d0328d6e1248c177769f3e339394e8dfefd4a6..42d1599e2e9a1aa7e6f790dc6fa7b964089bcd4e 100644 (file)
@@ -6538,6 +6538,11 @@ Action::OwningExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
   }
   if (ResultTy.isNull())
     return ExprError();
+  if (ResultTy->isObjCObjectType() && LangOpts.ObjCNonFragileABI) {
+    if (Opc >= BinaryOperator::Assign && Opc <= BinaryOperator::OrAssign) 
+          Diag(OpLoc, diag::err_assignment_requires_nonfragile_object)
+                << ResultTy;
+  }
   if (CompResultTy.isNull())
     return Owned(new (Context) BinaryOperator(lhs, rhs, Opc, ResultTy, OpLoc));
   else
index 642350b138d1aec13be28470f48187b4518d8db0..255e1d07981435f5846fd4406088521e16a40836 100644 (file)
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fobjc-nonfragile-abi -verify -fsyntax-only %s
-// XFAIL: *
 
 @interface NSView 
   - (id)initWithView:(id)realView;
@@ -7,7 +6,7 @@
 
 @implementation NSView
  - (id)initWithView:(id)realView {
-     *(NSView *)self = *(NSView *)realView;    // expected-error {{indirection cannot be to an interface in non-fragile ABI}}
+     *(NSView *)self = *(NSView *)realView;    // expected-error {{cannot assign to class object in non-fragile ABI}}
  }
 @end