diff options
author | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-09 20:10:13 +0000 |
---|---|---|
committer | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-09 20:10:13 +0000 |
commit | c39ed964c8cd9aec2fe6060830804416b0856b60 (patch) | |
tree | 1238be7fc80d74d8323d5f6c4344a6bb2be0f854 /libcpp/include | |
parent | f5efe504032463d907b2eb0f4f76a5d68ce45429 (diff) | |
download | gcc-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/include')
-rw-r--r-- | libcpp/include/ChangeLog | 11 | ||||
-rw-r--r-- | libcpp/include/cpp-id-data.h | 77 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 68 | ||||
-rw-r--r-- | libcpp/include/symtab.h | 5 |
4 files changed, 147 insertions, 14 deletions
diff --git a/libcpp/include/ChangeLog b/libcpp/include/ChangeLog index a2f4bc5e3ef..0dbd0c33474 100644 --- a/libcpp/include/ChangeLog +++ b/libcpp/include/ChangeLog @@ -1,3 +1,14 @@ +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. + 2004-05-29 Geoffrey Keating <geoffk@apple.com> * symtab.h (struct ht): New field 'entries_owned' diff --git a/libcpp/include/cpp-id-data.h b/libcpp/include/cpp-id-data.h new file mode 100644 index 00000000000..bdeaeba5182 --- /dev/null +++ b/libcpp/include/cpp-id-data.h @@ -0,0 +1,77 @@ +/* Structures that hang off cpp_identifier, for PCH. + Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "cpplib.h" + +#ifndef HAVE_UCHAR +typedef unsigned char uchar; +#endif +#define U (const uchar *) /* Intended use: U"string" */ + +/* Chained list of answers to an assertion. */ +struct answer GTY(()) +{ + struct answer *next; + unsigned int count; + cpp_token GTY ((length ("%h.count"))) first[1]; +}; + +/* Each macro definition is recorded in a cpp_macro structure. + Variadic macros cannot occur with traditional cpp. */ +struct cpp_macro GTY(()) +{ + /* Parameters, if any. */ + cpp_hashnode ** GTY ((nested_ptr (union tree_node, + "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL", + "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"), + length ("%h.paramc"))) + params; + + /* Replacement tokens (ISO) or replacement text (traditional). See + comment at top of cpptrad.c for how traditional function-like + macros are encoded. */ + union cpp_macro_u + { + cpp_token * GTY ((tag ("0"), length ("%0.count"))) tokens; + const uchar * GTY ((tag ("1"))) text; + } GTY ((desc ("%1.traditional"))) exp; + + /* Definition line number. */ + source_location line; + + /* Number of tokens in expansion, or bytes for traditional macros. */ + unsigned int count; + + /* Number of parameters. */ + unsigned short paramc; + + /* If a function-like macro. */ + unsigned int fun_like : 1; + + /* If a variadic macro. */ + unsigned int variadic : 1; + + /* If macro defined in system header. */ + unsigned int syshdr : 1; + + /* Nonzero if it has been expanded or had its existence tested. */ + unsigned int used : 1; + + /* Indicate which field of 'exp' is in use. */ + unsigned int traditional : 1; +}; diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index cf701b5e861..dab315714df 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -156,7 +156,7 @@ enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_GNUCXX, CLK_CXX98, CLK_ASM}; /* Payload of a NUMBER, STRING, CHAR or COMMENT token. */ -struct cpp_string +struct cpp_string GTY(()) { unsigned int len; const unsigned char *text; @@ -171,23 +171,48 @@ struct cpp_string #define NO_EXPAND (1 << 5) /* Do not macro-expand this token. */ #define BOL (1 << 6) /* Token at beginning of line. */ +/* Specify which field, if any, of the cpp_token union is used. */ + +enum cpp_token_fld_kind { + CPP_TOKEN_FLD_NODE, + CPP_TOKEN_FLD_SOURCE, + CPP_TOKEN_FLD_STR, + CPP_TOKEN_FLD_ARG_NO, + CPP_TOKEN_FLD_NONE +}; + /* A preprocessing token. This has been carefully packed and should occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts. */ -struct cpp_token +struct cpp_token GTY(()) { source_location src_loc; /* Location of first char of token. */ ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT; /* token type */ unsigned char flags; /* flags - see above */ - union + union cpp_token_u { - cpp_hashnode *node; /* An identifier. */ - const cpp_token *source; /* Inherit padding from this token. */ - struct cpp_string str; /* A string, or number. */ - unsigned int arg_no; /* Argument no. for a CPP_MACRO_ARG. */ - } val; + /* An identifier. */ + cpp_hashnode * + GTY ((nested_ptr (union tree_node, + "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL", + "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"), + tag ("CPP_TOKEN_FLD_NODE"))) + node; + + /* Inherit padding from this token. */ + cpp_token * GTY ((tag ("CPP_TOKEN_FLD_SOURCE"))) source; + + /* A string, or number. */ + struct cpp_string GTY ((tag ("CPP_TOKEN_FLD_STR"))) str; + + /* Argument no. for a CPP_MACRO_ARG. */ + unsigned int GTY ((tag ("CPP_TOKEN_FLD_ARG_NO"))) arg_no; + } GTY ((desc ("cpp_token_val_index (&%1)"))) val; }; +/* Say which field is in use. */ +extern enum cpp_token_fld_kind cpp_token_val_index (cpp_token *tok); + /* A type wide enough to hold any multibyte source character. cpplib's character constant interpreter requires an unsigned type. Also, a typedef for the signed equivalent. @@ -498,6 +523,23 @@ enum builtin_type #define NODE_LEN(NODE) HT_LEN (&(NODE)->ident) #define NODE_NAME(NODE) HT_STR (&(NODE)->ident) +/* Specify which field, if any, of the union is used. */ + +enum { + NTV_MACRO, + NTV_ANSWER, + NTV_BUILTIN, + NTV_ARGUMENT, + NTV_NONE +}; + +#define CPP_HASHNODE_VALUE_IDX(HNODE) \ + ((HNODE.flags & NODE_MACRO_ARG) ? NTV_ARGUMENT \ + : HNODE.type == NT_MACRO ? ((HNODE.flags & NODE_BUILTIN) \ + ? NTV_BUILTIN : NTV_MACRO) \ + : HNODE.type == NT_ASSERTION ? NTV_ANSWER \ + : NTV_NONE) + /* The common part of an identifier node shared amongst all 3 C front ends. Also used to store CPP identifiers, which are a superset of identifiers in the grammatical sense. */ @@ -515,14 +557,14 @@ struct cpp_hashnode GTY(()) union _cpp_hashnode_value { /* If a macro. */ - cpp_macro * GTY((skip)) macro; + cpp_macro * GTY((tag ("NTV_MACRO"))) macro; /* Answers to an assertion. */ - struct answer * GTY ((skip)) answers; + struct answer * GTY ((tag ("NTV_ANSWER"))) answers; /* Code for a builtin macro. */ - enum builtin_type GTY ((tag ("1"))) builtin; + enum builtin_type GTY ((tag ("NTV_BUILTIN"))) builtin; /* Macro argument index. */ - unsigned short GTY ((tag ("0"))) arg_index; - } GTY ((desc ("0"))) value; + unsigned short GTY ((tag ("NTV_ARGUMENT"))) arg_index; + } GTY ((desc ("CPP_HASHNODE_VALUE_IDX (%1)"))) value; }; /* Call this first to get a handle to pass to other functions. diff --git a/libcpp/include/symtab.h b/libcpp/include/symtab.h index d11e4efe6dc..0b2a848739e 100644 --- a/libcpp/include/symtab.h +++ b/libcpp/include/symtab.h @@ -46,8 +46,11 @@ struct ht struct obstack stack; hashnode *entries; - /* Call back. */ + /* Call back, allocate a node. */ hashnode (*alloc_node) (hash_table *); + /* Call back, allocate something that hangs off a node like a cpp_macro. + NULL means use the usual allocator. */ + void * (*alloc_subobject) (size_t); unsigned int nslots; /* Total slots in the entries array. */ unsigned int nelements; /* Number of live elements. */ |