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]

Move c_static_assembler_name around


Someone, perhaps Neil, suggested that c_static_assembler_name didn't
really belong in c-opts.c.  On thinking about it, I agree, so this
patch moves it.

However, I would like to emphasise that this is the one and only place
in the code generation where num_in_fnames should be used.  Please
don't start adding it at random places, because otherwise we will need
to add extra testsuite functionality to make sure that the compiler
works in both modes.  (Already I find myself adding debugging checks
to make sure that TREE_STATIC and TREE_PUBLIC don't change after this
routine is called.)

Bootstrapped & tested on powerpc-darwin.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-movecstaticassemblername.patch========
2003-07-21  Geoffrey Keating  <geoffk@apple.com>

	* c-common.h (num_in_fnames): Declare.
	(c_static_assembler_name): Move from here...
	* c-tree.h (c_static_assembler_name): ... to here.
	* c-opts.c: Don't include langhooks-def.h.
	(c_static_assembler_name): Move to c-decl.c.
	(num_in_fnames): Make externally visible.
	* c-decl.c: Include langhooks-def.h.
	(c_static_assembler_name): Move from c-opts.c.
	* Makefile.in (c-decl.o): Add $(LANGHOOKS_DEF_H).
	(c-opts.o): Remove $(LANGHOOKS_DEF_H).

Index: c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.192
diff -u -p -u -p -r1.192 c-common.h
--- c-common.h	17 Jul 2003 21:52:49 -0000	1.192
+++ c-common.h	21 Jul 2003 20:55:14 -0000
@@ -856,6 +856,11 @@ extern int max_tinst_depth;
 
 extern int skip_evaluation;
 
+/* The count of input filenames.  Only really valid for comparisons
+   against 1.  */
+
+extern unsigned num_in_fnames;
+
 /* C types are partitioned into three subsets: object, function, and
    incomplete types.  */
 #define C_TYPE_OBJECT_P(type) \
