aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2006-09-13 18:27:24 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2006-09-13 18:27:24 +0000
commit2655f1c6dd3b1a1db7453065a0bb67f30d4552ad (patch)
tree2e239ba8769813341c27af38aed2f2c2f2f5459f /gcc/ada/utils.c
parentf66fd328ce6453b71f117eed42dad270e3c2bcaa (diff)
downloadgcc-2655f1c6dd3b1a1db7453065a0bb67f30d4552ad.zip
gcc-2655f1c6dd3b1a1db7453065a0bb67f30d4552ad.tar.gz
gcc-2655f1c6dd3b1a1db7453065a0bb67f30d4552ad.tar.bz2
re PR ada/21952 (Annoying "attribute directive ignored" warnings)
PR ada/21952 * gigi.h (gnat_internal_attribute_table): Declare. * misc.c (LANG_HOOKS_ATTRIBUTE_TABLE): Define to above. * utils.c (gnat_internal_attribute_table): New global variable. (builtin_function): Always call decl_attributes on the builtin. (handle_const_attribute): New static function. (handle_nothrow_attribute): Likewise. From-SVN: r116926
Diffstat (limited to 'gcc/ada/utils.c')
-rw-r--r--gcc/ada/utils.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c
index 1bdfacf0..c59a33e 100644
--- a/gcc/ada/utils.c
+++ b/gcc/ada/utils.c
@@ -79,6 +79,21 @@ tree gnat_raise_decls[(int) LAST_REASON_CODE + 1];
tree static_ctors;
tree static_dtors;
+/* 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 *);
+
+/* Table of machine-independent internal attributes for Ada. We support
+ this minimal set ot attributes to accomodate the Alpha back-end which
+ unconditionally puts them on its builtins. */
+const struct attribute_spec gnat_internal_attribute_table[] =
+{
+ /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
+ { "const", 0, 0, true, false, false, handle_const_attribute },
+ { "nothrow", 0, 0, true, false, false, handle_nothrow_attribute },
+ { NULL, 0, 0, false, false, false, NULL }
+};
+
/* Associates a GNAT tree node to a GCC tree node. It is used in
`save_gnu_tree', `get_gnu_tree' and `present_gnu_tree'. See documentation
of `save_gnu_tree' for more info. */
@@ -1826,11 +1841,48 @@ builtin_function (const char *name, tree type, int function_code,
gnat_pushdecl (decl, Empty);
DECL_BUILT_IN_CLASS (decl) = class;
DECL_FUNCTION_CODE (decl) = function_code;
+
+ /* Possibly apply some default attributes to this built-in function. */
if (attrs)
- decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN);
+ decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN);
+ else
+ decl_attributes (&decl, NULL_TREE, 0);
+
return decl;
}
+/* Handle a "const" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_const_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)
+ TREE_READONLY (*node) = 1;
+ else
+ *no_add_attrs = true;
+
+ return NULL_TREE;
+}
+
+/* Handle a "nothrow" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_nothrow_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)
+ TREE_NOTHROW (*node) = 1;
+ else
+ *no_add_attrs = true;
+
+ return NULL_TREE;
+}
+
/* Return an integer type with the number of bits of precision given by
PRECISION. UNSIGNEDP is nonzero if the type is unsigned; otherwise
it is a signed type. */