aboutsummaryrefslogtreecommitdiff
path: root/gcc/objc
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2020-11-04 23:52:12 +0000
committerIain Sandoe <iain@sandoe.co.uk>2020-11-08 09:38:38 +0000
commitb642fca1c31b2e2175e0860daf32b4ee0d918085 (patch)
tree9fe0006f6338261f7e93d465a09686a2010e0119 /gcc/objc
parent49393e266a2570cb6227777acd4674f922c8a26b (diff)
downloadgcc-b642fca1c31b2e2175e0860daf32b4ee0d918085.zip
gcc-b642fca1c31b2e2175e0860daf32b4ee0d918085.tar.gz
gcc-b642fca1c31b2e2175e0860daf32b4ee0d918085.tar.bz2
Objective-C/C++ : Handle parsing @property 'class' attribute.
This attribute states that a property is one manipulated by class methods (it requires a static variable and the setter and getter must be provided explicitly, they cannot be @synthesized). gcc/c-family/ChangeLog: * c-common.h (OBJC_IS_PATTR_KEYWORD): Add class to the list of keywords accepted in @property attribute contexts. * c-objc.h (enum objc_property_attribute_group): Add OBJC_PROPATTR_GROUP_CLASS. (enum objc_property_attribute_kind): Add OBJC_PROPERTY_ATTR_CLASS. gcc/cp/ChangeLog: * parser.c (cp_parser_objc_at_property_declaration): Handle class keywords in @property attribute context. gcc/objc/ChangeLog: * objc-act.c (objc_prop_attr_kind_for_rid): Handle class attribute. (objc_add_property_declaration): Likewise. * objc-act.h (PROPERTY_CLASS): Record class attribute state. gcc/testsuite/ChangeLog: * obj-c++.dg/property/at-property-4.mm: Test handling class attributes. * objc.dg/property/at-property-4.m: Likewise.
Diffstat (limited to 'gcc/objc')
-rw-r--r--gcc/objc/objc-act.c10
-rw-r--r--gcc/objc/objc-act.h4
2 files changed, 14 insertions, 0 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 2dad46a..b9ed32d 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -825,6 +825,7 @@ objc_prop_attr_kind_for_rid (enum rid prop_rid)
case RID_PROPATOMIC: return OBJC_PROPERTY_ATTR_ATOMIC;
case RID_NONATOMIC: return OBJC_PROPERTY_ATTR_NONATOMIC;
+ case RID_CLASS: return OBJC_PROPERTY_ATTR_CLASS;
}
}
@@ -986,6 +987,14 @@ objc_add_property_declaration (location_t location, tree decl,
gcc_unreachable ();
}
+ /* An attribute that indicates this property manipulates a class variable.
+ In this case, both the variable and the getter/setter must be provided
+ by the user. */
+ bool property_class = false;
+ if (attrs[OBJC_PROPATTR_GROUP_CLASS])
+ property_nonatomic = attrs[OBJC_PROPATTR_GROUP_CLASS]->prop_kind
+ == OBJC_PROPERTY_ATTR_CLASS;
+
/* TODO: Check that the property type is an Objective-C object or a
"POD". */
@@ -1273,6 +1282,7 @@ objc_add_property_declaration (location_t location, tree decl,
PROPERTY_SETTER_NAME (property_decl) = property_setter_ident;
PROPERTY_READONLY (property_decl) = property_readonly;
PROPERTY_NONATOMIC (property_decl) = property_nonatomic;
+ PROPERTY_CLASS (property_decl) = property_class;
PROPERTY_ASSIGN_SEMANTICS (property_decl) = property_assign_semantics;
PROPERTY_IVAR_NAME (property_decl) = NULL_TREE;
PROPERTY_DYNAMIC (property_decl) = 0;
diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h
index db71b6a..5b0433f 100644
--- a/gcc/objc/objc-act.h
+++ b/gcc/objc/objc-act.h
@@ -137,6 +137,10 @@ enum objc_property_assign_semantics {
#define PROPERTY_OPTIONAL(DECL) \
DECL_LANG_FLAG_5 (PROPERTY_DECL_CHECK (DECL))
+/* PROPERTY_CLASS can be 0 or 1. */
+#define PROPERTY_CLASS(DECL) \
+ DECL_LANG_FLAG_6 (PROPERTY_DECL_CHECK (DECL))
+
/* PROPERTY_REF. A PROPERTY_REF represents an 'object.property'
expression. It is normally used for property access, but when
the Objective-C 2.0 "dot-syntax" (object.component) is used