This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

3.2: langhook for copy_lang_decl


I estimate that leaves about 20 or so to go 8-(

copy_lang_decl() was not consistenly implemented amonst front ends as
to whether it could be passed a NULL pointer.  So I decreed that a NULL
can be passed, and fixed java to work in that situation (it was saved
by the fact that its only caller would check before calling).

Bootstrapped x86 Linux.  OK to commit?

Neil.

	* Makefile.in (integrate.o): Update.
	* c-decl.c (copy_lang_decl): Rename.
	* c-lang.c (LANG_HOOKS_DUP_LANG_SPECIFIC_DECL): Redefine.
	* integrate.c: Include langhooks.h.
	(copy_decl_for_inlining): Update to use langhook.
	* langhooks-def.h (lhd_do_nothing_t,
	LANG_HOOKS_DUP_LANG_SPECIFIC_DECL): New.
	(LANG_HOOKS_INITIALIZER): Update.
	* langhooks.c (lhd_do_nothing_t): New.
	* langhooks.h (struct lang_hooks): Add dup_lang_specific_decl.
	* tree.h (copy_lang_decl): Remove.
ada:
	* misc.c (copy_lang_decl): Remove.
cp:
	* class.c (build_clone): Update.
	* cp-lang.c (LANG_HOOKS_DUP_LANG_SPECIFIC_DECL): Redefine.
	* cp-tree.h (cxx_dup_lang_specific_decl): New.
	* lex.c (copy_lang_decl): Rename cxx_dup_lang_specific_decl.
	(copy_decl): Update.
	* method.c (make_thunk): Update.
f:
	* com.c (copy_lang_decl): Delete.
java:
	* decl.c (copy_lang_decl): Rename java_dup_lang_specific_decl.
	* java-tree.h (java_dup_lang_specific_decl): New.
	* lang.c (LANG_HOOKS_DUP_LANG_SPECIFIC_DECL): Redefine.
objc:
	* objc-lang.c (LANG_HOOKS_DUP_LANG_SPECIFIC_DECL): Redefine.

============================================================
Index: gcc/Makefile.in
--- gcc/Makefile.in	2002/02/22 04:42:38	1.830
+++ gcc/Makefile.in	2002/02/27 20:55:07
@@ -1431,7 +1431,7 @@ real.o : real.c $(CONFIG_H) $(SYSTEM_H) 
 integrate.o : integrate.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \
    debug.h $(INTEGRATE_H) insn-config.h $(EXPR_H) real.h $(REGS_H) \
    intl.h function.h output.h $(RECOG_H) except.h toplev.h $(LOOP_H) \
-   $(PARAMS_H) $(TM_P_H) $(TARGET_H)
+   $(PARAMS_H) $(TM_P_H) $(TARGET_H) langhooks.h
 jump.o : jump.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) flags.h hard-reg-set.h $(REGS_H) \
    insn-config.h $(RECOG_H) $(EXPR_H) real.h except.h function.h \
    toplev.h $(INSN_ATTR_H) $(TM_P_H) reload.h $(PREDICT_H)
============================================================
Index: gcc/c-decl.c
--- gcc/c-decl.c	2002/02/27 18:46:59	1.301
+++ gcc/c-decl.c	2002/02/27 20:55:26
@@ -7200,10 +7200,10 @@ mark_c_function_context (f)
   mark_binding_level (&p->binding_level);
 }
 
-/* Copy the DECL_LANG_SPECIFIC data associated with NODE.  */
+/* Copy the DECL_LANG_SPECIFIC data associated with DECL.  */
 
 void
