summaryrefslogtreecommitdiff
path: root/libcpp/macro.c
diff options
context:
space:
mode:
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-09 20:10:13 +0000
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-09 20:10:13 +0000
commitc39ed964c8cd9aec2fe6060830804416b0856b60 (patch)
tree1238be7fc80d74d8323d5f6c4344a6bb2be0f854 /libcpp/macro.c
parentf5efe504032463d907b2eb0f4f76a5d68ce45429 (diff)
downloadgcc-c39ed964c8cd9aec2fe6060830804416b0856b60.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82851 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/macro.c')
-rw-r--r--libcpp/macro.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/libcpp/macro.c b/libcpp/macro.c
index cfc42b4050f..dc58b3180f1 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -1408,8 +1408,16 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
if (!ok)
return false;
- /* Success. Commit the parameter array. */
- BUFF_FRONT (pfile->a_buff) = (uchar *) &macro->params[macro->paramc];
+ /* Success. Commit or allocate the parameter array. */
+ if (pfile->hash_table->alloc_subobject)
+ {
+ cpp_token *tokns = pfile->hash_table->alloc_subobject
+ (sizeof (cpp_token) * macro->paramc);
+ memcpy (tokns, macro->params, sizeof (cpp_token) * macro->paramc);
+ macro->params = tokns;
+ }
+ else
+ BUFF_FRONT (pfile->a_buff) = (uchar *) &macro->params[macro->paramc];
macro->fun_like = 1;
}
else if (ctoken->type != CPP_EOF && !(ctoken->flags & PREV_WHITE))
@@ -1472,6 +1480,7 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
}
macro->exp.tokens = (cpp_token *) BUFF_FRONT (pfile->a_buff);
+ macro->traditional = 0;
/* Don't count the CPP_EOF. */
macro->count--;
@@ -1480,8 +1489,16 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
if (macro->count)
macro->exp.tokens[0].flags &= ~PREV_WHITE;
- /* Commit the memory. */
- BUFF_FRONT (pfile->a_buff) = (uchar *) &macro->exp.tokens[macro->count];
+ /* Commit or allocate the memory. */
+ if (pfile->hash_table->alloc_subobject)
+ {
+ cpp_token *tokns = pfile->hash_table->alloc_subobject (sizeof (cpp_token)
+ * macro->count);
+ memcpy (tokns, macro->exp.tokens, sizeof (cpp_token) * macro->count);
+ macro->exp.tokens = tokns;
+ }
+ else
+ BUFF_FRONT (pfile->a_buff) = (uchar *) &macro->exp.tokens[macro->count];
return true;
}
@@ -1494,7 +1511,10 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node)
unsigned int i;
bool ok;
- macro = (cpp_macro *) _cpp_aligned_alloc (pfile, sizeof (cpp_macro));
+ if (pfile->hash_table->alloc_subobject)
+ macro = pfile->hash_table->alloc_subobject (sizeof (cpp_macro));
+ else
+ macro = (cpp_macro *) _cpp_aligned_alloc (pfile, sizeof (cpp_macro));
macro->line = pfile->directive_line;
macro->params = 0;
macro->paramc = 0;