Objective-C/C++ (C-family) : Add missing 'atomic' property attribute.
authorIain Sandoe <iain@sandoe.co.uk>
Mon, 2 Nov 2020 21:12:38 +0000 (21:12 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Sat, 7 Nov 2020 11:50:23 +0000 (11:50 +0000)
This is the default, but it is still legal in user code and therefore
we should handle it in parsing.  Fix whitespace issues in the lines
affected.

gcc/c-family/ChangeLog:

* c-common.c (c_common_reswords): Add 'atomic' property
attribute.
* c-common.h (enum rid): Add RID_PROPATOMIC for atomic
property attributes.

gcc/objc/ChangeLog:

* objc-act.c (objc_prop_attr_kind_for_rid): Handle
RID_PROPATOMIC.

gcc/testsuite/ChangeLog:

* obj-c++.dg/property/at-property-4.mm: Test atomic property
attribute.
* objc.dg/property/at-property-4.m: Likewise.

gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/objc/objc-act.c
gcc/testsuite/obj-c++.dg/property/at-property-4.mm
gcc/testsuite/objc.dg/property/at-property-4.m

index 9302a2461d4af98749bee9abe0e9f15cf2d678e4..d4d3228b8f637e187a911e3cfb52e463373e8286 100644 (file)
@@ -571,14 +571,15 @@ const struct c_common_resword c_common_reswords[] =
   { "oneway",          RID_ONEWAY,             D_OBJC },
   { "out",             RID_OUT,                D_OBJC },
   /* These are recognized inside a property attribute list */
-  { "assign",          RID_ASSIGN,             D_OBJC }, 
-  { "copy",            RID_COPY,               D_OBJC }, 
-  { "getter",          RID_GETTER,             D_OBJC }, 
-  { "nonatomic",       RID_NONATOMIC,          D_OBJC }, 
-  { "readonly",                RID_READONLY,           D_OBJC }, 
-  { "readwrite",       RID_READWRITE,          D_OBJC }, 
-  { "retain",          RID_RETAIN,             D_OBJC }, 
-  { "setter",          RID_SETTER,             D_OBJC }, 
+  { "assign",          RID_ASSIGN,             D_OBJC },
+  { "atomic",          RID_PROPATOMIC,         D_OBJC },
+  { "copy",            RID_COPY,               D_OBJC },
+  { "getter",          RID_GETTER,             D_OBJC },
+  { "nonatomic",       RID_NONATOMIC,          D_OBJC },
+  { "readonly",                RID_READONLY,           D_OBJC },
+  { "readwrite",       RID_READWRITE,          D_OBJC },
+  { "retain",          RID_RETAIN,             D_OBJC },
+  { "setter",          RID_SETTER,             D_OBJC },
 };
 
 const unsigned int num_c_common_reswords =
index 18b489d55a3418cd4bf04c039143b96118fabd1c..7e2cd5342aa6db3d7219ba2ec216cd4adb16a227 100644 (file)
@@ -85,7 +85,7 @@ enum rid
   RID_GETTER, RID_SETTER,
   RID_READONLY, RID_READWRITE,
   RID_ASSIGN, RID_RETAIN, RID_COPY,
-  RID_NONATOMIC,
+  RID_PROPATOMIC, RID_NONATOMIC,
 
   /* C (reserved and imaginary types not implemented, so any use is a
      syntax error) */
index 8be4beadf3bccd7f7d61d2a485836cf665da729b..2dad46aa77e6fe4f11d57ea7b2190a30fa890339 100644 (file)
@@ -822,6 +822,7 @@ objc_prop_attr_kind_for_rid (enum rid prop_rid)
       case RID_RETAIN:         return OBJC_PROPERTY_ATTR_RETAIN;
       case RID_COPY:           return OBJC_PROPERTY_ATTR_COPY;
 
+      case RID_PROPATOMIC:     return OBJC_PROPERTY_ATTR_ATOMIC;
       case RID_NONATOMIC:      return OBJC_PROPERTY_ATTR_NONATOMIC;
 
     }
index 4083947de71d3cab5e7d43a3fd54e0aaf5b9e612..31f2eb4336ab246f9d578f09dd0d6f7c73ac6535 100644 (file)
@@ -16,6 +16,7 @@
 /* Test that all the new property attributes can be parsed.  */
 @property (assign)    id property_a;
 @property (copy)      id property_b;
+@property (atomic)    int property_ca;
 @property (nonatomic) int property_c;
 @property (readonly)  int property_d;
 @property (readwrite) int property_e;
@@ -34,6 +35,8 @@
 @property (assign, copy) id d;            /* { dg-error ".copy. attribute conflicts with .assign. attribute" } */
 @property (copy, retain) id e;            /* { dg-error ".retain. attribute conflicts with .copy. attribute" } */
 
+@property (atomic, nonatomic) int property_j; /* { dg-error {'nonatomic' attribute conflicts with 'atomic' attribute} } */
+
 @property (setter=mySetter:,setter=mySetter2:)  int f; /* { dg-warning {multiple property 'setter' methods specified, the latest one will be used} } */
 @property (getter=myGetter, getter=myGetter2 )  int g; /* { dg-warning {multiple property 'getter' methods specified, the latest one will be used} } */
 
index 4083947de71d3cab5e7d43a3fd54e0aaf5b9e612..31f2eb4336ab246f9d578f09dd0d6f7c73ac6535 100644 (file)
@@ -16,6 +16,7 @@
 /* Test that all the new property attributes can be parsed.  */
 @property (assign)    id property_a;
 @property (copy)      id property_b;
+@property (atomic)    int property_ca;
 @property (nonatomic) int property_c;
 @property (readonly)  int property_d;
 @property (readwrite) int property_e;
@@ -34,6 +35,8 @@
 @property (assign, copy) id d;            /* { dg-error ".copy. attribute conflicts with .assign. attribute" } */
 @property (copy, retain) id e;            /* { dg-error ".retain. attribute conflicts with .copy. attribute" } */
 
+@property (atomic, nonatomic) int property_j; /* { dg-error {'nonatomic' attribute conflicts with 'atomic' attribute} } */
+
 @property (setter=mySetter:,setter=mySetter2:)  int f; /* { dg-warning {multiple property 'setter' methods specified, the latest one will be used} } */
 @property (getter=myGetter, getter=myGetter2 )  int g; /* { dg-warning {multiple property 'getter' methods specified, the latest one will be used} } */