diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-02-10 23:47:04 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-02-10 23:47:04 +0000 |
commit | cf4ed945eab57de7fe5b2f736cc773659a966a0c (patch) | |
tree | 62eef5d947b8384b8147ec6d6b0b4aecba2485ac /gcc/cpphash.c | |
parent | 26439cc59cd34989b7a98d676a5e210302da15c0 (diff) | |
download | gcc-cf4ed945eab57de7fe5b2f736cc773659a966a0c.zip gcc-cf4ed945eab57de7fe5b2f736cc773659a966a0c.tar.gz gcc-cf4ed945eab57de7fe5b2f736cc773659a966a0c.tar.bz2 |
cppexp.c: Don't include cpphash.h.
* cppexp.c: Don't include cpphash.h.
(parse_charconst, cpp_lex): Use cpp_defined.
(cpp_lex): Use get_directive_token throughout. Remove
unnecessary cases from switch. Move assertion-handling code
down to OTHER case.
(cpp_parse_expr): If we see '+' or '-', check the context to
determine if they are unary or binary operators. Streamline
the jumps a bit. Do not call skip_rest_of_line.
* cpplib.c: Make skip_rest_of_line and cpp_skip_hspace
static. Export get_directive_token. Update commentary.
(cpp_defined): New function.
(do_define): Remove reference to T_PCSTRING. Call
free_definition to release memory for old definition, when
redefining a macro.
(eval_if_expression): Set only_seen_white to 0 before calling
cpp_parse_expr. Call skip_rest_of_line after it returns.
(cpp_read_check_assertion): Don't preserve a pointer into the
token buffer across a call to cpp_get_token.
* Makefile.in (cppexp.o): Don't depend on cpphash.h.
* cppfiles.c (redundant_include_p): Use cpp_defined.
* cpphash.c (free_definition): New function.
(delete_macro): Use it. Update commentary.
* cpphash.h: Typedef HASHNODE here. Prototype cpp_lookup and
free_definition.
* cpplib.h: Don't typedef HASHNODE here. Delete T_PCSTRING
from enum node_type. Prototype cpp_defined and get_directive_token.
Don't prototype cpp_lookup, skip_rest_of_line, or cpp_skip_hspace.
* fix-header.c (check_macro_names): Use cpp_defined.
(read_scan_file): Set inhibit_warnings and inhibit_errors in
the options structure.
From-SVN: r31908
Diffstat (limited to 'gcc/cpphash.c')
-rw-r--r-- | gcc/cpphash.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/gcc/cpphash.c b/gcc/cpphash.c index 0a4e860..7b0bea2 100644 --- a/gcc/cpphash.c +++ b/gcc/cpphash.c @@ -140,20 +140,31 @@ cpp_lookup (pfile, name, len) return (HASHNODE *) 0; } +/* Free a DEFINITION structure. Used by delete_macro, and by + do_define when redefining macros. */ + +void +free_definition (d) + DEFINITION *d; +{ + struct reflist *ap, *nextap; + + for (ap = d->pattern; ap != NULL; ap = nextap) + { + nextap = ap->next; + free (ap); + } + if (d->nargs >= 0) + free (d->argnames); + free (d); +} + /* * Delete a hash node. Some weirdness to free junk from macros. * More such weirdness will have to be added if you define more hash * types that need it. */ -/* Note that the DEFINITION of a macro is removed from the hash table - but its storage is not freed. This would be a storage leak - except that it is not reasonable to keep undefining and redefining - large numbers of macros many times. - In any case, this is necessary, because a macro can be #undef'd - in the middle of reading the arguments to a call to it. - If #undef freed the DEFINITION, that would crash. */ - void delete_macro (hp) HASHNODE *hp; @@ -170,19 +181,7 @@ delete_macro (hp) *hp->bucket_hdr = hp->next; if (hp->type == T_MACRO) - { - DEFINITION *d = hp->value.defn; - struct reflist *ap, *nextap; - - for (ap = d->pattern; ap != NULL; ap = nextap) - { - nextap = ap->next; - free (ap); - } - if (d->nargs >= 0) - free (d->argnames); - free (d); - } + free_definition (hp->value.defn); free (hp); } |