aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--lib/Sema/SemaExpr.cpp5
-rw-r--r--test/SemaObjC/deref-interface.m3
3 files changed, 8 insertions, 4 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 52c81c1676..47c0afffcf 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 59d0328d6e..42d1599e2e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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
diff --git a/test/SemaObjC/deref-interface.m b/test/SemaObjC/deref-interface.m
index 642350b138..255e1d0798 100644
--- a/test/SemaObjC/deref-interface.m
+++ b/test/SemaObjC/deref-interface.m
@@ -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