From patchwork Sun Nov 1 20:31:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1391830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CPSPm02qnz9sVK for ; Mon, 2 Nov 2020 07:31:39 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 74BC2384B00F; Sun, 1 Nov 2020 20:31:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp1.wavenetuk.net (smtp.wavenetuk.net [195.26.36.10]) by sourceware.org (Postfix) with ESMTP id C931B3858D37 for ; Sun, 1 Nov 2020 20:31:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C931B3858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=iain@sandoe.co.uk Received: from [192.168.1.212] (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp1.wavenetuk.net (Postfix) with ESMTPA id 3D58D1204F50 for ; Sun, 1 Nov 2020 20:31:34 +0000 (GMT) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [pushed] Objective-C : Implement SEL as a built-in typedef. Message-Id: <04A92747-F4E9-4A52-A5C6-FAB76A6FC170@sandoe.co.uk> Date: Sun, 1 Nov 2020 20:31:21 +0000 To: GCC Patches X-Mailer: Apple Mail (2.3273) X-Spam-Status: No, score=-16.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi The reference implementation for Objective-C provides the SEL typedef (although it is also available from ). tested on x86_64-darwin, x86_64-linux-gnu pushed thanks Iain gcc/objc/ChangeLog: * objc-act.c (synth_module_prologue): Get the SEL identifier. * objc-act.h (enum objc_tree_index): Add OCTI_SEL_NAME. (objc_selector_name): New. (SEL_TYPEDEF_NAME): New. * objc-gnu-runtime-abi-01.c (gnu_runtime_01_initialize): Initialize SEL typedef. * objc-next-runtime-abi-01.c (next_runtime_01_initialize): Likewise. * objc-next-runtime-abi-02.c gcc/testsuite/ChangeLog: * obj-c++.dg/SEL-typedef.mm: New test. * objc.dg/SEL-typedef.m: New test. --- gcc/objc/objc-act.c | 1 + gcc/objc/objc-act.h | 3 +++ gcc/objc/objc-gnu-runtime-abi-01.c | 7 +++++++ gcc/objc/objc-next-runtime-abi-01.c | 7 +++++++ gcc/objc/objc-next-runtime-abi-02.c | 7 +++++++ gcc/testsuite/obj-c++.dg/SEL-typedef.mm | 7 +++++++ gcc/testsuite/objc.dg/SEL-typedef.m | 7 +++++++ 7 files changed, 39 insertions(+) create mode 100644 gcc/testsuite/obj-c++.dg/SEL-typedef.mm create mode 100644 gcc/testsuite/objc.dg/SEL-typedef.m diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 31a2cf3753f..0393bc44500 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -2954,6 +2954,7 @@ synth_module_prologue (void) objc_object_name = get_identifier (OBJECT_TYPEDEF_NAME); objc_instancetype_name = get_identifier (INSTANCE_TYPEDEF_NAME); objc_class_name = get_identifier (CLASS_TYPEDEF_NAME); + objc_selector_name = get_identifier (SEL_TYPEDEF_NAME); /* Declare the 'id', 'instancetype' and 'Class' typedefs. */ type = lang_hooks.decls.pushdecl (build_decl (input_location, diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index 913e152fdeb..db71b6a265e 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -371,6 +371,7 @@ enum objc_tree_index OCTI_ID_NAME, OCTI_INSTANCETYPE_NAME, OCTI_CLASS_NAME, + OCTI_SEL_NAME, OCTI_CNST_STR_ID, OCTI_CNST_STR_TYPE, OCTI_CNST_STR_GLOB_ID, @@ -576,6 +577,7 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX]; #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] +#define objc_selector_name objc_global_trees[OCTI_SEL_NAME] /* Constant string classes. */ #define constant_string_id objc_global_trees[OCTI_CNST_STR_ID] @@ -614,6 +616,7 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX]; #define OBJECT_TYPEDEF_NAME "id" #define INSTANCE_TYPEDEF_NAME "instancetype" #define CLASS_TYPEDEF_NAME "Class" +#define SEL_TYPEDEF_NAME "SEL" #define TAG_OBJECT "objc_object" #define TAG_CLASS "objc_class" diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c index 25c0e01e157..ac9a8626f40 100644 --- a/gcc/objc/objc-gnu-runtime-abi-01.c +++ b/gcc/objc/objc-gnu-runtime-abi-01.c @@ -208,6 +208,13 @@ static void gnu_runtime_01_initialize (void) type = build_qualified_type (type, TYPE_QUAL_CONST); objc_selector_type = build_pointer_type (type); + /* SEL typedef. */ + type = lang_hooks.decls.pushdecl (build_decl (input_location, + TYPE_DECL, + objc_selector_name, + objc_selector_type)); + TREE_NO_WARNING (type) = 1; + /* typedef id (*IMP)(id, SEL, ...); */ ftype = build_varargs_function_type_list (objc_object_type, objc_object_type, diff --git a/gcc/objc/objc-next-runtime-abi-01.c b/gcc/objc/objc-next-runtime-abi-01.c index 233d89e75b5..7fc449bab41 100644 --- a/gcc/objc/objc-next-runtime-abi-01.c +++ b/gcc/objc/objc-next-runtime-abi-01.c @@ -277,6 +277,13 @@ static void next_runtime_01_initialize (void) objc_selector_type = build_pointer_type (xref_tag (RECORD_TYPE, get_identifier (TAG_SELECTOR))); + /* SEL typedef. */ + type = lang_hooks.decls.pushdecl (build_decl (input_location, + TYPE_DECL, + objc_selector_name, + objc_selector_type)); + TREE_NO_WARNING (type) = 1; + build_v1_class_template (); build_super_template (); build_v1_protocol_template (); diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index d7812ffc981..f3c285a937b 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -374,6 +374,13 @@ static void next_runtime_02_initialize (void) objc_selector_type = build_pointer_type (xref_tag (RECORD_TYPE, get_identifier (TAG_SELECTOR))); + /* SEL typedef. */ + type = lang_hooks.decls.pushdecl (build_decl (input_location, + TYPE_DECL, + objc_selector_name, + objc_selector_type)); + TREE_NO_WARNING (type) = 1; + /* IMP : id (*) (id, _message_ref_t*, ...) SUPER_IMP : id (*) ( super_t*, _super_message_ref_t*, ...) objc_v2_selector_type. */ diff --git a/gcc/testsuite/obj-c++.dg/SEL-typedef.mm b/gcc/testsuite/obj-c++.dg/SEL-typedef.mm new file mode 100644 index 00000000000..2ece1fd46cd --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/SEL-typedef.mm @@ -0,0 +1,7 @@ +/* Check that we accept the SEL typedef. */ +/* { dg-additional-options "-fsyntax-only " } */ + +SEL aSelector; + +typedef SEL MySEL; + diff --git a/gcc/testsuite/objc.dg/SEL-typedef.m b/gcc/testsuite/objc.dg/SEL-typedef.m new file mode 100644 index 00000000000..2ece1fd46cd --- /dev/null +++ b/gcc/testsuite/objc.dg/SEL-typedef.m @@ -0,0 +1,7 @@ +/* Check that we accept the SEL typedef. */ +/* { dg-additional-options "-fsyntax-only " } */ + +SEL aSelector; + +typedef SEL MySEL; +