This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix PR ada/21952
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 13 Sep 2006 20:32:19 +0200
- Subject: Fix PR ada/21952
It's a regression present on mainline and 4.1 branch for Alpha platforms.
The Alpha back-end unconditionally uses a couple of machine-independent
attributes that originally come from the C family of languages, leading to a
flood of warnings for the Ada compiler.
This is fixed by adding minimal support for these attributes to Gigi.
Bootstrapped/regtested on i586-suse-linux, applied to the mainline and 4.1
branch.
2006-09-13 Eric Botcazou <ebotcazou@adacore.com>
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.
--
Eric Botcazou
Index: gigi.h
===================================================================
RCS file: /gnat.dev/cvs/Dev/gnat/gigi.h,v
retrieving revision 1.20.2.41
retrieving revision 1.20.2.42
diff -u -r1.20.2.41 -r1.20.2.42
--- gigi.h 4 Mar 2006 18:18:19 -0000 1.20.2.41
+++ gigi.h 17 Mar 2006 11:25:59 -0000 1.20.2.42
@@ -309,7 +309,6 @@
type whose bit width is Pmode. Assume "long" is such a type here. */
#undef SIZE_TYPE
#define SIZE_TYPE "long int"
-
/* Data structures used to represent attributes. */
@@ -332,6 +331,9 @@
Node_Id error_point;
};
+/* Table of machine-independent internal attributes. */
+extern const struct attribute_spec gnat_internal_attribute_table[];
+
/* Define the entries in the standard data array. */
enum standard_datatypes
{
Index: misc.c
===================================================================
RCS file: /gnat.dev/cvs/Dev/gnat/misc.c,v
retrieving revision 1.44.2.70
retrieving revision 1.44.2.71
diff -u -p -r1.44.2.70 -r1.44.2.71
--- misc.c 14 Feb 2006 22:18:15 -0000 1.44.2.70
+++ misc.c 17 Mar 2006 11:26:02 -0000 1.44.2.71
@@ -158,6 +158,8 @@ static tree gnat_type_max_size (tree);
#define LANG_HOOKS_UNSIGNED_TYPE gnat_unsigned_type
#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE gnat_signed_or_unsigned_type
+#undef LANG_HOOKS_ATTRIBUTE_TABLE
+#define LANG_HOOKS_ATTRIBUTE_TABLE gnat_internal_attribute_table
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
Index: utils.c
===================================================================
RCS file: /gnat.dev/cvs/Dev/gnat/utils.c,v
retrieving revision 1.48.2.112
retrieving revision 1.48.2.113
diff -u -p -r1.48.2.112 -r1.48.2.113
--- utils.c 15 Mar 2006 08:01:31 -0000 1.48.2.112
+++ utils.c 17 Mar 2006 11:26:07 -0000 1.48.2.113
@@ -79,6 +79,21 @@ tree gnat_raise_decls[(int) LAST_REASON_
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. */
@@ -1844,11 +1859,48 @@ builtin_function (const char *name, tree
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. */