aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.h
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-03-01 00:57:09 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-03-01 00:57:09 +0000
commitba412f14ad13a1e71af1aebe1ee97c6591e1f12e (patch)
tree68077897eecebf1187d9c261fbded410af33eaf4 /gcc/cpplib.h
parent38769add25b9fb5b4d60e98c60ab2d6fb8bf0854 (diff)
downloadgcc-ba412f14ad13a1e71af1aebe1ee97c6591e1f12e.zip
gcc-ba412f14ad13a1e71af1aebe1ee97c6591e1f12e.tar.gz
gcc-ba412f14ad13a1e71af1aebe1ee97c6591e1f12e.tar.bz2
cpplib.h (CPP_ASSERTION, [...]): New token types.
* cpplib.h (CPP_ASSERTION, CPP_STRINGIZE, CPP_TOKPASTE): New token types. (struct cpp_reader): Add parsing_if_directive and parsing_define_directive flags. (struct cpp_options): Remove output_conditionals flag. (check_macro_name): Delete prototype. * cpphash.h (struct macrodef): Delete. (struct reflist): Separate from struct definition. (struct definition): Remove unused fields. Add column number. (create_definition): Returns a DEFINITION *. Takes a cpp_reader * and an int. * cpphash.c (SKIP_WHITE_SPACE): Delete. (PEEKC): Copy defn from cpplib.c. (rest_extension, REST_EXTENSION_LENGTH): Delete. (struct arg): New. (struct arglist): Simplify. (collect_expansion): Rewrite. Get tokens by calling cpp_get_token. Add more error checking. (collect_formal_parameters): New function, broken out of create_definition and reworked to use get_directive_token. (create_definition): All real work is now in collect_expansion and collect_formal_parameters. do_define handles finding the macro name. Return a DEFINITION, not a MACRODEF. (macroexpand): Replace bcopy with memcpy throughout. Replace character-at-a-time copy loop with memcpy and pointer increments. (compare-defs): d1->argnames / d2->argnames might be null. * cpplib.c (copy_rest_of_line): Delete function. (skip_rest_of_line): Do all the work ourselves. (skip_string): New function. (parse_string): Use skip_string. (get_macro_name): New function. (check_macro_name): Delete. (copy_comment): Use CPP_RESERVE and CPP_PUTC_Q. (cpp_skip_hspace): Use CPP_BUMP_LINE. (handle_directive): ICE if we're called on a macro buffer. (do_define): Determine macro name and type (funlike/objlike) here. Expunge all uses of MACRODEF. (cpp_push_buffer): Set line_base to NULL. (do_undef, read_line_number): Don't worry about getting a POP token. (eval_if_expression): Set/reset parsing_if_directive around cpp_parse_expr. Don't clear only_seen_white. (skip_if_group): Remove output_conditionals logic. Use skip_rest_of_line. (cpp_get_token): Return ASSERTION, STRINGIZE, and TOKPASTE tokens under appropriate conditions. (cpp_unassert): Call do_unassert not do_assert. Oops. * cppexp.c (parse_defined): New function, break out of cpp_lex. (cpp_lex): We now get CPP_ASSERTION tokens and can check them ourselves, with cpp_defined. * cppinit.c (cpp_handle_option, print_help): Delete -ifoutput. * gcc.dg/20000209-2.c: Turn off -pedantic-errors. * gcc.dg/strpaste-2.c: New. From-SVN: r32274
Diffstat (limited to 'gcc/cpplib.h')
-rw-r--r--gcc/cpplib.h35
1 files changed, 18 insertions, 17 deletions
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 71726aa..6c16494 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -47,14 +47,17 @@ enum cpp_token {
CPP_STRING,
CPP_WSTRING,
CPP_DIRECTIVE,
- CPP_LPAREN, /* "(" */
- CPP_RPAREN, /* ")" */
- CPP_LBRACE, /* "{" */
- CPP_RBRACE, /* "}" */
- CPP_COMMA, /* "," */
- CPP_SEMICOLON,/* ";" */
- CPP_3DOTS, /* "..." */
- CPP_POP /* We're about to pop the buffer stack. */
+ CPP_ASSERTION, /* #machine(a29k) */
+ CPP_STRINGIZE, /* stringize macro argument */
+ CPP_TOKPASTE, /* paste macro arg with next/prev token */
+ CPP_LPAREN, /* "(" */
+ CPP_RPAREN, /* ")" */
+ CPP_LBRACE, /* "{" */
+ CPP_RBRACE, /* "}" */
+ CPP_COMMA, /* "," */
+ CPP_SEMICOLON, /* ";" */
+ CPP_3DOTS, /* "..." */
+ CPP_POP /* We're about to pop the buffer stack. */
};
typedef enum cpp_token (*parse_underflow_t) PARAMS((cpp_reader *));
@@ -193,7 +196,6 @@ struct cpp_reader
/* If non-zero, directives cause a hard error. Used when parsing
macro arguments. */
-
char no_directives;
/* Print column number in error messages. */
@@ -205,6 +207,12 @@ struct cpp_reader
/* If true, character between '<' and '>' are a single (string) token. */
char parsing_include_directive;
+ /* If true, # introduces an assertion (see do_assert) */
+ char parsing_if_directive;
+
+ /* If true, # and ## are the STRINGIZE and TOKPASTE operators */
+ char parsing_define_directive;
+
/* True if escape sequences (as described for has_escapes in
parse_buffer) should be emitted. */
char output_escapes;
@@ -217,7 +225,7 @@ struct cpp_reader
/* Nonzero means this file was included with a -imacros or -include
command line and should not be recorded as an include file. */
- int no_record_file;
+ char no_record_file;
long lineno;
@@ -427,11 +435,6 @@ struct cpp_options {
char no_line_commands;
-/* Nonzero means output the text in failing conditionals,
- inside #failed ... #endfailed. */
-
- char output_conditionals;
-
/* Nonzero means -I- has been seen,
so don't look for #include "foo" the source-file directory. */
char ignore_srcdir;
@@ -689,14 +692,12 @@ extern int cpp_defined PARAMS ((cpp_reader *, const U_CHAR *, int));
extern void cpp_reader_init PARAMS ((cpp_reader *));
extern void cpp_options_init PARAMS ((cpp_options *));
extern int cpp_start_read PARAMS ((cpp_reader *, char *));
-extern int cpp_read_check_assertion PARAMS ((cpp_reader *));
extern void cpp_finish PARAMS ((cpp_reader *));
extern void quote_string PARAMS ((cpp_reader *, const char *));
extern void cpp_expand_to_buffer PARAMS ((cpp_reader *, const U_CHAR *,
int));
extern void cpp_scan_buffer PARAMS ((cpp_reader *));
-extern int check_macro_name PARAMS ((cpp_reader *, const U_CHAR *));
/* Last arg to output_line_command. */
enum file_change_code {same_file, rename_file, enter_file, leave_file};