aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2002-12-12 04:12:54 +0000
committerGeoffrey Keating <geoffk@apple.com>2002-12-12 04:12:54 +0000
commitd4ac54a42ab7774cb5b1a84fccd63a0831204395 (patch)
tree93330072b2daa42f3c5bcbaf56825ba1896c988b
parent5cf6b0dcae3e86a05262a86b86124e52ad190336 (diff)
Index: ChangeLog
2002-12-11 Geoffrey Keating <geoffk@apple.com> * gengtype.c (struct write_types_data): Add reorder_note_routine field. (struct walk_type_data): Add reorder_fn field. (walk_type): Process 'reorder' option. (write_types_process_field): Reorder parameters to gt_pch_note_object, call reorder_note_routine. (write_func_for_structure): Reorder parameters to gt_pch_note_object. (ggc_wtd): Update for change to struct write_types_data. (pch_wtd): Likewise. * ggc.h (gt_pch_note_object): Reorder parameters. (gt_handle_reorder): New definition. (gt_pch_note_reorder): New prototype. * ggc-common.c (struct ptr_data): Add reorder_fn. (gt_pch_note_object): Reorder parameters. (gt_pch_note_reorder): New. (gt_pch_save): Call reorder_fn. * stringpool.c (gt_pch_n_S): Update for change to gt_pch_note_object. * dbxout.c (cwd): Don't mark for PCH. Index: cp/ChangeLog 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. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/pch-branch@60057 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog21
-rw-r--r--gcc/cp/ChangeLog36
-rw-r--r--gcc/cp/Make-lang.in26
-rw-r--r--gcc/cp/call.c1
-rw-r--r--gcc/cp/class.c133
-rw-r--r--gcc/cp/cp-tree.h15
-rw-r--r--gcc/cp/decl.c1
-rw-r--r--gcc/cp/decl2.c1
-rw-r--r--gcc/cp/init.c1
-rw-r--r--gcc/cp/lang-specs.h2
-rw-r--r--gcc/cp/lex.c1
-rw-r--r--gcc/cp/method.c5
-rw-r--r--gcc/cp/optimize.c1
-rw-r--r--gcc/cp/parse.y1
-rw-r--r--gcc/cp/pt.c1
-rw-r--r--gcc/cp/repo.c3
-rw-r--r--gcc/cp/search.c1
-rw-r--r--gcc/cp/semantics.c1
-rw-r--r--gcc/cp/spew.c1
-rw-r--r--gcc/cp/tree.c1
-rw-r--r--gcc/dbxout.c2
-rw-r--r--gcc/gengtype.c31
-rw-r--r--gcc/ggc-common.c32
-rw-r--r--gcc/ggc.h18
-rw-r--r--gcc/stringpool.c2
-rw-r--r--gcc/testsuite/g++.dg/pch/pch.exp76
-rw-r--r--gcc/testsuite/g++.dg/pch/system-1.C7
-rw-r--r--gcc/testsuite/g++.dg/pch/system-1.H1
28 files changed, 342 insertions, 80 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d056fee2add..55902623605 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,24 @@
+2002-12-11 Geoffrey Keating <geoffk@apple.com>
+
+ * gengtype.c (struct write_types_data): Add reorder_note_routine field.
+ (struct walk_type_data): Add reorder_fn field.
+ (walk_type): Process 'reorder' option.
+ (write_types_process_field): Reorder parameters to gt_pch_note_object,
+ call reorder_note_routine.
+ (write_func_for_structure): Reorder parameters to gt_pch_note_object.
+ (ggc_wtd): Update for change to struct write_types_data.
+ (pch_wtd): Likewise.
+ * ggc.h (gt_pch_note_object): Reorder parameters.
+ (gt_handle_reorder): New definition.
+ (gt_pch_note_reorder): New prototype.
+ * ggc-common.c (struct ptr_data): Add reorder_fn.
+ (gt_pch_note_object): Reorder parameters.
+ (gt_pch_note_reorder): New.
+ (gt_pch_save): Call reorder_fn.
+ * stringpool.c (gt_pch_n_S): Update for change to gt_pch_note_object.
+
+ * dbxout.c (cwd): Don't mark for PCH.
+
2002-12-09 Geoffrey Keating <geoffk@apple.com>
* gengtype.c (finish_root_table): Fix some warnings.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1cb307d56b0..92958eb1835 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,39 @@
+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.
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 2aee1730b38..568cfbd225a 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
+# Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
#This file is part of GNU CC.
@@ -219,37 +219,37 @@ 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) $(CONFIG_H) $(TARGET_H) \
+ function.h varray.h $(SYSTEM_H) $(CONFIG_H) $(TARGET_H) $(GGC_H) \
$(srcdir)/../include/hashtab.h $(srcdir)/../include/splay-tree.h
cp/spew.o: cp/spew.c $(CXX_TREE_H) $(srcdir)/cp/parse.h flags.h cp/lex.h \
toplev.h gt-cp-spew.h
cp/lex.o: cp/lex.c $(CXX_TREE_H) $(srcdir)/cp/parse.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) toplev.h langhooks.h $(LANGHOOKS_DEF_H) \
c-common.h
cp/decl.o: cp/decl.c $(CXX_TREE_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) 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) flags.h toplev.h output.h $(TM_P_H) \
diagnostic.h
cp/typeck.o: cp/typeck.c $(CXX_TREE_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
diagnostic.h
cp/class.o: cp/class.c $(CXX_TREE_H) flags.h toplev.h $(RTL_H) $(TARGET_H)
cp/call.o: cp/call.c $(CXX_TREE_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) flags.h $(RTL_H) toplev.h $(EXPR_H)
cp/init.o: cp/init.c $(CXX_TREE_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
- $(GGC_H) except.h
-cp/method.o: cp/method.c $(CXX_TREE_H) toplev.h $(GGC_H) $(RTL_H) $(EXPR_H) \
+ except.h
+cp/method.o: cp/method.c $(CXX_TREE_H) toplev.h $(RTL_H) $(EXPR_H) \
$(TM_P_H) $(TARGET_H)
cp/cvt.o: cp/cvt.c $(CXX_TREE_H) cp/decl.h flags.h toplev.h convert.h
cp/search.o: cp/search.c $(CXX_TREE_H) stack.h flags.h toplev.h $(RTL_H)
-cp/tree.o: cp/tree.c $(CXX_TREE_H) flags.h toplev.h $(GGC_H) $(RTL_H) \
+cp/tree.o: cp/tree.c $(CXX_TREE_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) $(SYSTEM_H)
cp/rtti.o: cp/rtti.c $(CXX_TREE_H) flags.h toplev.h
@@ -258,13 +258,13 @@ cp/except.o: cp/except.c $(CXX_TREE_H) flags.h $(RTL_H) except.h toplev.h \
cp/expr.o: cp/expr.c $(CXX_TREE_H) $(RTL_H) flags.h $(EXPR_H) toplev.h \
except.h $(TM_P_H)
cp/pt.o: cp/pt.c $(CXX_TREE_H) cp/decl.h $(srcdir)/cp/parse.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) toplev.h diagnostic.h flags.h real.h \
$(LANGHOOKS_DEF_H)
-cp/repo.o: cp/repo.c $(CXX_TREE_H) toplev.h $(GGC_H) diagnostic.h \
+cp/repo.o: cp/repo.c $(CXX_TREE_H) toplev.h diagnostic.h \
gt-cp-repo.h
cp/semantics.o: cp/semantics.c $(CXX_TREE_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) tree-dump.h
cp/optimize.o: cp/optimize.c $(CXX_TREE_H) rtl.h integrate.h insn-config.h \
@@ -272,7 +272,7 @@ cp/optimize.o: cp/optimize.c $(CXX_TREE_H) rtl.h integrate.h insn-config.h \
cp/mangle.o: cp/mangle.c $(CXX_TREE_H) toplev.h real.h
cp/parse.o: cp/parse.c $(CXX_TREE_H) flags.h cp/lex.h except.h output.h \
- cp/decl.h $(SYSTEM_H) toplev.h $(GGC_H) gt-cp-parse.h
+ cp/decl.h $(SYSTEM_H) toplev.h gt-cp-parse.h
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(BIG_SWITCHFLAG) \
$(srcdir)/cp/parse.c $(OUTPUT_OPTION)
#
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index a7f9a917d15..fe612279708 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -33,7 +33,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 a36b981e6e8..48909663a2b 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -31,7 +31,6 @@ Boston, MA 02111-1307, USA. */
#include "rtl.h"
#include "output.h"
#include "toplev.h"
-#include "ggc.h"
#include "lex.h"
#include "target.h"
@@ -123,8 +122,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,
@@ -1450,7 +1451,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;
{
@@ -1924,9 +1926,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);
@@ -1939,12 +1943,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)
@@ -1956,6 +2012,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.
@@ -2026,7 +2139,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. */
@@ -5220,7 +5333,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 f4d84873f27..45ab369af4b 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -20,6 +20,7 @@ along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include "ggc.h"
#include "function.h"
#include "hashtab.h"
#include "splay-tree.h"
@@ -1163,7 +1164,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 decl_list;
tree template_info;
tree befriending_classes;
@@ -1763,6 +1764,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;
@@ -1794,7 +1798,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 unparsed_text * GTY ((tag ("2"))) pending_inline_info;
struct language_function * GTY ((tag ("1")))
saved_language_function;
@@ -3552,10 +3557,14 @@ extern tree perform_implicit_conversion PARAMS ((tree, 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 13e1814a807..92a224ed48f 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -42,7 +42,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"
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index a28cb9caac8..14d81a6de75 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -40,7 +40,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"
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index a7db6267853..ef750571d4a 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -32,7 +32,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 d1ce034f20a..89d864bf239 100644
--- a/gcc/cp/lang-specs.h
+++ b/gcc/cp/lang-specs.h
@@ -35,8 +35,6 @@ Boston, MA 02111-1307, USA. */
{".H", "@c++-header", 0},
{".hh", "@c++-header", 0},
{"@c++-header",
- /* We should convert -ansi to -std=c++98 even if -fpreprocessed,
- to get dollars in identifiers correct. */
"%{E|M|MM:cc1plus -E %{!no-gcc:-D__GNUG__=%v1}\
%(cpp_options) %2 %(cpp_debug_options)}\
%{!E:%{!M:%{!MM:\
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 40ec0c992d6..be03cf3c928 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -35,7 +35,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"
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 8a905b21b75..cb50f738554 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 GNU CC.
@@ -32,7 +32,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 6fbcc2be192..fd90ac2318e 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -29,7 +29,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/parse.y b/gcc/cp/parse.y
index 78cf991f192..ddbfae62408 100644
--- a/gcc/cp/parse.y
+++ b/gcc/cp/parse.y
@@ -42,7 +42,6 @@ Boston, MA 02111-1307, USA. */
#include "output.h"
#include "except.h"
#include "toplev.h"
-#include "ggc.h"
/* Like YYERROR but do call yyerror. */
#define YYERROR1 { yyerror ("syntax error"); YYERROR; }
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 67252f939a9..ca0fb58fd45 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -40,7 +40,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 64c6ec873fc..1bb82445bb6 100644
--- a/gcc/cp/repo.c
+++ b/gcc/cp/repo.c
@@ -1,5 +1,5 @@
/* Code to maintain a C++ template repository.
- Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Jason Merrill (jason@cygnus.com)
This file is part of GNU CC.
@@ -32,7 +32,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 PARAMS ((tree));
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 4170c161ca7..c84b796f840 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -31,7 +31,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 81b4ccfdafc..6589b00b746 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -33,7 +33,6 @@
#include "lex.h"
#include "toplev.h"
#include "flags.h"
-#include "ggc.h"
#include "rtl.h"
#include "expr.h"
#include "output.h"
diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c
index 380d6936b83..d7193d63a09 100644
--- a/gcc/cp/spew.c
+++ b/gcc/cp/spew.c
@@ -35,7 +35,6 @@ Boston, MA 02111-1307, USA. */
#include "flags.h"
#include "obstack.h"
#include "toplev.h"
-#include "ggc.h"
#include "intl.h"
#include "timevar.h"
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 4b1142b1154..dcb12d4c618 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -28,7 +28,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"
diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index 4095a4cb811..2f6e003caaa 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -141,7 +141,7 @@ static GTY(()) const char *lastfile;
/* Current working directory. */
-static GTY(()) const char *cwd;
+static const char *cwd;
enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index 773cce045e4..c1d4343640e 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -1375,6 +1375,7 @@ struct write_types_data
const char *param_prefix;
const char *subfield_marker_routine;
const char *marker_routine;
+ const char *reorder_note_routine;
const char *comment;
};
@@ -1425,6 +1426,7 @@ struct walk_type_data
type_p *param;
int used_length;
type_p orig_s;
+ const char *reorder_fn;
};
/* Print a mangled name representing T to OF. */
@@ -1562,6 +1564,8 @@ walk_type (t, d)
;
else if (strcmp (oo->name, "chain_prev") == 0)
;
+ else if (strcmp (oo->name, "reorder") == 0)
+ ;
else
error_at_line (d->line, "unknown option `%s'\n", oo->name);
@@ -1759,6 +1763,7 @@ walk_type (t, d)
int use_param_p = 0;
char *newval;
+ d->reorder_fn = NULL;
for (oo = f->opt; oo; oo = oo->next)
if (strcmp (oo->name, "dot") == 0)
dot = (const char *)oo->info;
@@ -1768,6 +1773,8 @@ walk_type (t, d)
skip_p = 1;
else if (strcmp (oo->name, "default") == 0)
default_p = 1;
+ else if (strcmp (oo->name, "reorder") == 0)
+ d->reorder_fn = (const char *)oo->info;
else if (strncmp (oo->name, "use_param", 9) == 0
&& (oo->name[9] == '\0' || ISDIGIT (oo->name[9])))
use_param_p = 1;
@@ -1820,6 +1827,8 @@ walk_type (t, d)
d->indent -= 2;
}
}
+ d->reorder_fn = NULL;
+
d->val = oldval;
d->prev_val[1] = oldprevval1;
d->prev_val[2] = oldprevval2;
@@ -1883,6 +1892,7 @@ write_types_process_field (f, d)
wtd->subfield_marker_routine, d->val);
if (wtd->param_prefix)
{
+ oprintf (d->of, ", %s", d->prev_val[3]);
if (d->orig_s)
{
oprintf (d->of, ", gt_%s_", wtd->param_prefix);
@@ -1890,9 +1900,12 @@ write_types_process_field (f, d)
}
else
oprintf (d->of, ", gt_%sa_%s", wtd->param_prefix, d->prev_val[0]);
- oprintf (d->of, ", %s", d->prev_val[3]);
}
oprintf (d->of, ");\n");
+ if (d->reorder_fn && wtd->reorder_note_routine)
+ oprintf (d->of, "%*s%s (%s, %s, %s);\n", d->indent, "",
+ wtd->reorder_note_routine, d->val,
+ d->prev_val[3], d->reorder_fn);
break;
case TYPE_STRING:
@@ -1906,6 +1919,10 @@ write_types_process_field (f, d)
oprintf (d->of, "%*sgt_%s_", d->indent, "", wtd->prefix);
output_mangled_typename (d->of, f);
oprintf (d->of, " (%s);\n", d->val);
+ if (d->reorder_fn && wtd->reorder_note_routine)
+ oprintf (d->of, "%*s%s (%s, %s, %s);\n", d->indent, "",
+ wtd->reorder_note_routine, d->val, d->val,
+ d->reorder_fn);
break;
case TYPE_SCALAR:
@@ -1992,9 +2009,8 @@ write_func_for_structure (orig_s, s, param, wtd)
oprintf (d.of, " if (%s (x", wtd->marker_routine);
if (wtd->param_prefix)
{
- oprintf (d.of, ", gt_%s_", wtd->param_prefix);
+ oprintf (d.of, ", x, gt_%s_", wtd->param_prefix);
output_mangled_typename (d.of, orig_s);
- oprintf (d.of, ", x");
}
oprintf (d.of, "))\n");
}
@@ -2003,9 +2019,8 @@ write_func_for_structure (orig_s, s, param, wtd)
oprintf (d.of, " while (%s (xlimit", wtd->marker_routine);
if (wtd->param_prefix)
{
- oprintf (d.of, ", gt_%s_", wtd->param_prefix);
+ oprintf (d.of, ", xlimit, gt_%s_", wtd->param_prefix);
output_mangled_typename (d.of, orig_s);
- oprintf (d.of, ", xlimit");
}
oprintf (d.of, "))\n");
oprintf (d.of, " xlimit = (");
@@ -2029,9 +2044,8 @@ write_func_for_structure (orig_s, s, param, wtd)
wtd->marker_routine);
if (wtd->param_prefix)
{
- oprintf (d.of, ", gt_%s_", wtd->param_prefix);
+ oprintf (d.of, ", xprev, gt_%s_", wtd->param_prefix);
output_mangled_typename (d.of, orig_s);
- oprintf (d.of, ", xprev");
}
oprintf (d.of, ");\n");
oprintf (d.of, " }\n");
@@ -2156,13 +2170,14 @@ write_types (structures, param_structs, wtd)
static const struct write_types_data ggc_wtd =
{
- "ggc_m", NULL, "ggc_mark", "ggc_test_and_set_mark",
+ "ggc_m", NULL, "ggc_mark", "ggc_test_and_set_mark", NULL,
"GC marker procedures. "
};
static const struct write_types_data pch_wtd =
{
"pch_n", "pch_p", "gt_pch_note_object", "gt_pch_note_object",
+ "gt_pch_note_reorder",
"PCH type-walking procedures. "
};
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index 007bf4666cf..69e10368032 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -224,8 +224,9 @@ static htab_t saving_htab;
struct ptr_data
{
void *obj;
- gt_note_pointers note_ptr_fn;
void *note_ptr_cookie;
+ gt_note_pointers note_ptr_fn;
+ gt_handle_reorder reorder_fn;
size_t size;
void *new_addr;
};
@@ -235,10 +236,10 @@ struct ptr_data
/* Register an object in the hash table. */
int
-gt_pch_note_object (obj, note_ptr_fn, note_ptr_cookie)
+gt_pch_note_object (obj, note_ptr_cookie, note_ptr_fn)
void *obj;
- gt_note_pointers note_ptr_fn;
void *note_ptr_cookie;
+ gt_note_pointers note_ptr_fn;
{
struct ptr_data **slot;
@@ -267,6 +268,27 @@ gt_pch_note_object (obj, note_ptr_fn, note_ptr_cookie)
return 1;
}
+/* Register an object in the hash table. */
+
+void
+gt_pch_note_reorder (obj, note_ptr_cookie, reorder_fn)
+ void *obj;
+ void *note_ptr_cookie;
+ gt_handle_reorder reorder_fn;
+{
+ struct ptr_data *data;
+
+ if (obj == NULL || obj == (void *) 1)
+ return;
+
+ data = htab_find_with_hash (saving_htab, obj, POINTER_HASH (obj));
+ if (data == NULL
+ || data->note_ptr_cookie != note_ptr_cookie)
+ abort ();
+
+ data->reorder_fn = reorder_fn;
+}
+
/* Hash and equality functions for saving_htab, callbacks for htab_create. */
static hashval_t
@@ -496,6 +518,10 @@ gt_pch_save (f)
this_object = xrealloc (this_object, this_object_size);
}
memcpy (this_object, state.ptrs[i]->obj, state.ptrs[i]->size);
+ if (state.ptrs[i]->reorder_fn != NULL)
+ state.ptrs[i]->reorder_fn (state.ptrs[i]->obj,
+ state.ptrs[i]->note_ptr_cookie,
+ relocate_ptrs, &state);
state.ptrs[i]->note_ptr_fn (state.ptrs[i]->obj,
state.ptrs[i]->note_ptr_cookie,
relocate_ptrs, &state);
diff --git a/gcc/ggc.h b/gcc/ggc.h
index b15b1600519..a2331dd9f9e 100644
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -40,8 +40,22 @@ typedef void (*gt_pointer_operator) PARAMS ((void *, void *));
typedef void (*gt_note_pointers)
PARAMS ((void *, void *, gt_pointer_operator, void *));
-/* Used by the gt_pch_n_* routines. */
-extern int gt_pch_note_object PARAMS ((void *, gt_note_pointers, void *));
+/* One of these is called before objects are re-ordered in memory.
+ The first parameter is the original object, the second is the
+ subobject that has had its pointers reordered, the third parameter
+ can compute the new values of a pointer when given the cookie in
+ the fourth parameter. */
+typedef void (*gt_handle_reorder)
+ PARAMS ((void *, void *, gt_pointer_operator, void *));
+
+/* Used by the gt_pch_n_* routines. Register an object in the hash table. */
+extern int gt_pch_note_object
+ PARAMS ((void *, void *, gt_note_pointers));
+
+/* Used by the gt_pch_n_* routines. Register that an object has a reorder
+ function. */
+extern void gt_pch_note_reorder
+ PARAMS ((void *, void *, gt_handle_reorder));
/* Mark the object in the first parameter and anything it points to. */
typedef void (*gt_pointer_walker) PARAMS ((void *));
diff --git a/gcc/stringpool.c b/gcc/stringpool.c
index b58c09771f8..77af27d7aae 100644
--- a/gcc/stringpool.c
+++ b/gcc/stringpool.c
@@ -198,7 +198,7 @@ void
gt_pch_n_S (x)
const void *x;
{
- gt_pch_note_object ((void *)x, &gt_pch_p_S, (void *)x);
+ gt_pch_note_object ((void *)x, (void *)x, &gt_pch_p_S);
}
/* Handle saving and restoring the string pool for PCH. */
diff --git a/gcc/testsuite/g++.dg/pch/pch.exp b/gcc/testsuite/g++.dg/pch/pch.exp
index f3e619b2c01..8507e355f53 100644
--- a/gcc/testsuite/g++.dg/pch/pch.exp
+++ b/gcc/testsuite/g++.dg/pch/pch.exp
@@ -23,9 +23,11 @@ load_lib "g++-dg.exp"
# Initialize `dg'.
dg-init
+set old_dg_do_what_default "${dg-do-what-default}"
+
# Main loop.
foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.C]] {
- global runtests torture_without_loops dg-do-what-default
+ global runtests dg-do-what-default
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $test] {
@@ -34,31 +36,65 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.C]] {
set nshort [file tail [file dirname $test]]/[file tail $test]
set bname "[file rootname [file tail $test]]"
- verbose "Testing $nshort" 1
-
catch { file delete "$bname.Hp.pch" }
catch { file delete "$bname.H.pch" }
+ catch { file delete "$bname.s" }
+ catch { file delete "$bname.s-pch" }
+ catch { file delete "$bname.Hp" }
+
+ # We don't try to use the loop-optimizing options, since they are highly
+ # unlikely to make any difference to PCH.
+ foreach flags { "-g" "-O2 -g" "-O2" } {
+ verbose "Testing $nshort, $flags" 1
+
+ # For the header files, the default is to precompile.
+ set dg-do-what-default precompile
+ dg-test -keep-output "[file rootname $test].H" $flags ""
- # For the header files, the default is to precompile.
- set old_dg_do_what_default "${dg-do-what-default}"
- set dg-do-what-default precompile
- dg-test -keep-output "[file rootname $test].H" "" ""
- set dg-do-what-default "$old_dg_do_what_default"
-
- if { [ file exists "$bname.H.pch" ] } {
- # To ensure that the PCH is used, not the original header,
- # the actual PCH file is renamed to "<foo>.hp.pch".
- file rename "$bname.H.pch" "$bname.Hp.pch"
- if { [ is_remote host ] } {
- remote_download host "$bname.Hp.pch"
+ # For the rest, the default is to compile to .s.
+ set dg-do-what-default compile
+
+ if { [ file exists "$bname.H.pch" ] } {
+ # To ensure that the PCH is used, not the original header,
+ # the actual PCH file is renamed to "<foo>.Hp.pch".
+ file rename "$bname.H.pch" "$bname.Hp.pch"
+ if { [ is_remote host ] } {
+ remote_download host "$bname.Hp.pch"
+ }
+
+ dg-test -keep-output $test $flags "-I."
+ file delete "$bname.Hp.pch"
+ if { [ file exists "$bname.s" ] } {
+ file rename "$bname.s" "$bname.s-pch"
+ if { [ is_remote host ] } {
+ remote_upload host "[file rootname $test].H" "$bname.Hp"
+ } else {
+ file copy "[file rootname $test].H" "$bname.Hp"
+ }
+ dg-test -keep-output $test $flags "-I."
+ remote_file host delete "$bname.Hp"
+ set tmp [ diff "$bname.s" "$bname.s-pch" ]
+ if { $tmp == 0 } {
+ untested "$nshort $flags assembly comparison"
+ } elseif { $tmp == 1 } {
+ pass "$nshort $flags assembly comparison"
+ } else {
+ fail "$nshort $flags assembly comparison"
+ }
+ file delete "$bname.s"
+ file delete "$bname.s-pch"
+ } else {
+ untested "$nshort $flags assembly comparison"
+ }
+
+ } else {
+ untested $nshort
+ untested "$nshort $flags assembly comparison"
}
-
- dg-test $test "" "-I."
- file delete "$bname.Hp.pch"
- } else {
- untested $test
}
}
+set dg-do-what-default "$old_dg_do_what_default"
+
# All done.
dg-finish
diff --git a/gcc/testsuite/g++.dg/pch/system-1.C b/gcc/testsuite/g++.dg/pch/system-1.C
new file mode 100644
index 00000000000..a0444bc5941
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pch/system-1.C
@@ -0,0 +1,7 @@
+#include "system-1.Hp"
+
+int main()
+{
+ std::cout << "hello world!" << '\n';
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/pch/system-1.H b/gcc/testsuite/g++.dg/pch/system-1.H
new file mode 100644
index 00000000000..604782e4dc7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pch/system-1.H
@@ -0,0 +1 @@
+#include <iostream>