aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2004-06-09 20:10:13 +0000
committerGeoffrey Keating <geoffk@gcc.gnu.org>2004-06-09 20:10:13 +0000
commitd8044160b7047642e312fb5f713fe0db46171dd8 (patch)
tree1238be7fc80d74d8323d5f6c4344a6bb2be0f854 /gcc
parent293155b099b94b81fa0147f2719f3da23c859f7e (diff)
downloadgcc-d8044160b7047642e312fb5f713fe0db46171dd8.zip
gcc-d8044160b7047642e312fb5f713fe0db46171dd8.tar.gz
gcc-d8044160b7047642e312fb5f713fe0db46171dd8.tar.bz2
Index: gcc/ChangeLog
2004-06-09 Geoffrey Keating <geoffk@apple.com> * Makefile.in (CPPLIB_H): Put files in order of inclusion. (CPP_ID_DATA_H): New. (gtype-desc.o): Update dependencies. (GTFILES): Use CPP_ID_DATA_H. Index: gcc/testsuite/ChangeLog 2004-06-09 Geoffrey Keating <geoffk@apple.com> * gcc.dg/pch/macro-4.c: New. * gcc.dg/pch/macro-4.hs: New. Index: libcpp/ChangeLog 2004-06-09 Geoffrey Keating <geoffk@apple.com> * traditional.c (push_replacement_text): Set macro->traditional. (save_replacement_text): Likewise. * pch.c (cpp_write_pch_state): Don't write list of defined macros. (struct save_macro_item): Delete. (struct save_macro_data): Use a character array not the previous structured format. (save_macros): Save macro as text not as internal structures. (cpp_prepare_state): Update for changes to save_macro_data. (cpp_read_state): Don't read macros defined in PCH. Restore -D macros as text. * macro.c (create_iso_definition): Honour alloc_subobject. Clear traditional flag. (_cpp_create_definition): Honour alloc_subobject. * lex.c (cpp_token_val_index): New. * internal.h: Include cpp-id-data.h. (uchar): Move definition to cpp-id-data.h. (U): Likewise. (cpp_macro): Likewise. * directives.c (struct answer): Move to cpp-id-data.h. (do_assert): Honour alloc_subobject. Index: libcpp/include/ChangeLog 2004-06-09 Geoffrey Keating <geoffk@apple.com> * symtab.h (struct ht): Add field 'alloc_subobject'. * cpplib.h (struct cpp_string): Add GTY marker. (enum cpp_token_fld_kind): New. (struct cpp_token): Add GTY markers. (cpp_token_val_index): Prototype. (CPP_HASHNODE_VALUE_IDX): New. (struct cpp_hashnode): Don't skip fields of 'value' when marking. * cpp-id-data.h: New file. From-SVN: r82851
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/Makefile.in16
-rw-r--r--gcc/gengtype.c53
-rw-r--r--gcc/stringpool.c49
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pch/macro-4.c8
-rw-r--r--gcc/testsuite/gcc.dg/pch/macro-4.hs1
7 files changed, 73 insertions, 66 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1184df7..7f5e57d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2004-06-09 Geoffrey Keating <geoffk@apple.com>
+
+ * Makefile.in (CPPLIB_H): Put files in order of inclusion.
+ (CPP_ID_DATA_H): New.
+ (gtype-desc.o): Update dependencies.
+ (GTFILES): Use CPP_ID_DATA_H.
+
2004-06-09 Mark Mitchell <mark@codesourcery.com>
Revert:
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 2fa566a..fc87854 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -712,10 +712,11 @@ C_COMMON_H = c-common.h $(SPLAY_TREE_H) $(CPPLIB_H)
C_TREE_H = c-tree.h $(C_COMMON_H)
SYSTEM_H = system.h hwint.h $(srcdir)/../include/libiberty.h
PREDICT_H = predict.h predict.def
-CPPLIB_H = $(srcdir)/../libcpp/include/cpplib.h \
- $(srcdir)/../libcpp/include/line-map.h
+CPPLIB_H = $(srcdir)/../libcpp/include/line-map.h \
+ $(srcdir)/../libcpp/include/cpplib.h
MKDEPS_H = $(srcdir)/../libcpp/include/mkdeps.h
SYMTAB_H = $(srcdir)/../libcpp/include/symtab.h
+CPP_ID_DATA_H = $(CPPLIB_H) $(srcdir)/../libcpp/include/cpp-id-data.h
TREE_DUMP_H = tree-dump.h $(SPLAY_TREE_H)
TREE_GIMPLE_H = tree-gimple.h tree-iterator.h
TREE_FLOW_H = tree-flow.h tree-flow-inline.h tree-ssa-operands.h \
@@ -1522,10 +1523,11 @@ dumpvers: dumpvers.c
version.o: version.c version.h
-gtype-desc.o: gtype-desc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) varray.h \
- $(HASHTAB_H) $(TREE_H) $(RTL_H) function.h insn-config.h $(EXPR_H) $(OPTABS_H) \
- libfuncs.h debug.h $(GGC_H) bitmap.h $(BASIC_BLOCK_H) hard-reg-set.h \
- cselib.h insn-addr.h $(TREE_FLOW_H)
+gtype-desc.o: gtype-desc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
+ varray.h $(HASHTAB_H) $(SPLAY_TREE_H) bitmap.h $(TREE_H) $(RTL_H) \
+ function.h insn-config.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
+ cselib.h insn-addr.h $(OPTABS_H) libfuncs.h debug.h $(GGC_H) \
+ cgraph.h tree-alias-type.h $(TREE_FLOW_H) reload.h $(CPP_ID_DATA_H)
ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GGC_H) \
$(HASHTAB_H) toplev.h $(PARAMS_H) hosthooks.h
@@ -2289,7 +2291,7 @@ s-preds: genpreds$(build_exeext)
$(STAMP) s-preds
GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
- $(srcdir)/../libcpp/include/cpplib.h $(host_xm_file_list) \
+ $(CPP_ID_DATA_H) $(host_xm_file_list) \
$(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \
$(srcdir)/coverage.c $(srcdir)/function.h $(srcdir)/rtl.h \
$(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(SYMTAB_H) \
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index 804ef70..5d70824 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -875,7 +875,7 @@ note_yacc_type (options_p o, pair_p fields, pair_p typeinfo,
}
static void process_gc_options (options_p, enum gc_used_enum,
- int *, int *, int *);
+ int *, int *, int *, type_p *);
static void set_gc_used_type (type_p, enum gc_used_enum, type_p *);
static void set_gc_used (pair_p);
@@ -883,7 +883,7 @@ static void set_gc_used (pair_p);
static void
process_gc_options (options_p opt, enum gc_used_enum level, int *maybe_undef,
- int *pass_param, int *length)
+ int *pass_param, int *length, type_p *nested_ptr)
{
options_p o;
for (o = opt; o; o = o->next)
@@ -895,6 +895,8 @@ process_gc_options (options_p opt, enum gc_used_enum level, int *maybe_undef,
*pass_param = 1;
else if (strcmp (o->name, "length") == 0)
*length = 1;
+ else if (strcmp (o->name, "nested_ptr") == 0)
+ *nested_ptr = ((const struct nested_ptr_data *) o->info)->type;
}
/* Set the gc_used field of T to LEVEL, and handle the types it references. */
@@ -914,18 +916,24 @@ set_gc_used_type (type_p t, enum gc_used_enum level, type_p param[NUM_PARAM])
{
pair_p f;
int dummy;
+ type_p dummy2;
- process_gc_options (t->u.s.opt, level, &dummy, &dummy, &dummy);
+ process_gc_options (t->u.s.opt, level, &dummy, &dummy, &dummy,
+ &dummy2);
for (f = t->u.s.fields; f; f = f->next)
{
int maybe_undef = 0;
int pass_param = 0;
int length = 0;
+ type_p nested_ptr = NULL;
process_gc_options (f->opt, level, &maybe_undef, &pass_param,
- &length);
+ &length, &nested_ptr);
- if (length && f->type->kind == TYPE_POINTER)
+ if (nested_ptr && f->type->kind == TYPE_POINTER)
+ set_gc_used_type (nested_ptr, GC_POINTED_TO,
+ pass_param ? param : NULL);
+ else if (length && f->type->kind == TYPE_POINTER)
set_gc_used_type (f->type->u.p, GC_USED, NULL);
else if (maybe_undef && f->type->kind == TYPE_POINTER)
set_gc_used_type (f->type->u.p, GC_MAYBE_POINTED_TO, NULL);
@@ -1015,7 +1023,7 @@ static outf_p
create_file (const char *name, const char *oname)
{
static const char *const hdr[] = {
- " Copyright (C) 2003 Free Software Foundation, Inc.\n",
+ " Copyright (C) 2004 Free Software Foundation, Inc.\n",
"\n",
"This file is part of GCC.\n",
"\n",
@@ -1101,6 +1109,7 @@ open_base_files (void)
"basic-block.h", "cselib.h", "insn-addr.h", "optabs.h",
"libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
"tree-alias-type.h", "tree-flow.h", "reload.h",
+ "cpp-id-data.h",
NULL
};
const char *const *ifp;
@@ -1408,7 +1417,8 @@ struct walk_type_data
int used_length;
type_p orig_s;
const char *reorder_fn;
- int needs_cast_p;
+ bool needs_cast_p;
+ bool fn_wants_lvalue;
};
/* Print a mangled name representing T to OF. */
@@ -1511,7 +1521,7 @@ walk_type (type_p t, struct walk_type_data *d)
options_p oo;
const struct nested_ptr_data *nested_ptr_d = NULL;
- d->needs_cast_p = 0;
+ d->needs_cast_p = false;
for (oo = d->opt; oo; oo = oo->next)
if (strcmp (oo->name, "length") == 0)
length = (const char *)oo->info;
@@ -1525,7 +1535,7 @@ walk_type (type_p t, struct walk_type_data *d)
else if (strcmp (oo->name, "desc") == 0)
desc = (const char *)oo->info;
else if (strcmp (oo->name, "nested_ptr") == 0)
- nested_ptr_d = (const struct nested_ptr_data *)oo->info ;
+ nested_ptr_d = (const struct nested_ptr_data *) oo->info;
else if (strcmp (oo->name, "dot") == 0)
;
else if (strcmp (oo->name, "tag") == 0)
@@ -1643,10 +1653,12 @@ walk_type (type_p t, struct walk_type_data *d)
oprintf (d->of, "%*s{\n", d->indent, "");
d->indent += 2;
d->val = xasprintf ("x%d", d->counter++);
- oprintf (d->of, "%*s%s %s * %s =\n", d->indent, "",
+ oprintf (d->of, "%*s%s %s * %s%s =\n", d->indent, "",
(nested_ptr_d->type->kind == TYPE_UNION
? "union" : "struct"),
- nested_ptr_d->type->u.s.tag, d->val);
+ nested_ptr_d->type->u.s.tag,
+ d->fn_wants_lvalue ? "" : "const ",
+ d->val);
oprintf (d->of, "%*s", d->indent + 2, "");
output_escaped_param (d, nested_ptr_d->convert_from,
"nested_ptr");
@@ -1654,12 +1666,15 @@ walk_type (type_p t, struct walk_type_data *d)
d->process_field (nested_ptr_d->type, d);
- oprintf (d->of, "%*s%s = ", d->indent, "",
- d->prev_val[2]);
- d->prev_val[2] = d->val;
- output_escaped_param (d, nested_ptr_d->convert_to,
- "nested_ptr");
- oprintf (d->of, ";\n");
+ if (d->fn_wants_lvalue)
+ {
+ oprintf (d->of, "%*s%s = ", d->indent, "",
+ d->prev_val[2]);
+ d->prev_val[2] = d->val;
+ output_escaped_param (d, nested_ptr_d->convert_to,
+ "nested_ptr");
+ oprintf (d->of, ";\n");
+ }
d->indent -= 2;
oprintf (d->of, "%*s}\n", d->indent, "");
@@ -1839,6 +1854,7 @@ walk_type (type_p t, struct walk_type_data *d)
d->line = &f->line;
d->val = newval = xasprintf ("%s%s%s", oldval, dot, f->name);
d->opt = f->opt;
+ d->used_length = false;
if (union_p && use_param_p && d->param == NULL)
oprintf (d->of, "%*sabort();\n", d->indent, "");
@@ -2231,7 +2247,7 @@ write_types_local_process_field (type_p f, const struct walk_type_data *d)
/* For S, a structure that's part of ORIG_S, and using parameters
PARAM, write out a routine that:
- Is of type gt_note_pointers
- - If calls PROCESS_FIELD on each field of S or its substructures.
+ - Calls PROCESS_FIELD on each field of S or its substructures.
*/
static void
@@ -2259,6 +2275,7 @@ write_local_func_for_structure (type_p orig_s, type_p s, type_p *param)
d.prev_val[1] = "not valid postage"; /* Guarantee an error. */
d.prev_val[3] = "x";
d.val = "(*x)";
+ d.fn_wants_lvalue = true;
oprintf (d.of, "\n");
oprintf (d.of, "void\n");
diff --git a/gcc/stringpool.c b/gcc/stringpool.c
index d17f31d..0227688 100644
--- a/gcc/stringpool.c
+++ b/gcc/stringpool.c
@@ -51,7 +51,12 @@ static struct obstack string_stack;
static hashnode alloc_node (hash_table *);
static int mark_ident (struct cpp_reader *, hashnode, const void *);
-static int ht_copy_and_clear (struct cpp_reader *, hashnode, const void *);
+
+static void *
+stringpool_ggc_alloc (size_t x)
+{
+ return ggc_alloc (x);
+}
/* Initialize the string pool. */
void
@@ -60,6 +65,7 @@ init_stringpool (void)
/* Create with 16K (2^14) entries. */
ident_hash = ht_create (14);
ident_hash->alloc_node = alloc_node;
+ ident_hash->alloc_subobject = stringpool_ggc_alloc;
gcc_obstack_init (&string_stack);
}
@@ -212,39 +218,7 @@ struct string_pool_data GTY(())
static GTY(()) struct string_pool_data * spd;
-/* Copy HP into the corresponding entry in HT2, and then clear
- the cpplib parts of HP. */
-
-static int
-ht_copy_and_clear (cpp_reader *r ATTRIBUTE_UNUSED, hashnode hp, const void *ht2_p)
-{
- cpp_hashnode *h = CPP_HASHNODE (hp);
- struct ht *ht2 = (struct ht *) ht2_p;
-
- if (h->type != NT_VOID
- && (h->flags & NODE_BUILTIN) == 0)
- {
- cpp_hashnode *h2 = CPP_HASHNODE (ht_lookup (ht2,
- NODE_NAME (h),
- NODE_LEN (h),
- HT_ALLOC));
- h2->type = h->type;
- memcpy (&h2->value, &h->value, sizeof (h->value));
-
- h->type = NT_VOID;
- memset (&h->value, 0, sizeof (h->value));
- }
- return 1;
-}
-
-/* The hash table as it was before gt_pch_save_stringpool was called. */
-
-static struct ht *saved_ident_hash;
-
-/* Prepare the stringpool to be written (by clearing all the cpp parts
- of each entry) and place the data to be saved in SPD. Save the
- current state in SAVED_IDENT_HASH so that gt_pch_fixup_stringpool
- can restore it. */
+/* Save the stringpool data in SPD. */
void
gt_pch_save_stringpool (void)
@@ -255,10 +229,6 @@ gt_pch_save_stringpool (void)
spd->entries = ggc_alloc (sizeof (spd->entries[0]) * spd->nslots);
memcpy (spd->entries, ident_hash->entries,
spd->nslots * sizeof (spd->entries[0]));
-
- saved_ident_hash = ht_create (14);
- saved_ident_hash->alloc_node = alloc_node;
- ht_forall (ident_hash, ht_copy_and_clear, saved_ident_hash);
}
/* Return the stringpool to its state before gt_pch_save_stringpool
@@ -267,9 +237,6 @@ gt_pch_save_stringpool (void)
void
gt_pch_fixup_stringpool (void)
{
- ht_forall (saved_ident_hash, ht_copy_and_clear, ident_hash);
- ht_destroy (saved_ident_hash);
- saved_ident_hash = 0;
}
/* A PCH file has been restored, which loaded SPD; fill the real hash table
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 332e3f0..c9565dd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-06-09 Geoffrey Keating <geoffk@apple.com>
+
+ * gcc.dg/pch/macro-4.c: New.
+ * gcc.dg/pch/macro-4.hs: New.
+
2004-06-09 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/13249
diff --git a/gcc/testsuite/gcc.dg/pch/macro-4.c b/gcc/testsuite/gcc.dg/pch/macro-4.c
new file mode 100644
index 0000000..1c199fa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pch/macro-4.c
@@ -0,0 +1,8 @@
+#define DEFN aa + bb
+
+#include "macro-4.h"
+
+int foo(int aa, int bb)
+{
+ return DEFN;
+}
diff --git a/gcc/testsuite/gcc.dg/pch/macro-4.hs b/gcc/testsuite/gcc.dg/pch/macro-4.hs
new file mode 100644
index 0000000..5af162d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pch/macro-4.hs
@@ -0,0 +1 @@
+/* No content! */