]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ada/21952 (Annoying "attribute directive ignored" warnings)
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 13 Sep 2006 18:27:24 +0000 (18:27 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 13 Sep 2006 18:27:24 +0000 (18:27 +0000)
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

gcc/ada/ChangeLog
gcc/ada/gigi.h
gcc/ada/misc.c
gcc/ada/utils.c

index f7a0d9f26037c215bd229d6594dd7e4193e2f71f..fd8318b73f16004af2566710d5f63dd216f3005d 100644 (file)
@@ -1,3 +1,13 @@
+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.
+
 2006-07-28  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        * Make-lang.in: Use $(HEADER_H) instead of header.h in dependencies.
index e1661290f723ded1782e666ebf143747f253926c..43d46f6ad0240510807cfd56427fbc614b848b50 100644 (file)
@@ -309,7 +309,6 @@ extern int force_global;
    type whose bit width is Pmode.  Assume "long" is such a type here.  */
 #undef SIZE_TYPE
 #define SIZE_TYPE "long int"
-
 \f
 /* Data structures used to represent attributes.  */
 
@@ -332,6 +331,9 @@ struct attrib
   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 47206da7e8699b86f84d4affb4f9cebbb580c8a3..11bd27bd58371070e04d83f3c6ad93cc59c3ea7b 100644 (file)
@@ -161,6 +161,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 1bdfacf09bcfbd113d5584c16ef17343559c0180..c59a33e9b4f5d7f9203b11ab106b71061e1da06e 100644 (file)
@@ -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.  */