target.h (struct gcc_target): Add insert_attributes.
authorJoseph Myers <jsm28@cam.ac.uk>
Sun, 8 Jul 2001 20:05:17 +0000 (21:05 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sun, 8 Jul 2001 20:05:17 +0000 (21:05 +0100)
* target.h (struct gcc_target): Add insert_attributes.
* target-def.h (TARGET_INSERT_ATTRIBUTES): Define.
(TARGET_INITIALIZER): Update.
* tree.c, tree.h (default_insert_attributes): New function.
Update comments on other default functions to refer to targetm,
not target.
* doc/tm.texi (INSERT_ATTRIBUTES): Update to document
TARGET_INSERT_ATTRIBUTES.
(SET_DEFAULT_DECL_ATTRIBUTES): Remove.
* c-common.c (decl_attributes): Use targetm.insert_attributes.
Don't use PRAGMA_INSERT_ATTRIBUTES.
* Makefile.in (c-common.o): Depend on $(TARGET_H).
* c-decl.c (start_decl, start_function): Don't call
SET_DEFAULT_DECL_ATTRIBUTES.
* config/c4x/c4x.h (SET_DEFAULT_DECL_ATTRIBUTES): Don't define.
* config/c4x/c4x-protos.h (c4x_set_default_attributes): Don't
declare.
* config/c4x/c4x.c (TARGET_INSERT_ATTRIBUTES): Define.
(c4x_check_attribute): Avoid modifying attribute list itself.
(c4x_set_default_attributes): Rename to c4x_insert_attributes.
Make static.
* config/sh/sh.h (PRAGMA_INSERT_ATTRIBUTES): Don't define.
* config/sh/sh-protos.h (sh_pragma_insert_attributes): Don't
declare.
* config/sh/sh.c (TARGET_INSERT_ATTRIBUTES): Define.
(sh_pragma_insert_attributes): Rename to sh_insert_attributes.
Make static.
* config/v850/v850.h (SET_DEFAULT_DECL_ATTRIBUTES): Don't define.
* config/v850/v850-protos.h (v850_set_default_decl_attr): Don't
declare.
* config/v850/v850.c (TARGET_INSERT_ATTRIBUTES): Define.
(v850_set_default_decl_attr): Rename to v850_insert_attributes.
Adjust parameters.  Make static.

cp:
* decl.c (start_decl): Don't call SET_DEFAULT_DECL_ATTRIBUTES.
(start_function): Don't call SET_DEFAULT_DECL_ATTRIBUTES.  Call
cplus_decl_attributes even if attrs is NULL.
* friend.c (do_friend): Don't call SET_DEFAULT_DECL_ATTRIBUTES.

From-SVN: r43851

21 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/c-common.c
gcc/c-decl.c
gcc/config/c4x/c4x-protos.h
gcc/config/c4x/c4x.c
gcc/config/c4x/c4x.h
gcc/config/sh/sh-protos.h
gcc/config/sh/sh.c
gcc/config/sh/sh.h
gcc/config/v850/v850-protos.h
gcc/config/v850/v850.c
gcc/config/v850/v850.h
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/friend.c
gcc/doc/tm.texi
gcc/target-def.h
gcc/target.h
gcc/tree.c
gcc/tree.h

index 9269546..0dae078 100644 (file)
@@ -1,5 +1,41 @@
 2001-07-08  Joseph S. Myers  <jsm28@cam.ac.uk>
 
+       * target.h (struct gcc_target): Add insert_attributes.
+       * target-def.h (TARGET_INSERT_ATTRIBUTES): Define.
+       (TARGET_INITIALIZER): Update.
+       * tree.c, tree.h (default_insert_attributes): New function.
+       Update comments on other default functions to refer to targetm,
+       not target.
+       * doc/tm.texi (INSERT_ATTRIBUTES): Update to document
+       TARGET_INSERT_ATTRIBUTES.
+       (SET_DEFAULT_DECL_ATTRIBUTES): Remove.
+       * c-common.c (decl_attributes): Use targetm.insert_attributes.
+       Don't use PRAGMA_INSERT_ATTRIBUTES.
+       * Makefile.in (c-common.o): Depend on $(TARGET_H).
+       * c-decl.c (start_decl, start_function): Don't call
+       SET_DEFAULT_DECL_ATTRIBUTES.
+       * config/c4x/c4x.h (SET_DEFAULT_DECL_ATTRIBUTES): Don't define.
+       * config/c4x/c4x-protos.h (c4x_set_default_attributes): Don't
+       declare.
+       * config/c4x/c4x.c (TARGET_INSERT_ATTRIBUTES): Define.
+       (c4x_check_attribute): Avoid modifying attribute list itself.
+       (c4x_set_default_attributes): Rename to c4x_insert_attributes.
+       Make static.
+       * config/sh/sh.h (PRAGMA_INSERT_ATTRIBUTES): Don't define.
+       * config/sh/sh-protos.h (sh_pragma_insert_attributes): Don't
+       declare.
+       * config/sh/sh.c (TARGET_INSERT_ATTRIBUTES): Define.
+       (sh_pragma_insert_attributes): Rename to sh_insert_attributes.
+       Make static.
+       * config/v850/v850.h (SET_DEFAULT_DECL_ATTRIBUTES): Don't define.
+       * config/v850/v850-protos.h (v850_set_default_decl_attr): Don't
+       declare.
+       * config/v850/v850.c (TARGET_INSERT_ATTRIBUTES): Define.
+       (v850_set_default_decl_attr): Rename to v850_insert_attributes.
+       Adjust parameters.  Make static.
+
+2001-07-08  Joseph S. Myers  <jsm28@cam.ac.uk>
+
        * c-common.c (decl_attributes): Only take a single attributes
        parameter.
        * c-common.h (decl_attributes): Update prototype.
index 84eaf0c..846ddea 100644 (file)
@@ -1236,7 +1236,7 @@ s-under: $(GCC_PASSES)
 
 c-common.o : c-common.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(OBSTACK_H) \
        $(C_COMMON_H) flags.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \
-       $(EXPR_H) $(TM_P_H) builtin-types.def
+       $(EXPR_H) $(TM_P_H) builtin-types.def $(TARGET_H)
 
 c-format.o : c-format.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
        $(C_COMMON_H) flags.h toplev.h intl.h diagnostic.h
index 2d56b9e..f1ee8b1 100644 (file)
@@ -33,6 +33,7 @@ Boston, MA 02111-1307, USA.  */
 #include "tm_p.h"
 #include "obstack.h"
 #include "cpplib.h"
+#include "target.h"
 cpp_reader *parse_in;          /* Declared in c-lex.h.  */
 
 #undef WCHAR_TYPE_SIZE
@@ -745,17 +746,7 @@ decl_attributes (node, attributes)
   else if (TYPE_P (node))
     type = node, is_type = 1;
 
-#ifdef PRAGMA_INSERT_ATTRIBUTES
-  /* If the code in c-pragma.c wants to insert some attributes then
-     allow it to do so.  Do this before allowing machine back ends to
-     insert attributes, so that they have the opportunity to override
-     anything done here.  */
-  PRAGMA_INSERT_ATTRIBUTES (node, & attributes);
-#endif
-
-#ifdef INSERT_ATTRIBUTES
-  INSERT_ATTRIBUTES (node, & attributes);
-#endif
+  (*targetm.insert_attributes) (node, &attributes);
 
   for (a = attributes; a; a = TREE_CHAIN (a))
     {
index eba9ee6..9d67d34 100644 (file)
@@ -3447,10 +3447,6 @@ start_decl (declarator, declspecs, initialized, attributes)
   if (! flag_no_common || ! TREE_PUBLIC (decl))
     DECL_COMMON (decl) = 1;
 
-#ifdef SET_DEFAULT_DECL_ATTRIBUTES
-  SET_DEFAULT_DECL_ATTRIBUTES (decl, attributes);
-#endif
-
   /* Set attributes here so if duplicate decl, will have proper attributes.  */
   decl_attributes (decl, attributes);
 
@@ -6021,10 +6017,6 @@ start_function (declspecs, declarator, attributes)
      except for defining how to inline.  So set DECL_EXTERNAL in that case.  */
   DECL_EXTERNAL (decl1) = current_extern_inline;
 
-#ifdef SET_DEFAULT_DECL_ATTRIBUTES
-  SET_DEFAULT_DECL_ATTRIBUTES (decl1, attributes);
-#endif
-
   /* This function exists in static storage.
      (This does not mean `static' in the C sense!)  */
   TREE_STATIC (decl1) = 1;
index 27bbbdb..44f47b6 100644 (file)
@@ -50,8 +50,6 @@ extern void c4x_external_ref (const char *);
 extern void c4x_file_end (FILE *);
 
 #ifdef TREE_CODE
-extern void c4x_set_default_attributes PARAMS ((tree, tree *));
-
 extern void c4x_function_arg_advance PARAMS ((CUMULATIVE_ARGS *, 
                                              enum machine_mode, tree, int));
 
index 6f75aa8..c0500be 100644 (file)
@@ -190,11 +190,15 @@ static int c4x_r11_set_p PARAMS ((rtx));
 static int c4x_rptb_valid_p PARAMS ((rtx, rtx));
 static int c4x_label_ref_used_p PARAMS ((rtx, rtx));
 static int c4x_valid_type_attribute_p PARAMS ((tree, tree, tree, tree));
+static void c4x_insert_attributes PARAMS ((tree, tree *));
 \f
 /* Initialize the GCC target structure.  */
 #undef TARGET_VALID_TYPE_ATTRIBUTE
 #define TARGET_VALID_TYPE_ATTRIBUTE c4x_valid_type_attribute_p
 
+#undef TARGET_INSERT_ATTRIBUTES
+#define TARGET_INSERT_ATTRIBUTES c4x_insert_attributes
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 /* Called to register all of our global variables with the garbage
@@ -4717,14 +4721,13 @@ c4x_check_attribute (attrib, list, decl, attributes)
         != IDENTIFIER_POINTER (DECL_NAME (decl)))
     list = TREE_CHAIN (list);
   if (list)
-    *attributes = chainon (*attributes,
-                          build_tree_list (get_identifier (attrib),
-                                           TREE_VALUE (list)));
+    *attributes = tree_cons (get_identifier (attrib), TREE_VALUE (list),
+                            *attributes);
 }
 
 
-void
-c4x_set_default_attributes(decl, attributes)
+static void
+c4x_insert_attributes (decl, attributes)
      tree decl, *attributes;
 {
   switch (TREE_CODE (decl))
index 9637526..b161d6d 100644 (file)
@@ -2443,9 +2443,6 @@ do {                                              \
   c4x_init_pragma (&c_lex);                                            \
 } while (0)
 
-#define SET_DEFAULT_DECL_ATTRIBUTES(DECL, ATTRIBUTES) \
-  c4x_set_default_attributes (DECL, &ATTRIBUTES)
-
 /* Assembler Commands for Alignment.  */
 
 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
index 4125e32..1200ba2 100644 (file)
@@ -105,7 +105,6 @@ extern rtx sh_va_arg PARAMS ((tree, tree));
 #endif /* RTX_CODE */
 
 #ifdef TREE_CODE
-extern void sh_pragma_insert_attributes PARAMS ((tree, tree *));
 extern tree sh_build_va_list PARAMS ((void));
 #endif /* TREE_CODE */
 
index d669840..b6885a7 100644 (file)
@@ -155,6 +155,7 @@ static HOST_WIDE_INT rounded_frame_size PARAMS ((int));
 static rtx mark_constant_pool_use PARAMS ((rtx));
 static int sh_valid_decl_attribute PARAMS ((tree, tree, tree, tree));
 static void sh_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
+static void sh_insert_attributes PARAMS ((tree, tree *));
 \f
 /* Initialize the GCC target structure.  */
 #undef TARGET_VALID_DECL_ATTRIBUTE
@@ -163,6 +164,9 @@ static void sh_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
 #undef TARGET_ASM_FUNCTION_EPILOGUE
 #define TARGET_ASM_FUNCTION_EPILOGUE sh_output_function_epilogue
 
+#undef TARGET_INSERT_ATTRIBUTES
+#define TARGET_INSERT_ATTRIBUTES sh_insert_attributes
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 /* Print the operand address in x to the stream.  */
@@ -4603,8 +4607,8 @@ sh_pr_nosave_low_regs (pfile)
 
 /* Generate 'handle_interrupt' attribute for decls */
 
-void
-sh_pragma_insert_attributes (node, attributes)
+static void
+sh_insert_attributes (node, attributes)
      tree node;
      tree * attributes;
 {
index 29393fd..3f6d3e6 100644 (file)
@@ -2293,9 +2293,6 @@ extern int current_function_interrupt;
    for interrupt functions.  */
 extern struct rtx_def *sp_switch;
 
-#define PRAGMA_INSERT_ATTRIBUTES(node, pattr) \
-  sh_pragma_insert_attributes (node, pattr)
-
 extern int rtx_equal_function_value_matters;
 extern struct rtx_def *fpscr_rtx;
 
index 9d6d08a..83622d4 100644 (file)
@@ -73,7 +73,6 @@ extern rtx    v850_va_arg                   PARAMS ((tree, tree));
 
 #ifdef TREE_CODE
 extern void   v850_encode_data_area         PARAMS ((tree));
-extern void   v850_set_default_decl_attr    PARAMS ((tree));
 extern int    v850_interrupt_function_p     PARAMS ((tree));
 extern void   v850_output_aligned_bss       PARAMS ((FILE *, tree, const char *, int, int));
 extern void   v850_output_common            PARAMS ((FILE *, tree, const char *, int, int));
index 10f33e2..2cbd115 100644 (file)
@@ -54,6 +54,7 @@ static void substitute_ep_register   PARAMS ((rtx, rtx, int, int, rtx *, rtx *))
 static int  ep_memory_offset         PARAMS ((enum machine_mode, int));
 static void v850_set_data_area       PARAMS ((tree, v850_data_area));
 static int v850_valid_decl_attribute PARAMS ((tree, tree, tree, tree));
+static void v850_insert_attributes   PARAMS ((tree, tree *));
 
 /* True if the current function has anonymous arguments.  */
 int current_function_anonymous_args;
@@ -86,6 +87,9 @@ static int v850_interrupt_p = FALSE;
 #undef TARGET_VALID_DECL_ATTRIBUTE
 #define TARGET_VALID_DECL_ATTRIBUTE v850_valid_decl_attribute
 
+#undef TARGET_INSERT_ATTRIBUTES
+#define TARGET_INSERT_ATTRIBUTES v850_insert_attributes
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 /* Sometimes certain combinations of command options do not make
@@ -2653,9 +2657,10 @@ v850_output_local (file, decl, name, size, align)
 
 /* Add data area to the given declaration if a ghs data area pragma is
    currently in effect (#pragma ghs startXXX/endXXX).  */
-void
-v850_set_default_decl_attr (decl)
+static void
+v850_insert_attributes (decl, attr_ptr)
      tree decl;
+     tree *attr_ptr ATTRIBUTE_UNUSED;
 {
   if (data_area_stack
       && data_area_stack->data_area
index bde4bb3..f2a7d7c 100644 (file)
@@ -1486,10 +1486,6 @@ do { char dstr[30];                                      \
    so give the MEM rtx a byte's mode.  */
 #define FUNCTION_MODE QImode
 
-/* A C statement that assigns default attributes to a newly created DECL.  */
-#define SET_DEFAULT_DECL_ATTRIBUTES(decl, attr) \
-     v850_set_default_decl_attr (decl)
-
 /* Tell compiler we want to support GHS pragmas */
 #define REGISTER_TARGET_PRAGMAS(PFILE) do {                              \
   cpp_register_pragma_space (PFILE, "ghs");                              \
index efdbccd..e07fd96 100644 (file)
@@ -1,5 +1,12 @@
 2001-07-08  Joseph S. Myers  <jsm28@cam.ac.uk>
 
+       * decl.c (start_decl): Don't call SET_DEFAULT_DECL_ATTRIBUTES.
+       (start_function): Don't call SET_DEFAULT_DECL_ATTRIBUTES.  Call
+       cplus_decl_attributes even if attrs is NULL.
+       * friend.c (do_friend): Don't call SET_DEFAULT_DECL_ATTRIBUTES.
+
+2001-07-08  Joseph S. Myers  <jsm28@cam.ac.uk>
+
        * decl.c (grokdeclarator), decl2.c (cplus_decl_attributes): Update
        calls to decl_attributes.
 
index c0f90b8..5de7150 100644 (file)
@@ -7220,10 +7220,6 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
       DECL_INITIAL (decl) = error_mark_node;
     }
 
-#ifdef SET_DEFAULT_DECL_ATTRIBUTES
-  SET_DEFAULT_DECL_ATTRIBUTES (decl, attributes);
-#endif
-
   /* Set attributes here so if duplicate decl, will have proper attributes.  */
   cplus_decl_attributes (decl, attributes, prefix_attributes);
 
@@ -13436,10 +13432,6 @@ start_function (declspecs, declarator, attrs, flags)
   if (!DECL_INITIAL (decl1))
     DECL_INITIAL (decl1) = error_mark_node;
 
-#ifdef SET_DEFAULT_DECL_ATTRIBUTES
-  SET_DEFAULT_DECL_ATTRIBUTES (decl1, attrs);
-#endif
-
   /* This function exists in static storage.
      (This does not mean `static' in the C sense!)  */
   TREE_STATIC (decl1) = 1;
@@ -13640,8 +13632,7 @@ start_function (declspecs, declarator, attrs, flags)
   pushlevel (0);
   current_binding_level->parm_flag = 1;
 
-  if (attrs)
-    cplus_decl_attributes (decl1, NULL_TREE, attrs);
+  cplus_decl_attributes (decl1, NULL_TREE, attrs);
 
   /* Promote the value to int before returning it.  */
   if (c_promoting_integer_type_p (restype))
index 8b2e8f8..c27a73e 100644 (file)
@@ -446,10 +446,6 @@ do_friend (ctype, declarator, decl, parmdecls, attrlist,
       prefix_attributes = NULL_TREE;
     } 
 
-#ifdef SET_DEFAULT_DECL_ATTRIBUTES
-  SET_DEFAULT_DECL_ATTRIBUTES (decl, attributes);
-#endif
-  
   /* Set attributes here so if duplicate decl, will have proper attributes.  */
   cplus_decl_attributes (decl, attributes, prefix_attributes);
 
index 4cddb83..78d052e 100644 (file)
@@ -8413,10 +8413,8 @@ as the expansion of @code{TARGET_MERGE_DECL_ATTRIBUTES}.  This is done
 in @file{i386/cygwin.h} and @file{i386/i386.c}, for example.
 @end deftypefn
 
-@table @code
-@findex INSERT_ATTRIBUTES
-@item INSERT_ATTRIBUTES (@var{node}, @var{attr_ptr})
-Define this macro if you want to be able to add attributes to a decl
+@deftypefn {Target Hook} void TARGET_INSERT_ATTRIBUTES (tree @var{node}, tree *@var{attr_ptr})
+Define this target hook if you want to be able to add attributes to a decl
 when it is being created.  This is normally useful for back ends which
 wish to implement a pragma by using the attributes which correspond to
 the pragma's effect.  The @var{node} argument is the decl which is being
@@ -8426,12 +8424,9 @@ shared with other decls, but attributes may be chained on the head of
 the list and @code{*@var{attr_ptr}} modified to point to the new
 attributes, or a copy of the list may be made if further changes are
 needed.
+@end deftypefn
 
-@findex SET_DEFAULT_DECL_ATTRIBUTES
-@item SET_DEFAULT_DECL_ATTRIBUTES (@var{decl}, @var{attributes})
-If defined, a C statement that assigns default attributes to
-newly defined @var{decl}.
-
+@table @code
 @findex DOLLARS_IN_IDENTIFIERS
 @item DOLLARS_IN_IDENTIFIERS
 Define this macro to control use of the character @samp{$} in identifier
index ec0b660..dbcaecf 100644 (file)
@@ -43,6 +43,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #define TARGET_VALID_TYPE_ATTRIBUTE default_valid_attribute_p
 #define TARGET_COMP_TYPE_ATTRIBUTES default_comp_type_attributes
 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES default_set_default_type_attributes
+#define TARGET_INSERT_ATTRIBUTES default_insert_attributes
 
 /* The whole shebang.  */
 #define TARGET_INITIALIZER                     \
@@ -53,5 +54,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   TARGET_VALID_DECL_ATTRIBUTE,                 \
   TARGET_VALID_TYPE_ATTRIBUTE,                 \
   TARGET_COMP_TYPE_ATTRIBUTES,                 \
-  TARGET_SET_DEFAULT_TYPE_ATTRIBUTES           \
+  TARGET_SET_DEFAULT_TYPE_ATTRIBUTES,          \
+  TARGET_INSERT_ATTRIBUTES                     \
 }
index 45143ab..20714c9 100644 (file)
@@ -87,6 +87,9 @@ struct gcc_target
 
   /* Assign default attributes to the newly defined TYPE.  */
   void (* set_default_type_attributes) PARAMS ((tree type));
+
+  /* Insert attributes on the newly created DECL.  */
+  void (* insert_attributes) PARAMS ((tree decl, tree *attributes));
 };
 
 extern struct gcc_target targetm;
index a48724b..7ad0665 100644 (file)
@@ -2707,8 +2707,8 @@ build_type_attribute_variant (ttype, attribute)
   return ttype;
 }
 
-/* Default value of target.valid_decl_attribute_p and
-   target.valid_type_attribute_p that always returns false.  */
+/* Default value of targetm.valid_decl_attribute_p and
+   targetm.valid_type_attribute_p that always returns false.  */
 
 int
 default_valid_attribute_p PARAMS ((attr_name, attr_args, decl, type))
@@ -2720,7 +2720,7 @@ default_valid_attribute_p PARAMS ((attr_name, attr_args, decl, type))
   return 0;
 }
 
-/* Default value of target.comp_type_attributes that always returns 1.  */
+/* Default value of targetm.comp_type_attributes that always returns 1.  */
 
 int
 default_comp_type_attributes (type1, type2)
@@ -2730,7 +2730,7 @@ default_comp_type_attributes (type1, type2)
   return 1;
 }
 
-/* Default version of target.set_default_type_attributes that always does
+/* Default version of targetm.set_default_type_attributes that always does
    nothing.  */
 
 void
@@ -2739,6 +2739,14 @@ default_set_default_type_attributes (type)
 {
 }
 
+/* Default version of targetm.insert_attributes that always does nothing.  */
+void
+default_insert_attributes (decl, attr_ptr)
+     tree decl ATTRIBUTE_UNUSED;
+     tree *attr_ptr ATTRIBUTE_UNUSED;
+{
+}
+
 /* Return 1 if ATTR_NAME and ATTR_ARGS is valid for either declaration
    DECL or type TYPE and 0 otherwise.  Validity is determined the
    target functions valid_decl_attribute and valid_machine_attribute.  */
index 9a5fb6a..ec7a287 100644 (file)
@@ -2046,6 +2046,7 @@ extern tree merge_type_attributes PARAMS ((tree, tree));
 extern int default_valid_attribute_p PARAMS ((tree, tree, tree, tree));
 extern int default_comp_type_attributes PARAMS ((tree, tree));
 extern void default_set_default_type_attributes PARAMS ((tree));
+extern void default_insert_attributes PARAMS ((tree, tree *));
 
 /* Split a list of declspecs and attributes into two.  */