r185710 - Objective-C: diagnose when synthesizing an ivar of

jahanian fjahanian at apple.com
Fri Jul 5 16:56:07 PDT 2013


On Jul 5, 2013, at 11:05 AM, Jordan Rose <jordan_rose at apple.com> wrote:

> Uh, I think the real error in this test case is that you can't meaningfully @synthesize a reference property. What happens without the reference?

Test was not meant to test reference type. Test is fixed in r185734 and issues the intended error on use of abstract class type.
For reasons that escapes me (gcc compatibility maybe?) we do allow designation of reference type on
properties. Except that ivars are by-value of the underlying type, getter returns reference to ivar, etc.

- Fariborz

> 
> 
> On Jul 5, 2013, at 10:18 , Fariborz Jahanian <fjahanian at apple.com> wrote:
> 
>> Author: fjahanian
>> Date: Fri Jul  5 12:18:11 2013
>> New Revision: 185710
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=185710&view=rev
>> Log:
>> Objective-C: diagnose when synthesizing an ivar of
>> abstract class type. // rdar://14261999
>> 
>> Modified:
>>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>    cfe/trunk/include/clang/Sema/Sema.h
>>    cfe/trunk/lib/Sema/SemaObjCProperty.cpp
>>    cfe/trunk/test/SemaObjCXX/abstract-class-type-ivar.mm
>> 
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=185710&r1=185709&r2=185710&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul  5 12:18:11 2013
>> @@ -911,7 +911,8 @@ def err_invalid_base_in_interface : Erro
>>   "%select{'struct|non-public 'interface|'class}0 %1'">;
>> 
>> def err_abstract_type_in_decl : Error<
>> -  "%select{return|parameter|variable|field|instance variable}0 type %1 is an abstract class">;
>> +  "%select{return|parameter|variable|field|instance variable|"
>> +  "synthesized instance variable}0 type %1 is an abstract class">;
>> def err_allocation_of_abstract_type : Error<
>>   "allocating an object of abstract class type %0">;
>> def err_throw_abstract_type : Error<
>> 
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=185710&r1=185709&r2=185710&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Jul  5 12:18:11 2013
>> @@ -4835,6 +4835,7 @@ public:
>>     AbstractVariableType,
>>     AbstractFieldType,
>>     AbstractIvarType,
>> +    AbstractSynthesizedIvarType,
>>     AbstractArrayType
>>   };
>> 
>> 
>> Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=185710&r1=185709&r2=185710&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Fri Jul  5 12:18:11 2013
>> @@ -1082,8 +1082,14 @@ Decl *Sema::ActOnPropertyImplDecl(Scope
>>                                   PropertyIvarType, /*Dinfo=*/0,
>>                                   ObjCIvarDecl::Private,
>>                                   (Expr *)0, true);
>> -      if (CompleteTypeErr)
>> +      if (RequireNonAbstractType(PropertyIvarLoc,
>> +                                 PropertyIvarType,
>> +                                 diag::err_abstract_type_in_decl,
>> +                                 AbstractSynthesizedIvarType)) {
>> +        Diag(property->getLocation(), diag::note_property_declare);
>>         Ivar->setInvalidDecl();
>> +      } else if (CompleteTypeErr)
>> +          Ivar->setInvalidDecl();
>>       ClassImpDecl->addDecl(Ivar);
>>       IDecl->makeDeclVisibleInContext(Ivar);
>> 
>> 
>> Modified: cfe/trunk/test/SemaObjCXX/abstract-class-type-ivar.mm
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/abstract-class-type-ivar.mm?rev=185710&r1=185709&r2=185710&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/SemaObjCXX/abstract-class-type-ivar.mm (original)
>> +++ cfe/trunk/test/SemaObjCXX/abstract-class-type-ivar.mm Fri Jul  5 12:18:11 2013
>> @@ -1,5 +1,6 @@
>> // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
>> // rdar://12095239
>> +// rdar://14261999
>> 
>> class CppAbstractBase {
>> public:
>> @@ -16,11 +17,14 @@ class CppConcreteSub : public CppAbstrac
>>     CppConcreteSub _concrete; // expected-error{{instance variable type 'CppConcreteSub' is an abstract class}}
>> }
>> - (CppAbstractBase*)abstract;
>> + at property (nonatomic, readonly) const CppConcreteSub& Prop;  // expected-note {{property declared here}}
>> @end
>> +
>> @implementation Objc
>> - (CppAbstractBase*)abstract {
>>     return &_concrete;
>> }
>> + at synthesize Prop; // expected-error {{synthesized instance variable type 'const CppConcreteSub' is an abstract class}}
>> @end
>> 
>> class Cpp {
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130705/f1dac8f6/attachment.html>


More information about the cfe-commits mailing list