forked from OSchip/llvm-project
Objective-C: diagnose when synthesizing an ivar of
abstract class type. // rdar://14261999 llvm-svn: 185710
This commit is contained in:
parent
751447a3ac
commit
873bae79ac
|
@ -911,7 +911,8 @@ def err_invalid_base_in_interface : Error<
|
|||
"%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<
|
||||
|
|
|
@ -4835,6 +4835,7 @@ public:
|
|||
AbstractVariableType,
|
||||
AbstractFieldType,
|
||||
AbstractIvarType,
|
||||
AbstractSynthesizedIvarType,
|
||||
AbstractArrayType
|
||||
};
|
||||
|
||||
|
|
|
@ -1082,8 +1082,14 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
|
|||
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);
|
||||
|
||||
|
|
|
@ -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 CppAbstractBase {
|
|||
CppConcreteSub _concrete; // expected-error{{instance variable type 'CppConcreteSub' is an abstract class}}
|
||||
}
|
||||
- (CppAbstractBase*)abstract;
|
||||
@property (nonatomic, readonly) const CppConcreteSub& Prop; // expected-note {{property declared here}}
|
||||
@end
|
||||
|
||||
@implementation Objc
|
||||
- (CppAbstractBase*)abstract {
|
||||
return &_concrete;
|
||||
}
|
||||
@synthesize Prop; // expected-error {{synthesized instance variable type 'const CppConcreteSub' is an abstract class}}
|
||||
@end
|
||||
|
||||
class Cpp {
|
||||
|
|
Loading…
Reference in New Issue