From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 23D6F3857719; Thu, 8 Jun 2023 10:42:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23D6F3857719 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686220978; bh=SfWm1wfNgYDxsl1oLygdbHCZivXRO1QMiX8NqMhAWEo=; h=From:To:Subject:Date:From; b=dQtPeM4UXALZS8MRJX6dJ4+81zsHShvxxtr8oUab7Q7dUgXaKYKR+SKqJ+7NZOP+r MV+ZGnxZOafXtngolXETOjbhZzHr2bqUXOMRtElGtzVCIjuzxvSa9QOnSyJmYueCfQ +UHFODxTwkmMOqtTLcsUThlcGL0CSHLW/bPvO6K0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] Expose expected_throw attribute (Ada) X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: 772cf7f81d182b557fc85a56a15af0db5196517b X-Git-Newrev: d74bd65cf3d148e78c7b06f96b7f0ee0588ba2e7 Message-Id: <20230608104258.23D6F3857719@sourceware.org> Date: Thu, 8 Jun 2023 10:42:58 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d74bd65cf3d148e78c7b06f96b7f0ee0588ba2e7 commit d74bd65cf3d148e78c7b06f96b7f0ee0588ba2e7 Author: Alexandre Oliva Date: Thu Jun 8 01:35:14 2023 -0300 Expose expected_throw attribute (Ada) Enable marking subprograms as expected_throw with Machine_Attribute pragmas. for gcc/ada/gcc-interface/ChangeLog * utils.cc (handle_expected_throw_attribute): New. (gnat_internal_attribute_table): Add expected_throw. Diff: --- gcc/ada/gcc-interface/utils.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index 8f1861b848e..d0a13d2af33 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -87,6 +87,7 @@ tree gnat_raise_decls_ext[(int) LAST_REASON_CODE + 1]; /* Forward declarations for handlers of attributes. */ static tree handle_const_attribute (tree *, tree, tree, int, bool *); static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *); +static tree handle_expected_throw_attribute (tree *, tree, tree, int, bool *); static tree handle_pure_attribute (tree *, tree, tree, int, bool *); static tree handle_novops_attribute (tree *, tree, tree, int, bool *); static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *); @@ -143,6 +144,8 @@ const struct attribute_spec gnat_internal_attribute_table[] = handle_const_attribute, NULL }, { "nothrow", 0, 0, true, false, false, false, handle_nothrow_attribute, NULL }, + { "expected_throw", 0, 0, true, false, false, false, + handle_expected_throw_attribute, NULL }, { "pure", 0, 0, true, false, false, false, handle_pure_attribute, NULL }, { "no vops", 0, 0, true, false, false, false, @@ -6379,6 +6382,22 @@ handle_nothrow_attribute (tree *node, tree ARG_UNUSED (name), return NULL_TREE; } +/* Handle a "expected_throw" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_expected_throw_attribute (tree *node, tree ARG_UNUSED (name), + tree ARG_UNUSED (args), int ARG_UNUSED (flags), + bool *no_add_attrs) +{ + if (TREE_CODE (*node) == FUNCTION_DECL) + /* No flag to set here. */; + else + *no_add_attrs = true; + + return NULL_TREE; +} + /* Handle a "pure" attribute; arguments as in struct attribute_spec.handler. */