diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2019-05-18 08:27:24 +0000 |
---|---|---|
committer | Iain Sandoe <iains@gcc.gnu.org> | 2019-05-18 08:27:24 +0000 |
commit | 5219955ccd44eaca6fd12b39acafc24c04602e97 (patch) | |
tree | 3377ebdc1bfccee1b67415ffb232730595a1937b /gcc/objc/objc-act.h | |
parent | c141668376b558228712f643ec643c94765c5e6c (diff) | |
download | gcc-5219955ccd44eaca6fd12b39acafc24c04602e97.zip gcc-5219955ccd44eaca6fd12b39acafc24c04602e97.tar.gz gcc-5219955ccd44eaca6fd12b39acafc24c04602e97.tar.bz2 |
objective-c - add instancetype.
The instancetype has been added as a typedef alias to id
in order to allow diagnosis of cases where a class is used
or returned where an instance is expected.
This adds the typedef, and tests that we can parse it.
It doesn't alter the diagnostics yet.
gcc/objc/
2019-05-18 Iain Sandoe <iain@sandoe.co.uk>
* objc/objc-act.h (OCTI_INSTANCE_TYPE, OCTI_INSTANCETYPE_NAME): New.
(objc_global_trees): Add instance type and name.
(INSTANCE_TYPEDEF_NAME): New.
* objc/objc-act.c (synth_module_prologue): Build decls for
objc_instancetype_type and objc_instancetype_name.
gcc/testsuite/
2019-05-18 Iain Sandoe <iain@sandoe.co.uk>
* objc.dg/instancetype-0.m: New.
From-SVN: r271370
Diffstat (limited to 'gcc/objc/objc-act.h')
-rw-r--r-- | gcc/objc/objc-act.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index 5794cdf..3b69043 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -313,6 +313,7 @@ enum objc_tree_index OCTI_SUPER_TYPE, OCTI_SEL_TYPE, OCTI_ID_TYPE, + OCTI_INSTANCE_TYPE, OCTI_CLS_TYPE, OCTI_NST_TYPE, OCTI_PROTO_TYPE, @@ -368,6 +369,7 @@ enum objc_tree_index OCTI_OBJ_ID, OCTI_CLS_ID, OCTI_ID_NAME, + OCTI_INSTANCETYPE_NAME, OCTI_CLASS_NAME, OCTI_CNST_STR_ID, OCTI_CNST_STR_TYPE, @@ -443,6 +445,7 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX]; #define objc_super_type objc_global_trees[OCTI_SUPER_TYPE] #define objc_selector_type objc_global_trees[OCTI_SEL_TYPE] #define objc_object_type objc_global_trees[OCTI_ID_TYPE] +#define objc_instancetype_type objc_global_trees[OCTI_INSTANCE_TYPE] #define objc_class_type objc_global_trees[OCTI_CLS_TYPE] #define objc_instance_type objc_global_trees[OCTI_NST_TYPE] #define objc_protocol_type objc_global_trees[OCTI_PROTO_TYPE] @@ -570,7 +573,8 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX]; #define objc_object_id objc_global_trees[OCTI_OBJ_ID] #define objc_class_id objc_global_trees[OCTI_CLS_ID] -#define objc_object_name objc_global_trees[OCTI_ID_NAME] +#define objc_object_name objc_global_trees[OCTI_ID_NAME] +#define objc_instancetype_name objc_global_trees[OCTI_INSTANCETYPE_NAME] #define objc_class_name objc_global_trees[OCTI_CLASS_NAME] /* Constant string classes. */ @@ -608,6 +612,7 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX]; /* Reserved tag definitions. */ #define OBJECT_TYPEDEF_NAME "id" +#define INSTANCE_TYPEDEF_NAME "instancetype" #define CLASS_TYPEDEF_NAME "Class" #define TAG_OBJECT "objc_object" |