diff options
author | Geoffrey Keating <geoffk@gcc.gnu.org> | 2003-01-10 02:22:34 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2003-01-10 02:22:34 +0000 |
commit | 17211ab55314d76370a68036f2d057b1effd687f (patch) | |
tree | a3ff2e89f1924fd7ea1d99358736bc8491352747 /gcc/cp | |
parent | 5f7c78d8a4df096dacfa2d9de367a6174dd631ba (diff) | |
download | gcc-17211ab55314d76370a68036f2d057b1effd687f.tar.gz |
Merge from pch-branch.
From-SVN: r61136
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 90 | ||||
-rw-r--r-- | gcc/cp/Make-lang.in | 25 | ||||
-rw-r--r-- | gcc/cp/call.c | 1 | ||||
-rw-r--r-- | gcc/cp/class.c | 133 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 27 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 4 | ||||
-rw-r--r-- | gcc/cp/g++spec.c | 96 | ||||
-rw-r--r-- | gcc/cp/init.c | 1 | ||||
-rw-r--r-- | gcc/cp/lang-specs.h | 13 | ||||
-rw-r--r-- | gcc/cp/lex.c | 6 | ||||
-rw-r--r-- | gcc/cp/method.c | 5 | ||||
-rw-r--r-- | gcc/cp/optimize.c | 1 | ||||
-rw-r--r-- | gcc/cp/parser.c | 68 | ||||
-rw-r--r-- | gcc/cp/pt.c | 1 | ||||
-rw-r--r-- | gcc/cp/repo.c | 1 | ||||
-rw-r--r-- | gcc/cp/search.c | 1 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 5 | ||||
-rw-r--r-- | gcc/cp/tree.c | 1 |
19 files changed, 374 insertions, 108 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2970abba965..fb530434027 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,93 @@ +2003-01-09 Geoffrey Keating <geoffk@apple.com> + + Merge from pch-branch: + + 2003-01-09 Geoffrey Keating <geoffk@apple.com> + + Merge to tag pch-merge-20030102: + + * semantics.c (finish_translation_unit): Don't call finish_file. + * parser.c: Don't include ggc.h. + (cp_lexer_new_main): Rename from cp_lexer_new, only create main lexer, + read first token here. Don't allow PCH files after the first + token is read. + (cp_lexer_new_from_tokens): Duplicate functionality from cp_lexer_new. + (cp_lexer_get_preprocessor_token): Allow LEXER to be NULL. + (cp_parser_new): Call cp_lexer_new_main before allocating GCed memory. + (cp_parser_late_parsing_for_member): Don't duplicate call to + cp_lexer_set_source_position_from_token. + (cp_parser_late_parsing_default_args): Likewise. + (yyparse): Call finish_file after clearing the_parser. + + 2002-12-11 Geoffrey Keating <geoffk@apple.com> + + * Make-lang.in: Remove $(GGC_H) from all dependencies. + (CXX_TREE_H): Add $(GGC_H). + * class.c: Don't include ggc.h. + (field_decl_cmp): Make parameters be 'const void *' to match qsort. + (method_name_cmp): Likewise. + (resort_data): New variable. + (resort_field_decl_cmp): New. + (resort_method_name_cmp): New. + (resort_sorted_fields): New. + (resort_type_method_vec): New. + (finish_struct_methods): Delete cast. + (finish_struct_1): Delete cast. + * cp-tree.h: Include ggc.h. + (struct lang_type_class): Add reorder attribute to field `methods'. + (union lang_decl_u3): Add reorder attribute to field `sorted_fields'. + (resort_sorted_fields): New prototype. + (resort_type_method_vec): New prototype. + * call.c: Don't include ggc.h. + * decl.c: Likewise. + * decl2.c: Likewise. + * init.c: Likewise. + * lex.c: Likewise. + * method.c: Likewise. + * optimize.c: Likewise. + * parse.y: Likewise. + * pt.c: Likewise. + * repo.c: Likewise. + * search.c: Likewise. + * semantics.c: Likewise. + * spew.c: Likewise. + * tree.c: Likewise. + + * lang-specs.h: Remove comment. + + 2002-12-03 Geoffrey Keating <geoffk@apple.com> + + * cp-tree.h (struct operator_name_info_t): Mark for GTY machinery. + (operator_name_info): Mark to be saved for PCH, specify size. + (assignment_operator_name_info): Likewise. + + 2002-11-19 Geoffrey Keating <geoffk@apple.com> + + * decl.c (anon_cnt): Mark to be saved for PCH. + + 2002-10-25 Geoffrey Keating <geoffk@apple.com> + + * lex.c (init_reswords): Delete now-untrue comment. + Allocate ridpointers using GGC. + + 2002-10-04 Geoffrey Keating <geoffk@apple.com> + + * cp-tree.h (union lang_decl_u2): Add tags to all fields. + + * g++spec.c (lang_specific_driver): Don't include standard + libraries in `added'. + + 2002-08-27 Geoffrey Keating <geoffk@redhat.com> + + * decl2.c (finish_file): Call c_common_write_pch. + * Make-lang.in (CXX_C_OBJS): Add c-pch.o. + + 2002-08-17 Geoffrey Keating <geoffk@redhat.com> + + * g++spec.c (lang_specific_driver): Treat .h files as C++ header + files when using g++. + * lang-specs.h: Handle compiling C++ header files. + 2003-01-09 Jakub Jelinek <jakub@redhat.com> * decl.c (start_decl): Only check DECL_THREAD_LOCAL for VAR_DECLs. diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index b54e3ba678f..347b71a906a 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -1,5 +1,5 @@ # Top level -*- makefile -*- fragment for GNU C++. -# Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002 +# Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. #This file is part of GCC. @@ -79,7 +79,7 @@ g++-cross$(exeext): g++$(exeext) # The compiler itself. # Shared with C front end: CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \ - c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o + c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o c-pch.o # Language-specific object files. CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \ @@ -210,34 +210,35 @@ c++.stage4: stage4-start # .o: .h dependencies. CXX_TREE_H = $(TREE_H) cp/cp-tree.h c-common.h cp/cp-tree.def c-common.def \ function.h varray.h $(SYSTEM_H) coretypes.h $(CONFIG_H) $(TARGET_H) \ + $(GGC_H) \ $(srcdir)/../include/hashtab.h $(srcdir)/../include/splay-tree.h cp/lex.o: cp/lex.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h \ - c-pragma.h toplev.h output.h mbchar.h $(GGC_H) input.h diagnostic.h \ + c-pragma.h toplev.h output.h mbchar.h input.h diagnostic.h \ cp/operators.def $(TM_P_H) cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) toplev.h langhooks.h \ $(LANGHOOKS_DEF_H) c-common.h cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h cp/decl.h stack.h \ - output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(GGC_H) $(RTL_H) \ + output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(RTL_H) \ cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h c-pragma.h \ debug.h gt-cp-decl.h gtype-cp.h cp/decl2.o: cp/decl2.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h cp/decl.h $(EXPR_H) \ - output.h except.h toplev.h $(GGC_H) $(RTL_H) c-common.h gt-cp-decl2.h + output.h except.h toplev.h $(RTL_H) c-common.h gt-cp-decl2.h cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h output.h $(TM_P_H) \ diagnostic.h cp/typeck.o: cp/typeck.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \ diagnostic.h cp/class.o: cp/class.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(TARGET_H) cp/call.o: cp/call.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(EXPR_H) \ - $(GGC_H) diagnostic.h gt-cp-call.h + diagnostic.h gt-cp-call.h cp/friend.o: cp/friend.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) toplev.h $(EXPR_H) cp/init.o: cp/init.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \ - $(GGC_H) except.h -cp/method.o: cp/method.c $(CXX_TREE_H) $(TM_H) toplev.h $(GGC_H) $(RTL_H) $(EXPR_H) \ + except.h +cp/method.o: cp/method.c $(CXX_TREE_H) $(TM_H) toplev.h $(RTL_H) $(EXPR_H) \ $(TM_P_H) $(TARGET_H) cp/cvt.o: cp/cvt.c $(CXX_TREE_H) $(TM_H) cp/decl.h flags.h toplev.h convert.h cp/search.o: cp/search.c $(CXX_TREE_H) $(TM_H) stack.h flags.h toplev.h $(RTL_H) -cp/tree.o: cp/tree.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(GGC_H) $(RTL_H) \ +cp/tree.o: cp/tree.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) \ insn-config.h integrate.h tree-inline.h real.h gt-cp-tree.h $(TARGET_H) cp/ptree.o: cp/ptree.c $(CXX_TREE_H) $(TM_H) cp/rtti.o: cp/rtti.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h @@ -246,13 +247,13 @@ cp/except.o: cp/except.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) except.h toplev. cp/expr.o: cp/expr.c $(CXX_TREE_H) $(TM_H) $(RTL_H) flags.h $(EXPR_H) toplev.h \ except.h $(TM_P_H) cp/pt.o: cp/pt.c $(CXX_TREE_H) $(TM_H) cp/decl.h cp/lex.h \ - toplev.h $(GGC_H) $(RTL_H) except.h tree-inline.h gt-cp-pt.h + toplev.h $(RTL_H) except.h tree-inline.h gt-cp-pt.h cp/error.o: cp/error.c $(CXX_TREE_H) $(TM_H) toplev.h diagnostic.h flags.h real.h \ $(LANGHOOKS_DEF_H) -cp/repo.o: cp/repo.c $(CXX_TREE_H) $(TM_H) toplev.h $(GGC_H) diagnostic.h \ +cp/repo.o: cp/repo.c $(CXX_TREE_H) $(TM_H) toplev.h diagnostic.h \ gt-cp-repo.h cp/semantics.o: cp/semantics.c $(CXX_TREE_H) $(TM_H) cp/lex.h except.h toplev.h \ - flags.h $(GGC_H) debug.h output.h $(RTL_H) $(TIMEVAR_H) $(EXPR_H) \ + flags.h debug.h output.h $(RTL_H) $(TIMEVAR_H) $(EXPR_H) \ tree-inline.h cp/dump.o: cp/dump.c $(CXX_TREE_H) $(TM_H) tree-dump.h cp/optimize.o: cp/optimize.c $(CXX_TREE_H) $(TM_H) rtl.h integrate.h insn-config.h \ diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 00458c06248..cd93f7bbe4b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -35,7 +35,6 @@ Boston, MA 02111-1307, USA. */ #include "rtl.h" #include "toplev.h" #include "expr.h" -#include "ggc.h" #include "diagnostic.h" extern int inhibit_warnings; diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 845ca19c738..bace3f4d7c9 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -33,7 +33,6 @@ Boston, MA 02111-1307, USA. */ #include "rtl.h" #include "output.h" #include "toplev.h" -#include "ggc.h" #include "lex.h" #include "target.h" @@ -125,8 +124,10 @@ static tree modify_all_vtables PARAMS ((tree, tree)); static void determine_primary_base PARAMS ((tree)); static void finish_struct_methods PARAMS ((tree)); static void maybe_warn_about_overly_private_class PARAMS ((tree)); -static int field_decl_cmp PARAMS ((const tree *, const tree *)); -static int method_name_cmp PARAMS ((const tree *, const tree *)); +static int field_decl_cmp PARAMS ((const void *, const void *)); +static int resort_field_decl_cmp PARAMS ((const void *, const void *)); +static int method_name_cmp PARAMS ((const void *, const void *)); +static int resort_method_name_cmp PARAMS ((const void *, const void *)); static void add_implicitly_declared_members PARAMS ((tree, int, int, int)); static tree fixed_type_or_null PARAMS ((tree, int *, int *)); static tree resolve_address_of_overloaded_function PARAMS ((tree, tree, int, @@ -1449,7 +1450,8 @@ mark_primary_virtual_base (base_binfo, type) base, then BINFO has no primary base in this graph. Called from mark_primary_bases. DATA is the most derived type. */ -static tree dfs_unshared_virtual_bases (binfo, data) +static tree +dfs_unshared_virtual_bases (binfo, data) tree binfo; void *data; { @@ -1923,9 +1925,11 @@ maybe_warn_about_overly_private_class (t) /* Function to help qsort sort FIELD_DECLs by name order. */ static int -field_decl_cmp (x, y) - const tree *x, *y; +field_decl_cmp (x_p, y_p) + const void *x_p, *y_p; { + const tree *const x = x_p; + const tree *const y = y_p; if (DECL_NAME (*x) == DECL_NAME (*y)) /* A nontype is "greater" than a type. */ return DECL_DECLARES_TYPE_P (*y) - DECL_DECLARES_TYPE_P (*x); @@ -1938,12 +1942,64 @@ field_decl_cmp (x, y) return 1; } +static struct { + gt_pointer_operator new_value; + void *cookie; +} resort_data; + +/* This routine compares two fields like field_decl_cmp but using the + pointer operator in resort_data. */ + +static int +resort_field_decl_cmp (x_p, y_p) + const void *x_p, *y_p; +{ + const tree *const x = x_p; + const tree *const y = y_p; + + if (DECL_NAME (*x) == DECL_NAME (*y)) + /* A nontype is "greater" than a type. */ + return DECL_DECLARES_TYPE_P (*y) - DECL_DECLARES_TYPE_P (*x); + if (DECL_NAME (*x) == NULL_TREE) + return -1; + if (DECL_NAME (*y) == NULL_TREE) + return 1; + { + tree d1 = DECL_NAME (*x); + tree d2 = DECL_NAME (*y); + resort_data.new_value (&d1, resort_data.cookie); + resort_data.new_value (&d2, resort_data.cookie); + if (d1 < d2) + return -1; + } + return 1; +} + +/* Resort DECL_SORTED_FIELDS because pointers have been reordered. */ + +void +resort_sorted_fields (obj, orig_obj, new_value, cookie) + void *obj; + void *orig_obj; + gt_pointer_operator new_value; + void *cookie; +{ + tree sf = obj; + resort_data.new_value = new_value; + resort_data.cookie = cookie; + qsort (&TREE_VEC_ELT (sf, 0), TREE_VEC_LENGTH (sf), sizeof (tree), + resort_field_decl_cmp); +} + /* Comparison function to compare two TYPE_METHOD_VEC entries by name. */ static int -method_name_cmp (m1, m2) - const tree *m1, *m2; +method_name_cmp (m1_p, m2_p) + const void *m1_p, *m2_p; { + const tree *const m1 = m1_p; + const tree *const m2 = m2_p; + if (*m1 == NULL_TREE && *m2 == NULL_TREE) return 0; if (*m1 == NULL_TREE) @@ -1955,6 +2011,63 @@ method_name_cmp (m1, m2) return 1; } +/* This routine compares two fields like method_name_cmp but using the + pointer operator in resort_field_decl_data. */ + +static int +resort_method_name_cmp (m1_p, m2_p) + const void *m1_p, *m2_p; +{ + const tree *const m1 = m1_p; + const tree *const m2 = m2_p; + if (*m1 == NULL_TREE && *m2 == NULL_TREE) + return 0; + if (*m1 == NULL_TREE) + return -1; + if (*m2 == NULL_TREE) + return 1; + { + tree d1 = DECL_NAME (OVL_CURRENT (*m1)); + tree d2 = DECL_NAME (OVL_CURRENT (*m2)); + resort_data.new_value (&d1, resort_data.cookie); + resort_data.new_value (&d2, resort_data.cookie); + if (d1 < d2) + return -1; + } + return 1; +} + +/* Resort TYPE_METHOD_VEC because pointers have been reordered. */ + +void +resort_type_method_vec (obj, orig_obj, new_value, cookie) + void *obj; + void *orig_obj; + gt_pointer_operator new_value; + void *cookie; +{ + tree method_vec = obj; + int len = TREE_VEC_LENGTH (method_vec); + int slot; + + /* The type conversion ops have to live at the front of the vec, so we + can't sort them. */ + for (slot = 2; slot < len; ++slot) + { + tree fn = TREE_VEC_ELT (method_vec, slot); + + if (!DECL_CONV_FN_P (OVL_CURRENT (fn))) + break; + } + if (len - slot > 1) + { + resort_data.new_value = new_value; + resort_data.cookie = cookie; + qsort (&TREE_VEC_ELT (method_vec, slot), len - slot, sizeof (tree), + resort_method_name_cmp); + } +} + /* Warn about duplicate methods in fn_fields. Also compact method lists so that lookup can be made faster. @@ -2025,7 +2138,7 @@ finish_struct_methods (t) } if (len - slot > 1) qsort (&TREE_VEC_ELT (method_vec, slot), len-slot, sizeof (tree), - (int (*)(const void *, const void *))method_name_cmp); + method_name_cmp); } /* Emit error when a duplicate definition of a type is seen. Patch up. */ @@ -5418,7 +5531,7 @@ finish_struct_1 (t) tree field_vec = make_tree_vec (n_fields); add_fields_to_vec (TYPE_FIELDS (t), field_vec, 0); qsort (&TREE_VEC_ELT (field_vec, 0), n_fields, sizeof (tree), - (int (*)(const void *, const void *))field_decl_cmp); + field_decl_cmp); if (! DECL_LANG_SPECIFIC (TYPE_MAIN_DECL (t))) retrofit_lang_decl (TYPE_MAIN_DECL (t)); DECL_SORTED_FIELDS (TYPE_MAIN_DECL (t)) = field_vec; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8f77d10bab7..aad82c019b2 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1,5 +1,5 @@ /* Definitions for C++ parsing and type checking. - Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com) @@ -23,6 +23,7 @@ Boston, MA 02111-1307, USA. */ #ifndef GCC_CP_TREE_H #define GCC_CP_TREE_H +#include "ggc.h" #include "function.h" #include "hashtab.h" #include "splay-tree.h" @@ -1182,7 +1183,7 @@ struct lang_type_class GTY(()) tree as_base; tree pure_virtuals; tree friend_classes; - tree methods; + tree GTY ((reorder ("resort_type_method_vec"))) methods; tree key_method; tree decl_list; tree template_info; @@ -1782,7 +1783,7 @@ struct lang_decl_flags GTY(()) tree GTY ((tag ("0"))) access; /* For VAR_DECL in function, this is DECL_DISCRIMINATOR. */ - int discriminator; + int GTY ((tag ("1"))) discriminator; /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is THUNK_VIRTUAL_OFFSET. */ @@ -1790,6 +1791,9 @@ struct lang_decl_flags GTY(()) } GTY ((desc ("%1.u2sel"))) u2; }; +/* sorted_fields is sorted based on a pointer, so we need to be able + to resort it if pointers get rearranged. */ + struct lang_decl GTY(()) { struct lang_decl_flags decl_flags; @@ -1827,7 +1831,8 @@ struct lang_decl GTY(()) union lang_decl_u3 { - tree GTY ((tag ("0"))) sorted_fields; + tree GTY ((tag ("0"), reorder ("resort_sorted_fields"))) + sorted_fields; struct cp_token_cache * GTY ((tag ("2"))) pending_inline_info; struct language_function * GTY ((tag ("1"))) saved_language_function; @@ -3555,7 +3560,7 @@ extern void init_reswords PARAMS ((void)); opname_tab[(int) MINUS_EXPR] == "-". */ extern const char **opname_tab, **assignop_tab; -typedef struct operator_name_info_t +typedef struct operator_name_info_t GTY(()) { /* The IDENTIFIER_NODE for the operator. */ tree identifier; @@ -3568,9 +3573,11 @@ typedef struct operator_name_info_t } operator_name_info_t; /* A mapping from tree codes to operator name information. */ -extern operator_name_info_t operator_name_info[]; +extern GTY(()) operator_name_info_t operator_name_info + [(int) LAST_CPLUS_TREE_CODE]; /* Similar, but for assignment operators. */ -extern operator_name_info_t assignment_operator_name_info[]; +extern GTY(()) operator_name_info_t assignment_operator_name_info + [(int) LAST_CPLUS_TREE_CODE]; /* in call.c */ extern bool check_dtor_name (tree, tree); @@ -3611,10 +3618,14 @@ extern tree in_charge_arg_for_name (tree); /* in class.c */ extern tree build_base_path PARAMS ((enum tree_code, tree, tree, int)); -extern tree convert_to_base (tree, tree, bool); +extern tree convert_to_base PARAMS ((tree, tree, bool)); extern tree build_vtbl_ref PARAMS ((tree, tree)); extern tree build_vfn_ref PARAMS ((tree, tree)); extern tree get_vtable_decl PARAMS ((tree, int)); +extern void resort_sorted_fields + PARAMS ((void *, void *, gt_pointer_operator, void *)); +extern void resort_type_method_vec + PARAMS ((void *, void *, gt_pointer_operator, void *)); extern void add_method PARAMS ((tree, tree, int)); extern int currently_open_class PARAMS ((tree)); extern tree currently_open_derived_class PARAMS ((tree)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 35a14e8cbe0..29a7a7fb93b 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -44,7 +44,6 @@ Boston, MA 02111-1307, USA. */ #include "except.h" #include "toplev.h" #include "hashtab.h" -#include "ggc.h" #include "tm_p.h" #include "target.h" #include "c-common.h" @@ -2731,7 +2730,7 @@ pushtag (tree name, tree type, int globalize) /* Counter used to create anonymous type names. */ -static int anon_cnt = 0; +static GTY(()) int anon_cnt; /* Return an IDENTIFIER which can be used as a name for anonymous structs and unions. */ diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 6363007b4ef..2491c8a3979 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -42,7 +42,6 @@ Boston, MA 02111-1307, USA. */ #include "output.h" #include "except.h" #include "toplev.h" -#include "ggc.h" #include "timevar.h" #include "cpplib.h" #include "target.h" @@ -2589,6 +2588,9 @@ finish_file () if (! global_bindings_p () || current_class_type || decl_namespace_list) return; + if (pch_file) + c_common_write_pch (); + /* Otherwise, GDB can get confused, because in only knows about source for LINENO-1 lines. */ lineno -= 1; diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c index 8c1e3ae98f1..75a1d7c28a4 100644 --- a/gcc/cp/g++spec.c +++ b/gcc/cp/g++spec.c @@ -60,14 +60,16 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) /* If nonzero, the user gave us the `-v' flag. */ int saw_verbose_flag = 0; - /* This will be 0 if we encounter a situation where we should not - link in libstdc++. */ - int library = 1; + /* This is a tristate: + -1 means we should not link in libstdc++ + 0 means we should link in libstdc++ if it is needed + 1 means libstdc++ is needed and should be linked in. */ + int library = 0; /* The number of arguments being added to what's in argv, other than libraries. We use this to track the number of times we've inserted -xc++/-xnone. */ - int added = 2; + int added = 0; /* Used to track options that take arguments, so we don't go wrapping those with -xc++/-xnone. */ @@ -131,10 +133,10 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) if (argv[i][0] == '-') { - if (library != 0 && (strcmp (argv[i], "-nostdlib") == 0 - || strcmp (argv[i], "-nodefaultlibs") == 0)) + if (strcmp (argv[i], "-nostdlib") == 0 + || strcmp (argv[i], "-nodefaultlibs") == 0) { - library = 0; + library = -1; } else if (strcmp (argv[i], "-lm") == 0 || strcmp (argv[i], "-lmath") == 0 @@ -152,31 +154,37 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) else if (strcmp (argv[i], "-pg") == 0 || strcmp (argv[i], "-p") == 0) saw_profile_flag++; else if (strcmp (argv[i], "-v") == 0) + saw_verbose_flag = 1; + else if (strncmp (argv[i], "-x", 2) == 0) { - saw_verbose_flag = 1; - if (argc == 2) + if (library == 0) { - /* If they only gave us `-v', don't try to link - in libg++. */ - library = 0; + const char * arg; + if (argv[i][2] != '\0') + arg = argv[i]+2; + else if (argv[i+1] != NULL) + arg = argv[i+1]; + else /* Error condition, message will be printed later. */ + arg = ""; + if (strcmp (arg, "c++") == 0 + || strcmp (arg, "c++-cpp-output") == 0) + library = 1; } + saw_speclang = 1; } - else if (strncmp (argv[i], "-x", 2) == 0) - saw_speclang = 1; else if (((argv[i][2] == '\0' && (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL) || strcmp (argv[i], "-Xlinker") == 0 || strcmp (argv[i], "-Tdata") == 0)) quote = argv[i]; - else if (library != 0 && ((argv[i][2] == '\0' - && (char *) strchr ("cSEM", argv[i][1]) != NULL) - || strcmp (argv[i], "-MM") == 0 - || strcmp (argv[i], "-fsyntax-only") == 0)) + else if ((argv[i][2] == '\0' + && (char *) strchr ("cSEM", argv[i][1]) != NULL) + || strcmp (argv[i], "-MM") == 0 + || strcmp (argv[i], "-fsyntax-only") == 0) { /* Don't specify libraries if we won't link, since that would cause a warning. */ - library = 0; - added -= 2; + library = -1; } else if (strcmp (argv[i], "-static-libgcc") == 0 || strcmp (argv[i], "-static") == 0) @@ -195,16 +203,28 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) continue; } - /* If the filename ends in .c or .i, put options around it. + /* If the filename ends in .[chi], put options around it. But not if a specified -x option is currently active. */ len = strlen (argv[i]); if (len > 2 - && (argv[i][len - 1] == 'c' || argv[i][len - 1] == 'i') + && (argv[i][len - 1] == 'c' + || argv[i][len - 1] == 'i' + || argv[i][len - 1] == 'h') && argv[i][len - 2] == '.') { args[i] |= LANGSPEC; added += 2; } + + /* If we don't know that this is a header file, we might + need to be linking in the libraries. */ + if (library == 0) + { + if ((len <= 2 || strcmp (argv[i] + (len - 2), ".H") != 0) + && (len <= 2 || strcmp (argv[i] + (len - 2), ".h") != 0) + && (len <= 3 || strcmp (argv[i] + (len - 3), ".hh") != 0)) + library = 1; + } } } @@ -212,7 +232,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) fatal ("argument to `%s' missing\n", quote); /* If we know we don't have to do anything, bail now. */ - if (! added && ! library) + if (! added && library <= 0) { free (args); return; @@ -225,7 +245,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) #endif /* Make sure to have room for the trailing NULL argument. */ - num_args = argc + added + need_math + shared_libgcc + 1; + num_args = argc + added + need_math + shared_libgcc + (library > 0) + 1; arglist = (const char **) xmalloc (num_args * sizeof (char *)); i = 0; @@ -241,27 +261,37 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) /* Make sure -lstdc++ is before the math library, since libstdc++ itself uses those math routines. */ - if (!saw_math && (args[i] & MATHLIB) && library) + if (!saw_math && (args[i] & MATHLIB) && library > 0) { --j; saw_math = argv[i]; } - if (!saw_libc && (args[i] & WITHLIBC) && library) + if (!saw_libc && (args[i] & WITHLIBC) && library > 0) { --j; saw_libc = argv[i]; } - /* Wrap foo.c and foo.i files in a language specification to + /* Wrap foo.[chi] files in a language specification to force the gcc compiler driver to run cc1plus on them. */ if (args[i] & LANGSPEC) { int len = strlen (argv[i]); - if (argv[i][len - 1] == 'i') - arglist[j++] = "-xc++-cpp-output"; - else - arglist[j++] = "-xc++"; + switch (argv[i][len - 1]) + { + case 'c': + arglist[j++] = "-xc++"; + break; + case 'i': + arglist[j++] = "-xc++-cpp-output"; + break; + case 'h': + arglist[j++] = "-xc++-header"; + break; + default: + abort (); + } arglist[j++] = argv[i]; arglist[j] = "-xnone"; } @@ -271,7 +301,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) } /* Add `-lstdc++' if we haven't already done so. */ - if (library) + if (library > 0) { arglist[j++] = saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX; added_libraries++; @@ -285,7 +315,7 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) } if (saw_math) arglist[j++] = saw_math; - else if (library && need_math) + else if (library > 0 && need_math) { arglist[j++] = saw_profile_flag ? MATH_LIBRARY_PROFILE : MATH_LIBRARY; added_libraries++; diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 2fd0c50779b..964ee1e0c12 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -34,7 +34,6 @@ Boston, MA 02111-1307, USA. */ #include "output.h" #include "except.h" #include "toplev.h" -#include "ggc.h" static void construct_virtual_base (tree, tree); static void expand_aggr_init_1 PARAMS ((tree, tree, tree, tree, int)); diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h index e8264676449..cf4ca4cee36 100644 --- a/gcc/cp/lang-specs.h +++ b/gcc/cp/lang-specs.h @@ -33,6 +33,19 @@ Boston, MA 02111-1307, USA. */ {".c++", "@c++", 0}, {".C", "@c++", 0}, {".CPP", "@c++", 0}, + {".H", "@c++-header", 0}, + {".hh", "@c++-header", 0}, + {"@c++-header", + "%{E|M|MM:cc1plus -E %{!no-gcc:-D__GNUG__=%v1}\ + %(cpp_options) %2 %(cpp_debug_options)}\ + %{!E:%{!M:%{!MM:\ + %{save-temps:cc1plus -E %{!no-gcc:-D__GNUG__=%v1}\ + %(cpp_options) %2 %b.ii \n}\ + cc1plus %{save-temps:-fpreprocessed %b.ii}\ + %{!save-temps:%(cpp_unique_options) %{!no-gcc:-D__GNUG__=%v1}}\ + %(cc1_options) %2 %{+e1*}\ + -o %g.s %{!o*:--output-pch=%i.pch} %W{o*:--output-pch=%*}%V}}}", + CPLUSPLUS_CPP_SPEC}, {"@c++", "%{E|M|MM:cc1plus -E %{!no-gcc:-D__GNUG__=%v1}\ %(cpp_options) %2 %(cpp_debug_options)}\ diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 29753992b54..5749fc463b7 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -36,7 +36,6 @@ Boston, MA 02111-1307, USA. */ #include "c-pragma.h" #include "toplev.h" #include "output.h" -#include "ggc.h" #include "tm_p.h" #include "timevar.h" #include "diagnostic.h" @@ -380,10 +379,7 @@ init_reswords () int mask = ((flag_no_asm ? D_ASM : 0) | (flag_no_gnu_keywords ? D_EXT : 0)); - /* It is not necessary to register ridpointers as a GC root, because - all the trees it points to are permanently interned in the - get_identifier hash anyway. */ - ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree)); + ridpointers = (tree *) ggc_calloc ((int) RID_MAX, sizeof (tree)); for (i = 0; i < ARRAY_SIZE (reswords); i++) { id = get_identifier (reswords[i].word); diff --git a/gcc/cp/method.c b/gcc/cp/method.c index f4960b29c53..883a81f73fd 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1,7 +1,7 @@ /* Handle the hair of processing (but not expanding) inline functions. Also manage function and variable name overloading. - Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com) This file is part of GCC. @@ -34,7 +34,6 @@ Boston, MA 02111-1307, USA. */ #include "output.h" #include "flags.h" #include "toplev.h" -#include "ggc.h" #include "tm_p.h" #include "target.h" diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index fe924f4aae4..8f08c9ac22b 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -31,7 +31,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "integrate.h" #include "toplev.h" #include "varray.h" -#include "ggc.h" #include "params.h" #include "hashtab.h" #include "debug.h" diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e88045dc117..629ba5d8178 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -32,7 +32,6 @@ #include "decl.h" #include "flags.h" #include "diagnostic.h" -#include "ggc.h" #include "toplev.h" #include "output.h" @@ -213,8 +212,8 @@ typedef struct cp_lexer GTY (()) /* Prototypes. */ -static cp_lexer *cp_lexer_new - PARAMS ((bool)); +static cp_lexer *cp_lexer_new_main + PARAMS ((void)); static cp_lexer *cp_lexer_new_from_tokens PARAMS ((struct cp_token_cache *)); static int cp_lexer_saving_tokens @@ -292,29 +291,37 @@ static void cp_lexer_stop_debugging /* The stream to which debugging output should be written. */ static FILE *cp_lexer_debug_stream; -/* Create a new C++ lexer. If MAIN_LEXER_P is true the new lexer is - the main lexer -- i.e, the lexer that gets tokens from the - preprocessor. Otherwise, it is a lexer that uses a cache of stored - tokens. */ +/* Create a new main C++ lexer, the lexer that gets tokens from the + preprocessor. */ static cp_lexer * -cp_lexer_new (bool main_lexer_p) +cp_lexer_new_main (void) { cp_lexer *lexer; + cp_token first_token; + + /* It's possible that lexing the first token will load a PCH file, + which is a GC collection point. So we have to grab the first + token before allocating any memory. */ + cp_lexer_get_preprocessor_token (NULL, &first_token); + cpp_get_callbacks (parse_in)->valid_pch = NULL; /* Allocate the memory. */ lexer = (cp_lexer *) ggc_alloc_cleared (sizeof (cp_lexer)); /* Create the circular buffer. */ lexer->buffer = ((cp_token *) - ggc_alloc (CP_TOKEN_BUFFER_SIZE * sizeof (cp_token))); + ggc_calloc (CP_TOKEN_BUFFER_SIZE, sizeof (cp_token))); lexer->buffer_end = lexer->buffer + CP_TOKEN_BUFFER_SIZE; - /* There are no tokens in the buffer. */ - lexer->last_token = lexer->buffer; + /* There is one token in the buffer. */ + lexer->last_token = lexer->buffer + 1; + lexer->first_token = lexer->buffer; + lexer->next_token = lexer->buffer; + memcpy (lexer->buffer, &first_token, sizeof (cp_token)); /* This lexer obtains more tokens by calling c_lex. */ - lexer->main_lexer_p = main_lexer_p; + lexer->main_lexer_p = true; /* Create the SAVED_TOKENS stack. */ VARRAY_INT_INIT (lexer->saved_tokens, CP_SAVED_TOKENS_SIZE, "saved_tokens"); @@ -339,15 +346,14 @@ cp_lexer_new_from_tokens (cp_token_cache *tokens) cp_token_block *block; ptrdiff_t num_tokens; - /* Create the lexer. */ - lexer = cp_lexer_new (/*main_lexer_p=*/false); + /* Allocate the memory. */ + lexer = (cp_lexer *) ggc_alloc_cleared (sizeof (cp_lexer)); /* Create a new buffer, appropriately sized. */ num_tokens = 0; for (block = tokens->first; block != NULL; block = block->next) num_tokens += block->num_tokens; - lexer->buffer = ((cp_token *) - ggc_alloc (num_tokens * sizeof (cp_token))); + lexer->buffer = ((cp_token *) ggc_alloc (num_tokens * sizeof (cp_token))); lexer->buffer_end = lexer->buffer + num_tokens; /* Install the tokens. */ @@ -365,6 +371,18 @@ cp_lexer_new_from_tokens (cp_token_cache *tokens) /* The buffer is full. */ lexer->last_token = lexer->first_token; + /* This lexer doesn't obtain more tokens. */ + lexer->main_lexer_p = false; + + /* Create the SAVED_TOKENS stack. */ + VARRAY_INT_INIT (lexer->saved_tokens, CP_SAVED_TOKENS_SIZE, "saved_tokens"); + + /* Create the STRINGS array. */ + VARRAY_TREE_INIT (lexer->string_tokens, 32, "strings"); + + /* Assume we are not debugging. */ + lexer->debugging_p = false; + return lexer; } @@ -610,7 +628,7 @@ cp_lexer_get_preprocessor_token (lexer, token) bool done; /* If this not the main lexer, return a terminating CPP_EOF token. */ - if (!lexer->main_lexer_p) + if (lexer != NULL && !lexer->main_lexer_p) { token->type = CPP_EOF; token->line_number = 0; @@ -2472,9 +2490,14 @@ static cp_parser * cp_parser_new () { cp_parser *parser; + cp_lexer *lexer; + + /* cp_lexer_new_main is called before calling ggc_alloc because + cp_lexer_new_main might load a PCH file. */ + lexer = cp_lexer_new_main (); parser = (cp_parser *) ggc_alloc_cleared (sizeof (cp_parser)); - parser->lexer = cp_lexer_new (/*main_lexer_p=*/true); + parser->lexer = lexer; parser->context = cp_parser_context_new (NULL); /* For now, we always accept GNU extensions. */ @@ -14422,9 +14445,7 @@ cp_parser_late_parsing_for_member (parser, member_function) /* Set the current source position to be the location of the first token in the saved inline body. */ - cp_lexer_set_source_position_from_token - (parser->lexer, - cp_lexer_peek_token (parser->lexer)); + (void) cp_lexer_peek_token (parser->lexer); /* Let the front end know that we going to be defining this function. */ @@ -14477,8 +14498,7 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn) /* Set the current source position to be the location of the first token in the default argument. */ - cp_lexer_set_source_position_from_token - (parser->lexer, cp_lexer_peek_token (parser->lexer)); + (void) cp_lexer_peek_token (parser->lexer); /* Local variable names (and the `this' keyword) may not appear in a default argument. */ @@ -14996,6 +15016,8 @@ yyparse () the_parser = cp_parser_new (); error_occurred = cp_parser_translation_unit (the_parser); the_parser = NULL; + + finish_file (); return error_occurred; } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7802e25b573..e7486afca25 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -41,7 +41,6 @@ Boston, MA 02111-1307, USA. */ #include "except.h" #include "toplev.h" #include "rtl.h" -#include "ggc.h" #include "timevar.h" /* The type of functions taking a tree, and some additional data, and diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index 105e4df51ac..603b04eef06 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -35,7 +35,6 @@ Boston, MA 02111-1307, USA. */ #include "input.h" #include "obstack.h" #include "toplev.h" -#include "ggc.h" #include "diagnostic.h" static tree repo_get_id (tree); diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 13ed4b0aa53..5e9b3955ad4 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -33,7 +33,6 @@ Boston, MA 02111-1307, USA. */ #include "flags.h" #include "rtl.h" #include "output.h" -#include "ggc.h" #include "toplev.h" #include "stack.h" diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0aeaa0db77e..3ed9f2e20a3 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3,7 +3,7 @@ building RTL. These routines are used both during actual parsing and during the instantiation of template functions. - Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Written by Mark Mitchell (mmitchell@usa.net) based on code found formerly in parse.y and pt.c. @@ -35,7 +35,6 @@ #include "lex.h" #include "toplev.h" #include "flags.h" -#include "ggc.h" #include "rtl.h" #include "expr.h" #include "output.h" @@ -1628,8 +1627,6 @@ finish_translation_unit () /* Do file scope __FUNCTION__ et al. */ finish_fname_decls (); - - finish_file (); } /* Finish a template type parameter, specified as AGGR IDENTIFIER. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 93c62dac158..a3b6ff14a4f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -30,7 +30,6 @@ Boston, MA 02111-1307, USA. */ #include "real.h" #include "rtl.h" #include "toplev.h" -#include "ggc.h" #include "insn-config.h" #include "integrate.h" #include "tree-inline.h" |