[cfe-commits] r50065 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaDeclObjC.cpp test/Sema/objc-property-1.m
Fariborz Jahanian
fjahanian at apple.com
Mon Apr 21 14:57:36 PDT 2008
Author: fjahanian
Date: Mon Apr 21 16:57:36 2008
New Revision: 50065
URL: http://llvm.org/viewvc/llvm-project?rev=50065&view=rev
Log:
More semantics checks of properties. Property implementation can implicitly use
ivar of same name.
Better diagnostics to bring home this point.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/Sema/objc-property-1.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=50065&r1=50064&r2=50065&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Mon Apr 21 16:57:36 2008
@@ -492,7 +492,7 @@
DIAG(error_bad_property_context, ERROR,
"property implementation must be in a class or category implementation")
DIAG(error_bad_property_decl, ERROR,
- "property implementation must have its declaration in the class '%0'")
+ "property implementation must have its declaration in interface '%0'")
DIAG(error_bad_category_property_decl, ERROR,
"property implementation must have its declaration in the category '%0'")
DIAG(error_property_ivar_decl, ERROR,
@@ -502,7 +502,8 @@
DIAG(error_missing_property_interface, ERROR,
"property implementation in a category with no category declaration")
DIAG(error_missing_property_ivar_decl, ERROR,
- "property synthesize requires a previously declared ivar")
+ "synthesized property '%0' must either be named the same as a compatible"
+ " ivar or must explicitly name an ivar")
DIAG(error_synthesize_category_decl, ERROR,
"@synthesize not allowed in a category's implementation")
DIAG(error_property_ivar_type, ERROR,
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=50065&r1=50064&r2=50065&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Apr 21 16:57:36 2008
@@ -998,14 +998,13 @@
// Check that we have a valid, previously declared ivar for @synthesize
if (Synthesize) {
// @synthesize
- if (!PropertyIvar) {
- Diag(PropertyLoc, diag::error_property_ivar_decl);
- return 0;
- }
+ if (!PropertyIvar)
+ PropertyIvar = PropertyId;
// Check that this is a previously declared 'ivar' in 'IDecl' interface
ObjCIvarDecl *Ivar = IDecl->FindIvarDeclaration(PropertyIvar);
if (!Ivar) {
- Diag(PropertyLoc, diag::error_missing_property_ivar_decl);
+ Diag(PropertyLoc, diag::error_missing_property_ivar_decl,
+ PropertyId->getName());
return 0;
}
// Check that type of property and its ivar match.
Modified: cfe/trunk/test/Sema/objc-property-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-property-1.m?rev=50065&r1=50064&r2=50065&view=diff
==============================================================================
--- cfe/trunk/test/Sema/objc-property-1.m (original)
+++ cfe/trunk/test/Sema/objc-property-1.m Mon Apr 21 16:57:36 2008
@@ -3,9 +3,11 @@
@interface I
{
int IVAR;
+ int name;
}
@property int d1;
@property id prop_id;
+ at property int name;
@end
@interface I(CAT)
@@ -13,10 +15,11 @@
@end
@implementation I
- at synthesize d1; // expected-error {{property synthesize requires specification of an ivar}}
- at dynamic bad; // expected-error {{property implementation must have its declaration in the class 'I'}}
- at synthesize prop_id; // expected-error {{property synthesize requires specification of an ivar}}
+ at synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}}
+ at dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}}
+ at synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}}
@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' does not match type of ivar 'IVAR'}}
+ at synthesize name; // OK! property with same name as an accessible ivar of same name
@end
@implementation I(CAT)
@@ -25,7 +28,7 @@
@end
@implementation E // expected-warning {{cannot find interface declaration for 'E'}}
- at dynamic d; // expected-error {{property implementation must have its declaration in the class 'E'}}
+ at dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}}
@end
@implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}}
More information about the cfe-commits
mailing list