[cfe-commits] r143219 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprObjC.cpp test/SemaObjC/arc-objc-lifetime.m test/SemaObjC/arc-unavailable-for-weakref.m test/SemaObjCXX/arc-unavailable-for-weakref.mm
John McCall
rjmccall at apple.com
Fri Oct 28 14:33:17 PDT 2011
On Oct 28, 2011, at 1:06 PM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Fri Oct 28 15:06:07 2011
> New Revision: 143219
>
> URL: http://llvm.org/viewvc/llvm-project?rev=143219&view=rev
> Log:
> objective-c arc: type-casting of an objc pointer to
> an rvalue retainable object type with life-time qualifier has no
> effect and wil be diagnosed as error. // rdar://10244607
>
> Added:
> cfe/trunk/test/SemaObjC/arc-objc-lifetime.m
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaExprObjC.cpp
> cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m
> cfe/trunk/test/SemaObjCXX/arc-unavailable-for-weakref.mm
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=143219&r1=143218&r2=143219&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 28 15:06:07 2011
> @@ -3042,6 +3042,9 @@
> "%select{%2|a non-Objective-C pointer type %2|a block pointer|"
> "an Objective-C pointer|an indirect pointer to an Objective-C pointer}1"
> " to %3 is disallowed with ARC">;
> +def err_arc_nolifetime_behavior : Error<
> + "casting expression of type %1 to type %0 with qualified lifetime"
> + "will not change object lifetime">;
We use the term "ownership" externally; I just haven't changed the name
internally everywhere.
Also, what do you think about this wording?
error: explicit ownership qualifier on cast result would have no effect
> + if ((castACTC == ACTC_retainable) &&
> + isa<AttributedType>(castType) &&
> + (castType.getObjCLifetime() != Qualifiers::OCL_None) &&
> + (CCK == CCK_CStyleCast || CCK == CCK_OtherCast) &&
I don't think the CCK restriction is meaningful.
I know it's kindof marginal, but please do look through ParenTypes
and other AttributedTypes here. Also, AttributedTypes are not
necessarily only ownership attributes. Also also, please add a
comment explaining that you're intentionally looking at type sugar
and that you don't want to look through certain kinds of sugar.
I don't know if it's currently possible to get a good test case for other
AttributedTypes, but (__strong NSString(*)) is a good test case for
ParenTypes.
John.
More information about the cfe-commits
mailing list