aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-04-21 21:05:54 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-04-21 21:05:54 +0000
commitc35b9e4e2efad727538c848cf30d4b0eb1031dc9 (patch)
tree0ab8e411adc50cdf4fafe8e8b2882c1a9c73f7c1 /lib/Sema/SemaDeclObjC.cpp
parentd0eef024e9fce128903b34e8e1752f3b92e06bda (diff)
Support for @dynamic AST build.
More property semantics checking. First test case for ObjC2's property implementation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50057 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--lib/Sema/SemaDeclObjC.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 21130a04fa..45d8777785 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -952,10 +952,11 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
if (ObjCImplementationDecl *IC =
dyn_cast<ObjCImplementationDecl>(ClassImpDecl)) {
IDecl = getObjCInterfaceDecl(IC->getIdentifier());
- if (!IDecl) {
- Diag(AtLoc, diag::error_missing_property_interface);
- return 0;
- }
+ // We always synthesize an interface for an implementation
+ // without an interface decl. So, IDecl is always non-zero.
+ assert(IDecl &&
+ "ActOnPropertyImplDecl - @implementation without @interface");
+
// Look for this property declaration in the @implementation's @interface
property = IDecl->FindPropertyDeclaration(PropertyId);
if (!property) {
@@ -965,6 +966,10 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
}
else if (ObjCCategoryImplDecl* CatImplClass =
dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl)) {
+ if (Synthesize) {
+ Diag(AtLoc, diag::error_synthesize_category_decl);
+ return 0;
+ }
IDecl = CatImplClass->getClassInterface();
if (!IDecl) {
Diag(AtLoc, diag::error_missing_property_interface);
@@ -980,7 +985,7 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
// Look for this property declaration in @implementation's category
property = Category->FindPropertyDeclaration(PropertyId);
if (!property) {
- Diag(PropertyLoc, diag::error_bad_property_decl,
+ Diag(PropertyLoc, diag::error_bad_category_property_decl,
Category->getName());
return 0;
}
@@ -998,16 +1003,23 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
return 0;
}
// Check that this is a previously declared 'ivar' in 'IDecl' interface
- if (!IDecl->FindIvarDeclaration(PropertyIvar)) {
+ ObjCIvarDecl *Ivar = IDecl->FindIvarDeclaration(PropertyIvar);
+ if (!Ivar) {
Diag(PropertyLoc, diag::error_missing_property_ivar_decl);
return 0;
}
+ // Check that type of property and its ivar match.
+ if (Ivar->getCanonicalType() != property->getCanonicalType()) {
+ Diag(PropertyLoc, diag::error_property_ivar_type, property->getName(),
+ Ivar->getName());
+ return 0;
+ }
+
} else if (PropertyIvar) {
// @dynamic
Diag(PropertyLoc, diag::error_dynamic_property_ivar_decl);
return 0;
}
- // TODO: More diagnostics go here !!
assert (property && "ActOnPropertyImplDecl - property declaration missing");
// TODO: Build the property implementation AST, pushes it into its
// class/cateogory implementation's vector of property implementations