@@ -905,7 +910,6 @@ extern void check_function_format (int *
 extern void set_Wformat (int);
 extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
 extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
-extern void c_static_assembler_name (tree);
 extern void c_common_insert_default_attributes (tree);
 extern int c_common_handle_option (size_t code, const char *arg, int value);
 extern void c_common_handle_filename (const char *filename);
Index: c-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-tree.h,v
retrieving revision 1.121
diff -u -p -u -p -r1.121 c-tree.h
--- c-tree.h	17 Jul 2003 20:12:14 -0000	1.121
+++ c-tree.h	21 Jul 2003 20:55:14 -0000
@@ -228,6 +228,7 @@ extern tree xref_tag (enum tree_code, tr
 extern tree c_begin_compound_stmt (void);
 extern void c_expand_deferred_function (tree);
 extern void c_expand_decl_stmt (tree);
+extern void c_static_assembler_name (tree);
 extern tree make_pointer_declarator (tree, tree);
 extern void merge_translation_unit_decls (void);
 
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.76
diff -u -p -u -p -r1.76 c-opts.c
--- c-opts.c	17 Jul 2003 21:52:49 -0000	1.76
+++ c-opts.c	21 Jul 2003 20:55:14 -0000
@@ -37,7 +37,6 @@ Software Foundation, 59 Temple Place - S
 #include "debug.h"		/* For debug_hooks.  */
 #include "opts.h"
 #include "options.h"
-#include "langhooks-def.h"
 
 #ifndef DOLLARS_IN_IDENTIFIERS
 # define DOLLARS_IN_IDENTIFIERS true
@@ -54,7 +53,7 @@ static cpp_options *cpp_opts;
 
 /* Input filename.  */
 static const char **in_fnames;
-static unsigned num_in_fnames;
+unsigned num_in_fnames;
 static const char *this_input_filename;
 
 /* Filename and stream for preprocessed output.  */
@@ -1249,22 +1248,6 @@ c_common_finish (void)
 
   if (out_stream && (ferror (out_stream) || fclose (out_stream)))
     fatal_error ("when writing output to %s: %m", out_fname);
-}
-
-/* A wrapper around lhd_set_decl_assembler_name that gives static
-   variables their C names if they are at the top level and only one
-   translation unit is being compiled, for backwards compatibility
-   with certain bizzare assembler hacks (like crtstuff.c).  */
-
-void
-c_static_assembler_name (tree decl)
-{
-  if (num_in_fnames == 1
-      && TREE_STATIC (decl) && !TREE_PUBLIC (decl) && DECL_CONTEXT (decl)
-      && TREE_CODE (DECL_CONTEXT (decl)) == TRANSLATION_UNIT_DECL)
-    SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
-  else
-    lhd_set_decl_assembler_name (decl);
 }
 
 /* Either of two environment variables can specify output of
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.407
diff -u -p -u -p -r1.407 c-decl.c
--- c-decl.c	17 Jul 2003 20:12:13 -0000	1.407
+++ c-decl.c	21 Jul 2003 20:55:15 -0000
@@ -52,6 +52,7 @@ Software Foundation, 59 Temple Place - S
 #include "hashtab.h"
 #include "libfuncs.h"
 #include "except.h"
+#include "langhooks-def.h"
 
 /* In grokdeclarator, distinguish syntactic contexts of declarators.  */
 enum decl_context
@@ -6746,6 +6771,22 @@ make_pointer_declarator (tree type_quals
   if (attrs != NULL_TREE)
     itarget = tree_cons (attrs, target, NULL_TREE);
   return build1 (INDIRECT_REF, quals, itarget);
+}
+
+/* A wrapper around lhd_set_decl_assembler_name that gives static
+   variables their C names if they are at the top level and only one
+   translation unit is being compiled, for backwards compatibility
+   with certain bizzare assembler hacks (like crtstuff.c).  */
+
+void
+c_static_assembler_name (tree decl)
+{
+  if (num_in_fnames == 1
+      && TREE_STATIC (decl) && !TREE_PUBLIC (decl) && DECL_CONTEXT (decl)
+      && TREE_CODE (DECL_CONTEXT (decl)) == TRANSLATION_UNIT_DECL)
+    SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
+  else
+    lhd_set_decl_assembler_name (decl);
 }
 
 /* Hash and equality functions for link_hash_table: key off
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1118
diff -u -p -u -p -r1.1118 Makefile.in
--- Makefile.in	17 Jul 2003 21:52:49 -0000	1.1118
+++ Makefile.in	21 Jul 2003 20:55:15 -0000
@@ -1269,7 +1269,8 @@ c-incpath.o: c-incpath.c c-incpath.h $(C
 c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     $(RTL_H) $(C_TREE_H) $(GGC_H) $(TARGET_H) flags.h function.h output.h \
     $(EXPR_H) debug.h toplev.h intl.h $(TM_P_H) tree-inline.h $(TIMEVAR_H) \
-    c-pragma.h gt-c-decl.h cgraph.h $(HASHTAB_H) libfuncs.h except.h
+    c-pragma.h gt-c-decl.h cgraph.h $(HASHTAB_H) libfuncs.h except.h \
+    $(LANGHOOKS_DEF_H)
 c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_TREE_H) \
     $(TARGET_H) flags.h intl.h output.h $(EXPR_H) $(RTL_H) toplev.h $(TM_P_H)
 c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_TREE_H) \
@@ -1324,8 +1325,7 @@ c-pretty-print.o : c-pretty-print.c c-pr
 
 c-opts.o : c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
         c-pragma.h flags.h toplev.h langhooks.h tree-inline.h diagnostic.h \
-	intl.h debug.h $(C_COMMON_H) opts.h options.h $(PARAMS_H) \
-	$(LANGHOOKS_DEF_H)
+	intl.h debug.h $(C_COMMON_H) opts.h options.h $(PARAMS_H)
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 		$< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@
 
============================================================


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