[cfe-commits] r139235 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaObjCProperty.cpp test/SemaObjC/error-property-gc-attr.m
Fariborz Jahanian
fjahanian at apple.com
Wed Sep 7 09:24:21 PDT 2011
Author: fjahanian
Date: Wed Sep 7 11:24:21 2011
New Revision: 139235
URL: http://llvm.org/viewvc/llvm-project?rev=139235&view=rev
Log:
objc-gc: More sema work for properties declared 'weak'
in GC mode. // rdar://10073896
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/error-property-gc-attr.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=139235&r1=139234&r2=139235&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 7 11:24:21 2011
@@ -549,6 +549,9 @@
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"
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=139235&r1=139234&r2=139235&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Wed Sep 7 11:24:21 2011
@@ -594,12 +594,18 @@
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 @@
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
Modified: cfe/trunk/test/SemaObjC/error-property-gc-attr.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/error-property-gc-attr.m?rev=139235&r1=139234&r2=139235&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/error-property-gc-attr.m (original)
+++ cfe/trunk/test/SemaObjC/error-property-gc-attr.m Wed Sep 7 11:24:21 2011
@@ -3,7 +3,7 @@
@interface INTF
{
- id IVAR;
+ id IVAR; // expected-note {{ivar is declared here}}
__weak id II;
__weak id WID;
id ID;
More information about the cfe-commits
mailing list