diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2011-09-07 16:24:21 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-09-07 16:24:21 +0000 |
| commit | eebdb67420c1809c158c78f3ace08c35085deb6e (patch) | |
| tree | d660928f3e901f2bf04e6ccbcdfb03835e1f55a7 | |
| parent | 4ff93f3bc289689ce74dfcf3830ccaeb6c8625c5 (diff) | |
| download | bcm5719-llvm-eebdb67420c1809c158c78f3ace08c35085deb6e.tar.gz bcm5719-llvm-eebdb67420c1809c158c78f3ace08c35085deb6e.zip | |
objc-gc: More sema work for properties declared 'weak'
in GC mode. // rdar://10073896
llvm-svn: 139235
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaObjCProperty.cpp | 19 | ||||
| -rw-r--r-- | clang/test/SemaObjC/error-property-gc-attr.m | 2 |
3 files changed, 17 insertions, 7 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index e39a2c72f38..a90849cc196 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -549,6 +549,9 @@ def err_arc_perform_selector_retains : Error< def warn_arc_perform_selector_leaks : Warning< "performSelector may cause a leak because its selector is unknown">, InGroup<DiagGroup<"arc-performSelector-leaks">>; +def err_gc_weak_property_strong_type : Error< + "weak attribute declared on a __strong type property" + "in GC mode">; def error_synthesized_ivar_yet_not_supported : Error< "instance variable synthesis not yet supported" diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index 9695b811ee5..9f50dea233b 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -594,12 +594,18 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, ObjCPropertyDecl::PropertyAttributeKind kind = property->getPropertyAttributes(); QualType PropType = Context.getCanonicalType(property->getType()); - bool PropertyIsGCWeak = (kind & ObjCPropertyDecl::OBJC_PR_weak && - !getLangOptions().ObjCAutoRefCount && - getLangOptions().getGCMode() != - LangOptions::NonGC); - if (PropertyIsGCWeak && !PropType.isObjCGCStrong()) - PropType = Context.getObjCGCQualType(PropType, Qualifiers::Weak); + + if ((kind & ObjCPropertyDecl::OBJC_PR_weak) && + !getLangOptions().ObjCAutoRefCount && + getLangOptions().getGCMode() != LangOptions::NonGC) { + if (PropType.isObjCGCStrong()) { + Diag(PropertyLoc, + diag::err_gc_weak_property_strong_type); + Diag(property->getLocation(), diag::note_property_declare); + } + else + PropType = Context.getObjCGCQualType(PropType, Qualifiers::Weak); + } QualType PropertyIvarType = PropType; if (PropType->isReferenceType()) PropertyIvarType = cast<ReferenceType>(PropType)->getPointeeType(); @@ -721,6 +727,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, getLangOptions().getGCMode() != LangOptions::NonGC)) { Diag(PropertyLoc, diag::error_weak_property) << property->getDeclName() << Ivar->getDeclName(); + Diag(Ivar->getLocation(), diag::note_ivar_decl); // Fall thru - see previous comment } // Fall thru - see previous comment diff --git a/clang/test/SemaObjC/error-property-gc-attr.m b/clang/test/SemaObjC/error-property-gc-attr.m index 829c0822874..25fee051174 100644 --- a/clang/test/SemaObjC/error-property-gc-attr.m +++ b/clang/test/SemaObjC/error-property-gc-attr.m @@ -3,7 +3,7 @@ @interface INTF { - id IVAR; + id IVAR; // expected-note {{ivar is declared here}} __weak id II; __weak id WID; id ID; |

