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.c | |
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.c')
-rw-r--r-- | gcc/objc/objc-act.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 7ee3306..2173092 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -2950,12 +2950,14 @@ synth_module_prologue (void) objc_class_reference = xref_tag (RECORD_TYPE, objc_class_id); objc_object_type = build_pointer_type (objc_object_reference); + objc_instancetype_type = build_pointer_type (objc_object_reference); objc_class_type = build_pointer_type (objc_class_reference); objc_object_name = get_identifier (OBJECT_TYPEDEF_NAME); + objc_instancetype_name = get_identifier (INSTANCE_TYPEDEF_NAME); objc_class_name = get_identifier (CLASS_TYPEDEF_NAME); - /* Declare the 'id' and 'Class' typedefs. */ + /* Declare the 'id', 'instancetype' and 'Class' typedefs. */ type = lang_hooks.decls.pushdecl (build_decl (input_location, TYPE_DECL, objc_object_name, @@ -2964,6 +2966,12 @@ synth_module_prologue (void) type = lang_hooks.decls.pushdecl (build_decl (input_location, TYPE_DECL, + objc_instancetype_name, + objc_instancetype_type)); + TREE_NO_WARNING (type) = 1; + + type = lang_hooks.decls.pushdecl (build_decl (input_location, + TYPE_DECL, objc_class_name, objc_class_type)); TREE_NO_WARNING (type) = 1; |