From 62ac5d01aade35790a6d8e814edb21062da5d3f7 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 18 May 2010 23:04:17 +0000 Subject: [PATCH] Misc. fixes to bring Objetive-C++'s handling of gc attributes to be inline with Objective-C (for radar 7925141). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104084 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaObjCProperty.cpp | 11 ++++++++++- lib/Sema/SemaOverload.cpp | 3 ++- test/SemaObjC/error-property-gc-attr.m | 5 +++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 453ea25859..4c89a118bc 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -383,7 +383,16 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(Scope *S, // Check that type of property and its ivar are type compatible. if (PropType != IvarType) { - if (CheckAssignmentConstraints(PropType, IvarType) != Compatible) { + bool compat = false; + if (isa(PropType) + && isa(IvarType)) + compat = + Context.canAssignObjCInterfaces( + PropType->getAs(), + IvarType->getAs()); + else + compat = (CheckAssignmentConstraints(PropType, IvarType) == Compatible); + if (!compat) { Diag(PropertyLoc, diag::error_property_ivar_type) << property->getDeclName() << PropType << Ivar->getDeclName() << IvarType; diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 365daa6018..897ee66265 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -1042,7 +1042,8 @@ Sema::IsStandardConversion(Expr* From, QualType ToType, CanonTo = Context.getCanonicalType(ToType); if (CanonFrom.getLocalUnqualifiedType() == CanonTo.getLocalUnqualifiedType() && - CanonFrom.getLocalCVRQualifiers() != CanonTo.getLocalCVRQualifiers()) { + (CanonFrom.getLocalCVRQualifiers() != CanonTo.getLocalCVRQualifiers() + || CanonFrom.getObjCGCAttr() != CanonTo.getObjCGCAttr())) { FromType = ToType; CanonFrom = CanonTo; } diff --git a/test/SemaObjC/error-property-gc-attr.m b/test/SemaObjC/error-property-gc-attr.m index a36170475b..661638c52e 100644 --- a/test/SemaObjC/error-property-gc-attr.m +++ b/test/SemaObjC/error-property-gc-attr.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s +// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s @interface INTF { @@ -11,7 +12,7 @@ } @property (assign) __weak id pweak; @property (assign) __weak id WID; -@property (assign) __strong id not; +@property (assign) __strong id NOT; @property (assign) id ID; @property (assign) INTF* AWEAK; @property (assign) __weak INTF* WI; @@ -19,7 +20,7 @@ @implementation INTF @synthesize pweak=IVAR; // expected-error {{existing ivar 'IVAR' for __weak property 'pweak' must be __weak}} -@synthesize not=II; // expected-error {{existing ivar 'II' for a __strong property 'not' must be garbage collectable}} +@synthesize NOT=II; // expected-error {{existing ivar 'II' for a __strong property 'NOT' must be garbage collectable}} @synthesize WID; @synthesize ID; @synthesize AWEAK; // expected-error {{existing ivar 'AWEAK' for a __strong property 'AWEAK' must be garbage collectable}} -- 2.40.0