objc: Issue a generic diagnostic assigning to

an objc object in any abi mode.

llvm-svn: 148847
This commit is contained in:
Fariborz Jahanian 2012-01-24 19:40:13 +00:00
parent c11d1dd133
commit e2a7776eff
4 changed files with 5 additions and 12 deletions

View File

@ -3606,10 +3606,8 @@ def warn_pointer_indirection_from_incompatible_type : Warning<
"behavior.">, "behavior.">,
InGroup<DiagGroup<"undefined-reinterpret-cast">>, DefaultIgnore; InGroup<DiagGroup<"undefined-reinterpret-cast">>, DefaultIgnore;
def err_assignment_requires_nonfragile_object : Error<
"cannot assign to class object in non-fragile ABI (%0 invalid)">;
def err_objc_object_assignment : Error< def err_objc_object_assignment : Error<
"cannot assign to class object - use memcpy instead">; "cannot assign to class object (%0 invalid)">;
def err_direct_interface_unsupported : Error< def err_direct_interface_unsupported : Error<
"indirection to an interface is not supported (%0 invalid)">; "indirection to an interface is not supported (%0 invalid)">;
def err_typecheck_invalid_operands : Error< def err_typecheck_invalid_operands : Error<

View File

@ -7252,14 +7252,9 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
ConvTy = Compatible; ConvTy = Compatible;
if (ConvTy == Compatible && if (ConvTy == Compatible &&
LHSType->isObjCObjectType()) { LHSType->isObjCObjectType())
if (getLangOptions().ObjCNonFragileABI)
Diag(Loc, diag::err_assignment_requires_nonfragile_object)
<< LHSType;
else
Diag(Loc, diag::err_objc_object_assignment) Diag(Loc, diag::err_objc_object_assignment)
<< LHSType; << LHSType;
}
// If the RHS is a unary plus or minus, check to see if they = and + are // 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" // right next to each other. If so, the user may have typo'd "x =+ 4"

View File

@ -6,7 +6,7 @@
@implementation NSView @implementation NSView
- (id)initWithView:(id)realView { - (id)initWithView:(id)realView {
*(NSView *)self = *(NSView *)realView; // expected-error {{cannot assign to class object in non-fragile ABI}} *(NSView *)self = *(NSView *)realView; // expected-error {{cannot assign to class object}}
} }
@end @end

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-fragile-abi -verify %s // RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-fragile-abi -verify %s
// rdar://10731065 // rdar://10731065
@interface MyView {} @interface MyView {}
@ -7,7 +7,7 @@
@implementation MyViewTemplate // expected-warning {{cannot find interface declaration for 'MyViewTemplate'}} @implementation MyViewTemplate // expected-warning {{cannot find interface declaration for 'MyViewTemplate'}}
- (id) createRealObject { - (id) createRealObject {
id realObj; id realObj;
*(MyView *) realObj = *(MyView *) self; // expected-error {{cannot assign to class object - use memcpy instead}} *(MyView *) realObj = *(MyView *) self; // expected-error {{cannot assign to class object}}
} }
@end @end