aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpphash.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-05-18 15:55:46 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-05-18 15:55:46 +0000
commit15dad1d9085624c3bce83e0fa0d9b2764f65bccb (patch)
treeeae8b6ec3c589f4957c72e8c82be5c3cc2ea4bbf /gcc/cpphash.c
parent7021bb50d4366bf1630d5a685704d0118b06621a (diff)
downloadgcc-15dad1d9085624c3bce83e0fa0d9b2764f65bccb.zip
gcc-15dad1d9085624c3bce83e0fa0d9b2764f65bccb.tar.gz
gcc-15dad1d9085624c3bce83e0fa0d9b2764f65bccb.tar.bz2
cppexp.c (parse_assertion): New.
* cppexp.c (parse_assertion): New. (lex): Call it for CPP_HASH. Remove CPP_ASSERTION case. (_cpp_parse_expr): Remove case '#'. Don't set parsing_if_directive. * cpphash.c (collect_objlike_expansion, collect_funlike_expansion, collect_params, _cpp_create_definition): The list no longer has a trailing VSPACE token. * cpphash.h (enum node_type): Add T_ASSERTION. (struct hashnode): Remove aschain, add pred. (struct predicate): New. Update prototypes. * cpplex.c (expand_token_space): Handle both offset and nonoffset lists. (init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete. (_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist, _cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens, _cpp_equiv_toklists): New. (_cpp_scan_line): Rename to _cpp_scan_until; add ability to stop at any single-character token, not just newline. (_cpp_lex_token): Remove special cases for #define and #if. (cpp_get_token): Expect # as a separate token type. Remove DIRECTIVE case. (_cpp_get_directive_token): Remove DIRECTIVE case. (_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update. * cpplib.c (_cpp_check_directive): Set dirno and SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags. (_cpp_handle_directive): Run # <number> through the same logic as normal directives. (do_define): Don't set parsing_define_directive. Use _cpp_scan_until. The list does not have a VSPACE at the end. (do_if): Save, clear, and restore only_seen_white around _cpp_parse_expr. (skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/ (do_assert, do_unassert): Rewrite. * cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION. (LIST_OFFSET): New flag. (struct cpp_toklist): Replace dir_handler and dir_flags with dirno and flags. (struct cpp_reader): Remove parsing_if_directive and parsing_define_directive. From-SVN: r33984
Diffstat (limited to 'gcc/cpphash.c')
-rw-r--r--gcc/cpphash.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/gcc/cpphash.c b/gcc/cpphash.c
index 21efb09..3eb7d1a 100644
--- a/gcc/cpphash.c
+++ b/gcc/cpphash.c
@@ -480,12 +480,6 @@ collect_objlike_expansion (pfile, list)
{
switch (TOK_TYPE (list, i))
{
- case CPP_EOF:
- cpp_ice (pfile, "EOF in collect_expansion");
- /* fall through */
- case CPP_VSPACE:
- goto done;
-
case CPP_PASTE:
/* ## is not special if it appears right after another ##;
nor is it special if -traditional. */
@@ -506,7 +500,6 @@ collect_objlike_expansion (pfile, list)
CPP_PUTS (pfile, TOK_NAME (list, i), TOK_LEN (list, i));
last_was_paste = 0;
}
- done:
if (last_was_paste)
cpp_error (pfile, "`##' at end of macro definition");
@@ -568,12 +561,6 @@ collect_funlike_expansion (pfile, list, arglist, replacement)
len = TOK_LEN (list, i);
switch (token)
{
- case CPP_EOF:
- cpp_ice (pfile, "EOF in collect_expansion");
- /* fall through */
- case CPP_VSPACE:
- goto done;
-
case CPP_HASH:
/* # is special in function-like macros with no args.
(6.10.3.2 para 1.) However, it is not special after
@@ -677,7 +664,6 @@ collect_funlike_expansion (pfile, list, arglist, replacement)
}
last_token = ARG;
}
- done:
if (last_token == STRIZE)
cpp_error (pfile, "`#' is not followed by a macro argument name");
@@ -759,8 +745,8 @@ collect_params (pfile, list, arglist)
case CPP_CLOSE_PAREN:
goto scanned;
case CPP_VSPACE:
- cpp_error_with_line (pfile, list->line, TOK_COL (list, i),
- "missing right paren in macro argument list");
+ case CPP_EOF:
+ cpp_ice (pfile, "impossible token in macro argument list");
return 0;
default:
@@ -783,9 +769,8 @@ collect_params (pfile, list, arglist)
}
goto scanned;
}
-
- cpp_ice (pfile, "collect_params: unreachable - i=%d, ntokens=%d, type=%d",
- i, list->tokens_used, TOK_TYPE (list, i-1));
+ cpp_error_with_line (pfile, list->line, TOK_COL (list, i-1),
+ "missing right paren in macro argument list");
return 0;
scanned:
@@ -892,9 +877,9 @@ _cpp_create_definition (pfile, list, hp)
#define FUNC(a, b, ...) // nothing
#define FUNC(a, b, c) FUNC(a, b, c) */
- if (list->tokens_used == 2)
+ if (list->tokens_used == 1)
ntype = T_EMPTY; /* Empty definition of object-like macro. */
- else if (list->tokens_used == 3 && TOK_TYPE (list, 1) == CPP_NAME
+ else if (list->tokens_used == 2 && TOK_TYPE (list, 1) == CPP_NAME
&& TOK_LEN (list, 0) == TOK_LEN (list, 1)
&& !ustrncmp (TOK_NAME (list, 0), TOK_NAME (list, 1),
TOK_LEN (list, 0)))