Repost: Patch to const-ify tree_code_{type,name,length}
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Tue Mar 12 14:06:00 GMT 2002
This is a repost of a patch I originally submitted back in December to
constify tree_code_type, tree_code_name & tree_code_length. Its not
as simple as adding "const", so I don't consider this a candidate for
"obvious" installation. I.e. it requires a review IMHO. See:
http://gcc.gnu.org/ml/gcc-patches/2001-12/msg02395.html
The patch below was updated for the current sources and successfully
bootstrapped on sparc-sun-solaris2.7.
Ok to install?
Thanks,
--Kaveh
2001-12-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* c-common.c (c_tree_code_type, c_tree_code_length,
c_tree_code_name, add_c_tree_codes): Delete.
* c-common.h (add_c_tree_codes): Delete.
* c-lang.c (tree_code_type, tree_code_length, tree_code_name):
Define.
* c-objc-common.c (c_objc_common_init): Don't call
add_c_tree_codes, instead set lang_unsafe_for_reeval.
* objc/objc-act.c (objc_tree_code_type, objc_tree_code_length,
objc_tree_code_name, add_objc_tree_codes): Delete.
(objc_init): Don't call add_objc_tree_codes.
* objc/objc-lang.c (tree_code_type, tree_code_length,
tree_code_name): Define.
* toplev.c (lang_independent_init): Don't set
tree_code_length[IDENTIFIER_NODE].
* tree.c (tree_code_type, tree_code_length, tree_code_name):
Delete definitions, moved to language front-ends.
* tree.def (IDENTIFIER_NODE): Hardwire the length.
* tree.h (tree_code_type, tree_code_length, tree_code_name):
Const-ify.
(tree_code_length): Change type to unsigned char.
ada:
* misc.c (gnat_tree_code_type, gnat_tree_code_length,
gnat_tree_code_name): Delete.
(tree_code_type, tree_code_length, tree_code_name): Define.
(gnat_init): Don't try to copy into the various tree_code
arrays.
ch:
* decl.c (chill_tree_code_type, chill_tree_code_length,
chill_tree_code_name): Delete.
(tree_code_type, tree_code_length, tree_code_name): Define.
(init_decl_processing): Don't try to copy into the various
tree_code arrays.
cp:
* cp-lang.c (tree_code_type, tree_code_length, tree_code_name):
Define.
* decl.c (duplicate_decls): Use TREE_CODE_LENGTH, not
tree_code_length.
* lex.c (cplus_tree_code_type, cplus_tree_code_length,
cplus_tree_code_name): Delete.
(cxx_init): Don't call add_c_tree_codes, instead set
lang_unsafe_for_reeval. Don't try to copy into the various
tree_code arrays.
f:
* com.c (tree_code_type, tree_code_length, tree_code_name):
Define.
java:
* lang.c (java_tree_code_type, java_tree_code_length,
tree_code_name): Delete.
(tree_code_type, tree_code_length, tree_code_name): Define.
(java_init): Don't try to copy into the various tree_code
arrays.
diff -rup orig/egcc-CVS20020312/gcc/c-common.c egcc-CVS20020312/gcc/c-common.c
--- orig/egcc-CVS20020312/gcc/c-common.c Thu Mar 7 07:30:18 2002
+++ egcc-CVS20020312/gcc/c-common.c Tue Mar 12 13:38:39 2002
@@ -3696,56 +3696,6 @@ c_staticp (exp)
return 0;
}
-/* Tree code classes. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-static const char c_tree_code_type[] = {
- 'x',
-#include "c-common.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
- operands beyond the fixed part of the node structure.
- Not used for types or decls. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-static const int c_tree_code_length[] = {
- 0,
-#include "c-common.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
- Used for printing out the tree and error messages. */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-static const char *const c_tree_code_name[] = {
- "@@dummy",
-#include "c-common.def"
-};
-#undef DEFTREECODE
-
-/* Adds the tree codes specific to the C front end to the list of all
- tree codes. */
-
-void
-add_c_tree_codes ()
-{
- memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
- c_tree_code_type,
- (int) LAST_C_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE);
- memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
- c_tree_code_length,
- (LAST_C_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
- memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
- c_tree_code_name,
- (LAST_C_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
- lang_unsafe_for_reeval = c_unsafe_for_reeval;
-}
-
#define CALLED_AS_BUILT_IN(NODE) \
(!strncmp (IDENTIFIER_POINTER (DECL_NAME (NODE)), "__builtin_", 10))
diff -rup orig/egcc-CVS20020312/gcc/c-common.h egcc-CVS20020312/gcc/c-common.h
--- orig/egcc-CVS20020312/gcc/c-common.h Wed Feb 27 16:30:31 2002
+++ egcc-CVS20020312/gcc/c-common.h Tue Mar 12 13:38:39 2002
@@ -728,7 +728,6 @@ enum c_tree_code {
#undef DEFTREECODE
-extern void add_c_tree_codes PARAMS ((void));
extern void genrtl_do_pushlevel PARAMS ((void));
extern void genrtl_goto_stmt PARAMS ((tree));
extern void genrtl_expr_stmt PARAMS ((tree));
diff -rup orig/egcc-CVS20020312/gcc/c-lang.c egcc-CVS20020312/gcc/c-lang.c
--- orig/egcc-CVS20020312/gcc/c-lang.c Thu Feb 28 07:33:19 2002
+++ egcc-CVS20020312/gcc/c-lang.c Tue Mar 12 13:38:39 2002
@@ -73,6 +73,41 @@ static void c_post_options PARAMS ((void
/* Each front end provides its own. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
+/* Tree code classes. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+ 'x',
+#include "c-common.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+ operands beyond the fixed part of the node structure.
+ Not used for types or decls. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+ 0,
+#include "c-common.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+ Used for printing out the tree and error messages. */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char *const tree_code_name[] = {
+#include "tree.def"
+ "@@dummy",
+#include "c-common.def"
+};
+#undef DEFTREECODE
+
/* Post-switch processing. */
static void
c_post_options ()
diff -rup orig/egcc-CVS20020312/gcc/c-objc-common.c egcc-CVS20020312/gcc/c-objc-common.c
--- orig/egcc-CVS20020312/gcc/c-objc-common.c Fri Feb 22 07:30:36 2002
+++ egcc-CVS20020312/gcc/c-objc-common.c Tue Mar 12 13:38:39 2002
@@ -217,7 +217,7 @@ c_objc_common_init (filename)
filename = c_common_init (filename);
- add_c_tree_codes ();
+ lang_unsafe_for_reeval = c_unsafe_for_reeval;
save_lang_status = &push_c_function_context;
restore_lang_status = &pop_c_function_context;
diff -rup orig/egcc-CVS20020312/gcc/ada/misc.c egcc-CVS20020312/gcc/ada/misc.c
--- orig/egcc-CVS20020312/gcc/ada/misc.c Fri Mar 8 15:11:53 2002
+++ egcc-CVS20020312/gcc/ada/misc.c Tue Mar 12 13:43:19 2002
@@ -77,42 +77,6 @@ extern FILE *asm_out_file;
extern int save_argc;
extern char **save_argv;
-/* Tables describing GCC tree codes used only by GNAT.
-
- Table indexed by tree code giving a string containing a character
- classifying the tree code. Possibilities are
- t, d, s, c, r, <, 1 and 2. See cp-tree.def for details. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-static const char gnat_tree_code_type[] = {
- 'x',
-#include "ada-tree.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
- operands beyond the fixed part of the node structure.
- Not used for types or decls. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-static const int gnat_tree_code_length[] = {
- 0,
-#include "ada-tree.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
- Used for printing out the tree and error messages. */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-const char * const gnat_tree_code_name[] = {
- "@@dummy",
-#include "ada-tree.def"
-};
-#undef DEFTREECODE
-
static const char *gnat_init PARAMS ((const char *));
static void gnat_init_options PARAMS ((void));
static int gnat_decode_option PARAMS ((int, char **));
@@ -146,6 +110,45 @@ static int gnat_eh_type_covers PARAMS (
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
+/* Tables describing GCC tree codes used only by GNAT.
+
+ Table indexed by tree code giving a string containing a character
+ classifying the tree code. Possibilities are
+ t, d, s, c, r, <, 1 and 2. See cp-tree.def for details. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+ 'x',
+#include "ada-tree.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+ operands beyond the fixed part of the node structure.
+ Not used for types or decls. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+ 0,
+#include "ada-tree.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+ Used for printing out the tree and error messages. */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char *const tree_code_name[] = {
+#include "tree.def"
+ "@@dummy",
+#include "ada-tree.def"
+};
+#undef DEFTREECODE
+
/* gnat standard argc argv */
extern int gnat_argc;
@@ -357,21 +360,6 @@ gnat_init (filename)
lang_expand_expr = gnat_expand_expr;
decl_printable_name = gnat_printable_name;
-
- memcpy ((char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
- (char *) gnat_tree_code_type,
- ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
- * sizeof (char *)));
-
- memcpy ((char *) (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
- (char *) gnat_tree_code_length,
- ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
- * sizeof (int)));
-
- memcpy ((char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
- (char *) gnat_tree_code_name,
- ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
- * sizeof (char *)));
gnat_init_decl_processing ();
diff -rup orig/egcc-CVS20020312/gcc/ch/decl.c egcc-CVS20020312/gcc/ch/decl.c
--- orig/egcc-CVS20020312/gcc/ch/decl.c Wed Feb 27 16:30:43 2002
+++ egcc-CVS20020312/gcc/ch/decl.c Tue Mar 12 13:38:42 2002
@@ -534,7 +534,8 @@ int warn_missing_braces;
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
- const char chill_tree_code_type[] = {
+const char tree_code_type[] = {
+#include "tree.def"
'x',
#include "ch-tree.def"
};
@@ -546,7 +547,8 @@ int warn_missing_braces;
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-int chill_tree_code_length[] = {
+const unsigned char tree_code_length[] = {
+#include "tree.def"
0,
#include "ch-tree.def"
};
@@ -557,7 +559,8 @@ int chill_tree_code_length[] = {
Used for printing out the tree and error messages. */
#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-const char *chill_tree_code_name[] = {
+const char *const tree_code_name[] = {
+#include "tree.def"
"@@dummy",
#include "ch-tree.def"
};
@@ -3482,18 +3485,6 @@ init_decl_processing ()
DECL_SOURCE_LINE (temp) = 0;
initializer_type = TREE_TYPE (temp);
- memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
- chill_tree_code_type,
- (((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
- * sizeof (char)));
- memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
- chill_tree_code_length,
- (((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
- * sizeof (int)));
- memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
- chill_tree_code_name,
- (((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
- * sizeof (char *)));
boolean_code_name = (const char **) xcalloc (sizeof (char *),
(int) LAST_CHILL_TREE_CODE);
diff -rup orig/egcc-CVS20020312/gcc/cp/cp-lang.c egcc-CVS20020312/gcc/cp/cp-lang.c
--- orig/egcc-CVS20020312/gcc/cp/cp-lang.c Mon Mar 11 16:31:14 2002
+++ egcc-CVS20020312/gcc/cp/cp-lang.c Tue Mar 12 13:38:42 2002
@@ -152,6 +152,47 @@ ok_to_generate_alias_set_for_type (t)
return true;
}
+/* Tree code classes. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+ 'x',
+#include "c-common.def"
+ 'x',
+#include "cp-tree.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+ operands beyond the fixed part of the node structure.
+ Not used for types or decls. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+ 0,
+#include "c-common.def"
+ 0,
+#include "cp-tree.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+ Used for printing out the tree and error messages. */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char *const tree_code_name[] = {
+#include "tree.def"
+ "@@dummy",
+#include "c-common.def"
+ "@@dummy",
+#include "cp-tree.def"
+};
+#undef DEFTREECODE
+
/* Special routine to get the alias set for C++. */
static HOST_WIDE_INT
diff -rup orig/egcc-CVS20020312/gcc/cp/decl.c egcc-CVS20020312/gcc/cp/decl.c
--- orig/egcc-CVS20020312/gcc/cp/decl.c Mon Mar 11 16:31:18 2002
+++ egcc-CVS20020312/gcc/cp/decl.c Tue Mar 12 13:38:42 2002
@@ -3781,7 +3781,7 @@ duplicate_decls (newdecl, olddecl)
memcpy ((char *) olddecl + sizeof (struct tree_common),
(char *) newdecl + sizeof (struct tree_common),
sizeof (struct tree_decl) - sizeof (struct tree_common)
- + tree_code_length [(int)TREE_CODE (newdecl)] * sizeof (char *));
+ + TREE_CODE_LENGTH (TREE_CODE (newdecl)) * sizeof (char *));
}
DECL_UID (olddecl) = olddecl_uid;
diff -rup orig/egcc-CVS20020312/gcc/cp/lex.c egcc-CVS20020312/gcc/cp/lex.c
--- orig/egcc-CVS20020312/gcc/cp/lex.c Sun Mar 3 09:03:21 2002
+++ egcc-CVS20020312/gcc/cp/lex.c Tue Mar 12 13:38:42 2002
@@ -205,37 +205,6 @@ int interface_only; /* whether or not c
int interface_unknown; /* whether or not we know this class
to behave according to #pragma interface. */
-/* Tree code classes. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-static const char cplus_tree_code_type[] = {
- 'x',
-#include "cp-tree.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
- operands beyond the fixed part of the node structure.
- Not used for types or decls. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-static const int cplus_tree_code_length[] = {
- 0,
-#include "cp-tree.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
- Used for printing out the tree and error messages. */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-static const char *const cplus_tree_code_name[] = {
- "@@dummy",
-#include "cp-tree.def"
-};
-#undef DEFTREECODE
/* Post-switch processing. */
void
@@ -682,17 +651,7 @@ cxx_init (filename)
init_cplus_expand ();
init_cp_semantics ();
- add_c_tree_codes ();
-
- memcpy (tree_code_type + (int) LAST_C_TREE_CODE,
- cplus_tree_code_type,
- (int)LAST_CPLUS_TREE_CODE - (int)LAST_C_TREE_CODE);
- memcpy (tree_code_length + (int) LAST_C_TREE_CODE,
- cplus_tree_code_length,
- (LAST_CPLUS_TREE_CODE - (int)LAST_C_TREE_CODE) * sizeof (int));
- memcpy (tree_code_name + (int) LAST_C_TREE_CODE,
- cplus_tree_code_name,
- (LAST_CPLUS_TREE_CODE - (int)LAST_C_TREE_CODE) * sizeof (char *));
+ lang_unsafe_for_reeval = c_unsafe_for_reeval;
init_operators ();
init_method ();
diff -rup orig/egcc-CVS20020312/gcc/f/com.c egcc-CVS20020312/gcc/f/com.c
--- orig/egcc-CVS20020312/gcc/f/com.c Sun Mar 3 16:30:26 2002
+++ egcc-CVS20020312/gcc/f/com.c Tue Mar 12 13:38:42 2002
@@ -14224,6 +14224,37 @@ static void ffe_print_identifier PARAMS
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
+/* Table indexed by tree code giving a string containing a character
+ classifying the tree code. Possibilities are
+ t, d, s, c, r, <, 1, 2 and e. See tree.def for details. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+ operands beyond the fixed part of the node structure.
+ Not used for types or decls. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+ Used for printing out the tree and error messages. */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char *const tree_code_name[] = {
+#include "tree.def"
+};
+#undef DEFTREECODE
+
static const char *
ffe_init (filename)
const char *filename;
diff -rup orig/egcc-CVS20020312/gcc/java/lang.c egcc-CVS20020312/gcc/java/lang.c
--- orig/egcc-CVS20020312/gcc/java/lang.c Sun Mar 3 07:31:04 2002
+++ egcc-CVS20020312/gcc/java/lang.c Tue Mar 12 13:38:42 2002
@@ -70,7 +70,8 @@ static int process_option_with_no PARAMS
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-static const char java_tree_code_type[] = {
+const char tree_code_type[] = {
+#include "tree.def"
'x',
#include "java-tree.def"
};
@@ -82,7 +83,8 @@ static const char java_tree_code_type[]
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-static const int java_tree_code_length[] = {
+const unsigned char tree_code_length[] = {
+#include "tree.def"
0,
#include "java-tree.def"
};
@@ -92,7 +94,8 @@ static const int java_tree_code_length[]
Used for printing out the tree and error messages. */
#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-static const char *const java_tree_code_name[] = {
+const char *const tree_code_name[] = {
+#include "tree.def"
"@@dummy",
#include "java-tree.def"
};
@@ -505,19 +508,6 @@ java_init (filename)
print_error_function = lang_print_error;
lang_expand_expr = java_lang_expand_expr;
- /* Append to Gcc tree node definition arrays */
-
- memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
- java_tree_code_type,
- (int)LAST_JAVA_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
- memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
- java_tree_code_length,
- (LAST_JAVA_TREE_CODE -
- (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
- memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
- java_tree_code_name,
- (LAST_JAVA_TREE_CODE -
- (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
java_init_decl_processing ();
using_eh_for_cleanups ();
diff -rup orig/egcc-CVS20020312/gcc/objc/objc-act.c egcc-CVS20020312/gcc/objc/objc-act.c
--- orig/egcc-CVS20020312/gcc/objc/objc-act.c Tue Mar 12 00:36:28 2002
+++ egcc-CVS20020312/gcc/objc/objc-act.c Tue Mar 12 13:38:42 2002
@@ -86,40 +86,6 @@ Boston, MA 02111-1307, USA. */
#define OBJC_FORWARDING_MIN_OFFSET 0
#endif
-/* Define the special tree codes that we use. */
-
-/* Table indexed by tree code giving a string containing a character
- classifying the tree code. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-static const char objc_tree_code_type[] = {
- 'x',
-#include "objc-tree.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
- operands beyond the fixed part of the node structure.
- Not used for types or decls. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-static const int objc_tree_code_length[] = {
- 0,
-#include "objc-tree.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
- Used for printing out the tree and error messages. */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-static const char * const objc_tree_code_name[] = {
- "@@dummy",
-#include "objc-tree.def"
-};
-#undef DEFTREECODE
/* Set up for use of obstacks. */
@@ -270,7 +236,6 @@ static void dump_interface PARAMS ((FI
/* Everything else. */
-static void add_objc_tree_codes PARAMS ((void));
static tree define_decl PARAMS ((tree, tree));
static tree lookup_method_in_protocol_list PARAMS ((tree, tree, int));
static tree lookup_protocol_in_reflist PARAMS ((tree, tree));
@@ -511,7 +476,6 @@ objc_init (filename)
const char *filename;
{
filename = c_objc_common_init (filename);
- add_objc_tree_codes ();
decl_printable_name = objc_printable_name;
@@ -8070,22 +8034,6 @@ objc_printable_name (decl, kind)
int kind ATTRIBUTE_UNUSED;
{
return objc_demangle (IDENTIFIER_POINTER (DECL_NAME (decl)));
-}
-
-/* Adds the tree codes specific to the ObjC/ObjC++ front end to the
- list of all tree codes. */
-
-static void
-add_objc_tree_codes ()
-{
- int add = (int) LAST_OBJC_TREE_CODE - (int) LAST_BASE_TREE_CODE;
-
- memcpy (tree_code_type + (int) LAST_BASE_TREE_CODE,
- objc_tree_code_type, add);
- memcpy (tree_code_length + (int) LAST_BASE_TREE_CODE,
- objc_tree_code_length, add * sizeof (int));
- memcpy (tree_code_name + (int) LAST_BASE_TREE_CODE,
- objc_tree_code_name, add * sizeof (char *));
}
static void
diff -rup orig/egcc-CVS20020312/gcc/objc/objc-lang.c egcc-CVS20020312/gcc/objc/objc-lang.c
--- orig/egcc-CVS20020312/gcc/objc/objc-lang.c Thu Feb 28 07:39:52 2002
+++ egcc-CVS20020312/gcc/objc/objc-lang.c Tue Mar 12 13:38:42 2002
@@ -66,6 +66,50 @@ static void objc_post_options
/* Each front end provides its own hooks, for toplev.c. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
+/* Define the special tree codes that we use. */
+
+/* Table indexed by tree code giving a string containing a character
+ classifying the tree code. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+ 'x',
+#include "c-common.def"
+ 'x',
+#include "objc-tree.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+ operands beyond the fixed part of the node structure.
+ Not used for types or decls. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+ 0,
+#include "c-common.def"
+ 0,
+#include "objc-tree.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+ Used for printing out the tree and error messages. */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char * const tree_code_name[] = {
+#include "tree.def"
+ "@@dummy",
+#include "c-common.def"
+ "@@dummy",
+#include "objc-tree.def"
+};
+#undef DEFTREECODE
+
static void
objc_init_options ()
{
diff -rup orig/egcc-CVS20020312/gcc/toplev.c egcc-CVS20020312/gcc/toplev.c
--- orig/egcc-CVS20020312/gcc/toplev.c Tue Mar 12 00:36:28 2002
+++ egcc-CVS20020312/gcc/toplev.c Tue Mar 12 13:38:42 2002
@@ -4998,11 +4998,6 @@ lang_independent_init ()
decl_printable_name = decl_name;
lang_expand_expr = (lang_expand_expr_t) do_abort;
- /* Set the language-dependent identifier size. */
- tree_code_length[(int) IDENTIFIER_NODE]
- = ((lang_hooks.identifier_size - sizeof (struct tree_common)
- + sizeof (tree) - 1) / sizeof (tree));
-
/* Initialize the garbage-collector, and string pools. */
init_ggc ();
ggc_add_rtx_root (&stack_limit_rtx, 1);
diff -rup orig/egcc-CVS20020312/gcc/tree.c egcc-CVS20020312/gcc/tree.c
--- orig/egcc-CVS20020312/gcc/tree.c Fri Mar 8 15:09:51 2002
+++ egcc-CVS20020312/gcc/tree.c Tue Mar 12 13:38:42 2002
@@ -56,37 +56,6 @@ extern int _obstack_allocated_p PARAMS (
struct obstack permanent_obstack;
-/* Table indexed by tree code giving a string containing a character
- classifying the tree code. Possibilities are
- t, d, s, c, r, <, 1, 2 and e. See tree.def for details. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-char tree_code_type[MAX_TREE_CODES] = {
-#include "tree.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
- operands beyond the fixed part of the node structure.
- Not used for types or decls. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-int tree_code_length[MAX_TREE_CODES] = {
-#include "tree.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
- Used for printing out the tree and error messages. */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-const char *tree_code_name[MAX_TREE_CODES] = {
-#include "tree.def"
-};
-#undef DEFTREECODE
-
/* Statistics-gathering stuff. */
typedef enum
{
diff -rup orig/egcc-CVS20020312/gcc/tree.def egcc-CVS20020312/gcc/tree.def
--- orig/egcc-CVS20020312/gcc/tree.def Tue Feb 19 07:31:21 2002
+++ egcc-CVS20020312/gcc/tree.def Tue Mar 12 13:38:42 2002
@@ -49,7 +49,7 @@ DEFTREECODE (ERROR_MARK, "error_mark", '
Internally it looks like a STRING_CST node.
There is only one IDENTIFIER_NODE ever made for any particular name.
Use `get_identifier' to get it (or create it, the first time). */
-DEFTREECODE (IDENTIFIER_NODE, "identifier_node", 'x', -1)
+DEFTREECODE (IDENTIFIER_NODE, "identifier_node", 'x', ((LANG_HOOKS_IDENTIFIER_SIZE - sizeof (struct tree_common) + sizeof (tree) - 1) / sizeof (tree)))
/* Has the TREE_VALUE and TREE_PURPOSE fields. */
/* These nodes are made into lists by chaining through the
diff -rup orig/egcc-CVS20020312/gcc/tree.h egcc-CVS20020312/gcc/tree.h
--- orig/egcc-CVS20020312/gcc/tree.h Fri Mar 8 15:09:52 2002
+++ egcc-CVS20020312/gcc/tree.h Tue Mar 12 13:38:42 2002
@@ -46,7 +46,7 @@ enum tree_code {
and `x' for anything else (TREE_LIST, IDENTIFIER, etc). */
#define MAX_TREE_CODES 256
-extern char tree_code_type[MAX_TREE_CODES];
+extern const char tree_code_type[];
#define TREE_CODE_CLASS(CODE) tree_code_type[(int) (CODE)]
/* Returns non-zero iff CLASS is the tree-code class of an
@@ -57,12 +57,12 @@ extern char tree_code_type[MAX_TREE_CODE
/* Number of argument-words in each kind of tree-node. */
-extern int tree_code_length[MAX_TREE_CODES];
+extern const unsigned char tree_code_length[];
#define TREE_CODE_LENGTH(CODE) tree_code_length[(int) (CODE)]
/* Names of tree components. */
-extern const char *tree_code_name[MAX_TREE_CODES];
+extern const char *const tree_code_name[];
/* Classify which part of the compiler has defined a given builtin function.
Note that we assume below that this is no more than two bits. */
More information about the Gcc-patches
mailing list