-copy_lang_decl (decl)
+c_dup_lang_specific_decl (decl)
      tree decl;
 {
   struct lang_decl *ld;
============================================================
Index: gcc/c-lang.c
--- gcc/c-lang.c	2001/12/17 22:43:40	1.74
+++ gcc/c-lang.c	2002/02/27 20:55:28
@@ -55,7 +55,9 @@ static void c_post_options PARAMS ((void
 #define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier
 #undef LANG_HOOKS_SET_YYDEBUG
 #define LANG_HOOKS_SET_YYDEBUG c_set_yydebug
+#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
+#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL c_dup_lang_specific_decl
 
 #undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
 #define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
============================================================
Index: gcc/c-tree.h
--- gcc/c-tree.h	2002/02/27 18:47:01	1.82
+++ gcc/c-tree.h	2002/02/27 20:55:41
@@ -168,6 +168,7 @@ extern void gen_aux_info_record         
 
 /* in c-decl.c */
 extern void c_init_decl_processing		PARAMS ((void));
+extern void c_dup_lang_specific_decl		PARAMS ((tree));
 extern void c_print_identifier			PARAMS ((FILE *, tree, int));
 extern tree build_array_declarator              PARAMS ((tree, tree, int, int));
 extern tree build_enumerator                    PARAMS ((tree, tree));
============================================================
Index: gcc/integrate.c
--- gcc/integrate.c	2002/02/19 02:53:13	1.184
+++ gcc/integrate.c	2002/02/27 20:55:44
@@ -43,6 +43,7 @@ Software Foundation, 59 Temple Place - S
 #include "params.h"
 #include "ggc.h"
 #include "target.h"
+#include "langhooks.h"
 
 #include "obstack.h"
 #define	obstack_chunk_alloc	xmalloc
@@ -368,8 +369,7 @@ copy_decl_for_inlining (decl, from_fn, t
   else
     {
       copy = copy_node (decl);
-      if (DECL_LANG_SPECIFIC (copy))
-	copy_lang_decl (copy);
+      (*lang_hooks.dup_lang_specific_decl) (copy);
 
       /* TREE_ADDRESSABLE isn't used to indicate that a label's
 	 address has been taken; it's for internal bookkeeping in
============================================================
Index: gcc/langhooks-def.h
--- gcc/langhooks-def.h	2001/12/05 23:48:10	1.8
+++ gcc/langhooks-def.h	2002/02/27 20:55:46
@@ -38,6 +38,7 @@ extern HOST_WIDE_INT hook_get_alias_set_
 /* See langhooks.h for the definition and documentation of each hook.  */
 
 extern void lhd_do_nothing PARAMS ((void));
+extern void lhd_do_nothing_t PARAMS ((tree));
 extern int lhd_decode_option PARAMS ((int, char **));
 extern HOST_WIDE_INT lhd_get_alias_set PARAMS ((tree));
 extern tree lhd_return_tree PARAMS ((tree));
@@ -75,6 +76,7 @@ void lhd_tree_inlining_end_inlining		PAR
 #define LANG_HOOKS_EXPAND_CONSTANT	lhd_return_tree
 #define LANG_HOOKS_SAFE_FROM_P		lhd_safe_from_p
 #define LANG_HOOKS_STATICP		lhd_staticp
+#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL lhd_do_nothing_t
 #define LANG_HOOKS_HONOR_READONLY	false
 #define LANG_HOOKS_PRINT_STATISTICS	lhd_do_nothing
 #define LANG_HOOKS_PRINT_XNODE		lhd_print_tree_nothing
@@ -143,6 +145,7 @@ int lhd_tree_dump_type_quals			PARAMS ((
   LANG_HOOKS_EXPAND_CONSTANT, \
   LANG_HOOKS_SAFE_FROM_P, \
   LANG_HOOKS_STATICP, \
+  LANG_HOOKS_DUP_LANG_SPECIFIC_DECL, \
   LANG_HOOKS_HONOR_READONLY, \
   LANG_HOOKS_PRINT_STATISTICS, \
   LANG_HOOKS_PRINT_XNODE, \
============================================================
Index: gcc/langhooks.c
--- gcc/langhooks.c	2002/02/22 04:23:21	1.16
+++ gcc/langhooks.c	2002/02/27 20:55:46
@@ -39,6 +39,14 @@ lhd_do_nothing ()
 {
 }
 
+/* Do nothing.  */
+
+void
+lhd_do_nothing_t (t)
+     tree t ATTRIBUTE_UNUSED;
+{
+}
+
 /* Do nothing (return the tree node passed).  */
 
 tree
============================================================
Index: gcc/langhooks.h
--- gcc/langhooks.h	2001/12/05 23:48:10	1.15
+++ gcc/langhooks.h	2002/02/27 20:55:47
@@ -128,6 +128,10 @@ struct lang_hooks
   /* Hook called by staticp for language-specific tree codes.  */
   int (*staticp) PARAMS ((tree));
 
+  /* Replace the DECL_LANG_SPECIFIC data, which may be NULL, of the
+     DECL_NODE with a newly GC-allocated copy.  */
+  void (*dup_lang_specific_decl) PARAMS ((tree));
+
   /* Nonzero if TYPE_READONLY and TREE_READONLY should always be honored.  */
   bool honor_readonly;
 
============================================================
Index: gcc/tree.h
--- gcc/tree.h	2002/02/26 21:17:14	1.309
+++ gcc/tree.h	2002/02/27 20:55:57
@@ -2859,9 +2859,6 @@ extern tree fold_builtin		PARAMS ((tree)
 
 /* The language front-end must define these functions.  */
 
-/* Function to replace the DECL_LANG_SPECIFIC field of a DECL with a copy.  */
-extern void copy_lang_decl			PARAMS ((tree));
-
 /* Function called with no arguments to parse and compile the input.  */
 extern int yyparse				PARAMS ((void));
 /* Functions for processing symbol declarations.  */
============================================================
Index: gcc/ada/misc.c
--- gcc/ada/misc.c	2002/02/27 18:47:17	1.18
+++ gcc/ada/misc.c	2002/02/27 20:55:59
@@ -406,15 +406,6 @@ maybe_build_cleanup (decl)
   return NULL_TREE;
 }
 
-/* integrate_decl_tree calls this function, but since we don't use the
-   DECL_LANG_SPECIFIC field, this is a no-op.  */
-
-void
-copy_lang_decl (node)
-     tree node ATTRIBUTE_UNUSED;
-{
-}
-
 /* Hooks for print-tree.c:  */
 
 static void
============================================================
Index: gcc/cp/class.c
--- gcc/cp/class.c	2002/02/07 20:51:12	1.436
+++ gcc/cp/class.c	2002/02/27 20:56:22
@@ -4038,7 +4038,7 @@ build_clone (fn, name)
       for (parms = DECL_ARGUMENTS (clone); parms; parms = TREE_CHAIN (parms))
 	{
 	  DECL_CONTEXT (parms) = clone;
-	  copy_lang_decl (parms);
+	  cxx_dup_lang_specific_decl (parms);
 	}
     }
 
============================================================
Index: gcc/cp/cp-lang.c
--- gcc/cp/cp-lang.c	2001/12/05 23:48:14	1.9
+++ gcc/cp/cp-lang.c	2002/02/27 20:56:22
@@ -50,6 +50,8 @@ static HOST_WIDE_INT cxx_get_alias_set P
 #define LANG_HOOKS_EXPAND_CONSTANT cplus_expand_constant
 #undef LANG_HOOKS_SAFE_FROM_P
 #define LANG_HOOKS_SAFE_FROM_P c_safe_from_p
+#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
+#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL cxx_dup_lang_specific_decl
 #undef LANG_HOOKS_PRINT_STATISTICS
 #define LANG_HOOKS_PRINT_STATISTICS cxx_print_statistics
 #undef LANG_HOOKS_PRINT_XNODE
============================================================
Index: gcc/cp/cp-tree.h
--- gcc/cp/cp-tree.h	2002/02/24 18:57:38	1.681
+++ gcc/cp/cp-tree.h	2002/02/27 20:56:34
@@ -3922,6 +3922,7 @@ extern tree build_java_class_ref        
 /* in input.c */
 
 /* in lex.c */
+extern void cxx_dup_lang_specific_decl		PARAMS ((tree));
 extern tree make_pointer_declarator		PARAMS ((tree, tree));
 extern tree make_reference_declarator		PARAMS ((tree, tree));
 extern tree make_call_declarator		PARAMS ((tree, tree, tree, tree));
============================================================
Index: gcc/cp/lex.c
--- gcc/cp/lex.c	2002/02/04 08:55:43	1.265
+++ gcc/cp/lex.c	2002/02/27 20:56:37
@@ -1516,7 +1516,7 @@ retrofit_lang_decl (t)
 }
 
 void
-copy_lang_decl (node)
+cxx_dup_lang_specific_decl (node)
      tree node;
 {
   int size;
@@ -1548,7 +1548,7 @@ copy_decl (decl)
   tree copy;
 
   copy = copy_node (decl);
-  copy_lang_decl (copy);
+  cxx_dup_lang_specific_decl (copy);
   return copy;
 }
 
============================================================
Index: gcc/cp/method.c
--- gcc/cp/method.c	2002/02/04 17:44:25	1.219
+++ gcc/cp/method.c	2002/02/27 20:56:40
@@ -302,7 +302,7 @@ make_thunk (function, delta, vcall_index
     {
       thunk = build_decl (FUNCTION_DECL, thunk_id, TREE_TYPE (func_decl));
       DECL_LANG_SPECIFIC (thunk) = DECL_LANG_SPECIFIC (func_decl);
-      copy_lang_decl (func_decl);
+      cxx_dup_lang_specific_decl (func_decl);
       SET_DECL_ASSEMBLER_NAME (thunk, thunk_id);
       DECL_CONTEXT (thunk) = DECL_CONTEXT (func_decl);
       TREE_READONLY (thunk) = TREE_READONLY (func_decl);
============================================================
Index: gcc/f/com.c
--- gcc/f/com.c	2002/02/27 18:47:56	1.154
+++ gcc/f/com.c	2002/02/27 20:57:13
@@ -14049,15 +14049,6 @@ convert (type, expr)
   return error_mark_node;
 }
 
-/* integrate_decl_tree calls this function, but since we don't use the
-   DECL_LANG_SPECIFIC field, this is a no-op.  */
-
-void
-copy_lang_decl (node)
-     tree node UNUSED;
-{
-}
-
 /* Return the list of declarations of the current level.
    Note that this list is in reverse order unless/until
    you nreverse it; and when you do nreverse it, you must
============================================================
Index: gcc/java/decl.c
--- gcc/java/decl.c	2002/02/27 18:47:59	1.118
+++ gcc/java/decl.c	2002/02/27 20:57:18
@@ -1543,13 +1543,20 @@ set_block (block)
 /* integrate_decl_tree calls this function. */
 
 void
-copy_lang_decl (node)
+java_dup_lang_specific_decl (node)
      tree node;
 {
-  int lang_decl_size
-    = TREE_CODE (node) == VAR_DECL ? sizeof (struct lang_decl_var)
-    : sizeof (struct lang_decl);
-  struct lang_decl *x = (struct lang_decl *) ggc_alloc (lang_decl_size);
+  int lang_decl_size;
+  struct lang_decl *x;
+
+  if (!DECL_LANG_SPECIFIC (node))
+    return;
+
+  if (TREE_CODE (node) == VAR_DECL)
+    lang_decl_size = sizeof (struct lang_decl_var);
+  else
+    lang_decl_size = sizeof (struct lang_decl);
+  x = (struct lang_decl *) ggc_alloc (lang_decl_size);
   memcpy (x, DECL_LANG_SPECIFIC (node), lang_decl_size);
   DECL_LANG_SPECIFIC (node) = x;
 }
============================================================
Index: gcc/java/java-tree.h
--- gcc/java/java-tree.h	2002/02/20 19:53:48	1.136
+++ gcc/java/java-tree.h	2002/02/27 20:57:23
@@ -1069,6 +1069,7 @@ extern tree ident_subst PARAMS ((const c
 extern tree identifier_subst PARAMS ((const tree,
 				     const char *, int, int, const char *));
 extern void java_init_decl_processing PARAMS ((void));
+extern void java_dup_lang_specific_decl PARAMS ((tree));
 extern tree build_java_signature PARAMS ((tree));
 extern tree build_java_argument_signature PARAMS ((tree));
 extern void set_java_signature PARAMS ((tree, tree));
============================================================
Index: gcc/java/lang.c
--- gcc/java/lang.c	2002/02/20 23:12:24	1.85
+++ gcc/java/lang.c	2002/02/27 20:57:24
@@ -214,6 +214,8 @@ static int dependency_tracking = 0;
 #define LANG_HOOKS_DECODE_OPTION java_decode_option
 #undef LANG_HOOKS_SET_YYDEBUG
 #define LANG_HOOKS_SET_YYDEBUG java_set_yydebug
+#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
+#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL java_dup_lang_specific_decl
 
 /* Each front end provides its own.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
============================================================
Index: gcc/objc/objc-lang.c
--- gcc/objc/objc-lang.c	2001/12/04 22:55:38	1.2
+++ gcc/objc/objc-lang.c	2002/02/27 20:57:24
@@ -46,6 +46,8 @@ static void objc_post_options           
 #define LANG_HOOKS_POST_OPTIONS objc_post_options
 #undef LANG_HOOKS_STATICP
 #define LANG_HOOKS_STATICP c_staticp
+#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
+#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL c_dup_lang_specific_decl
 #undef LANG_HOOKS_PRINT_IDENTIFIER
 #define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier
 #undef LANG_HOOKS_SET_YYDEBUG


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]