summaryrefslogtreecommitdiff
path: root/gcc/cpplib.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cpplib.h')
-rw-r--r--gcc/cpplib.h419
1 files changed, 203 insertions, 216 deletions
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 19f958f3229..e1ae46e9eeb 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -128,306 +128,294 @@ struct htab;
efficiency, and partly to limit runaway recursion. */
#define CPP_STACK_MAX 200
-/* A cpp_reader encapsulates the "state" of a pre-processor run.
- Applying cpp_get_token repeatedly yields a stream of pre-processor
- tokens. Usually, there is only one cpp_reader object active. */
+/* Values for opts.dump_macros.
+ dump_only means inhibit output of the preprocessed text
+ and instead output the definitions of all user-defined
+ macros in a form suitable for use as input to cccp.
+ dump_names means pass #define and the macro name through to output.
+ dump_definitions means pass the whole definition (plus #define) through
+*/
+enum { dump_none = 0, dump_only, dump_names, dump_definitions };
-struct cpp_reader
+/* This structure is nested inside struct cpp_reader, and
+ carries all the options visible to the command line. */
+struct cpp_options
{
- cpp_buffer *buffer;
- cpp_options *opts;
-
- /* A buffer used for both for cpp_get_token's output, and also internally. */
- unsigned char *token_buffer;
- /* Allocated size of token_buffer. CPP_RESERVE allocates space. */
- unsigned int token_buffer_size;
- /* End of the written part of token_buffer. */
- unsigned char *limit;
-
- /* Error counter for exit code */
- int errors;
-
- /* Line where a newline was first seen in a string constant. */
- int multiline_string_line;
-
- /* Current depth in #include directives that use <...>. */
- int system_include_depth;
-
- /* Current depth of buffer stack. */
- int buffer_stack_depth;
-
- /* Hash table of macros and assertions. See cpphash.c */
- struct htab *hashtab;
-
- /* Hash table of other included files. See cppfiles.c */
- struct htab *all_include_files;
-
- /* Chain of `actual directory' file_name_list entries,
- for "" inclusion. */
- struct file_name_list *actual_dirs;
-
- /* Current maximum length of directory names in the search path
- for include files. (Altered as we get more of them.) */
- unsigned int max_include_len;
-
- struct if_stack *if_stack;
-
- /* Nonzero means we have printed (while error reporting) a list of
- containing files that matches the current status. */
- char input_stack_listing_current;
-
- /* If non-zero, macros are not expanded. */
- char no_macro_expand;
-
- /* If non-zero, directives cause a hard error. Used when parsing
- macro arguments. */
- char no_directives;
-
- /* Print column number in error messages. */
- char show_column;
-
- /* We're printed a warning recommending against using #import. */
- char import_warning;
-
- /* 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;
-
- /* 0: Have seen non-white-space on this line.
- 1: Only seen white space so far on this line.
- 2: Only seen white space so far in this file. */
- char only_seen_white;
-
- long lineno;
-
- struct tm *timebuf;
-
- /* Buffer of -M output. */
- struct deps *deps;
-
- /* A buffer and a table, used only by read_and_prescan (in cppfiles.c)
- which are allocated once per cpp_reader object to keep them off the
- stack and avoid setup costs. */
- unsigned char *input_buffer;
- unsigned char *input_speccase;
- size_t input_buffer_len;
-};
-
-#define CPP_FATAL_LIMIT 1000
-/* True if we have seen a "fatal" error. */
-#define CPP_FATAL_ERRORS(READER) ((READER)->errors >= CPP_FATAL_LIMIT)
-
-/* Macros for manipulating the token_buffer. */
+ /* Name of input and output files. */
+ const char *in_fname;
+ const char *out_fname;
-/* Number of characters currently in PFILE's output buffer. */
-#define CPP_WRITTEN(PFILE) ((size_t)((PFILE)->limit - (PFILE)->token_buffer))
-#define CPP_PWRITTEN(PFILE) ((PFILE)->limit)
-#define CPP_ADJUST_WRITTEN(PFILE,DELTA) ((PFILE)->limit += (DELTA))
-#define CPP_SET_WRITTEN(PFILE,N) ((PFILE)->limit = (PFILE)->token_buffer + (N))
+ /* Pending options - -D, -U, -A, -I, -ixxx. */
+ struct cpp_pending *pending;
-#define CPP_OPTIONS(PFILE) ((PFILE)->opts)
-#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
+ /* File name which deps are being written to. This is 0 if deps are
+ being written to stdout. */
+ const char *deps_file;
-/* Pointed to by cpp_reader.opts. */
-struct cpp_options
-{
- const char *in_fname;
+ /* Target-name to write with the dependency information. */
+ char *deps_target;
- /* Name of output file, for error messages. */
- const char *out_fname;
+ /* Search paths for include files. */
+ struct file_name_list *quote_include; /* First dir to search for "file" */
+ struct file_name_list *bracket_include;/* First dir to search for <file> */
+ /* Map between header names and file names, used only on DOS where
+ file names are limited in length. */
struct file_name_map_list *map_list;
+ /* Directory prefix that should replace `/usr/lib/gcc-lib/TARGET/VERSION'
+ in the standard include file directories. */
+ const char *include_prefix;
+ unsigned int include_prefix_len;
+
/* Non-0 means -v, so print the full set of include dirs. */
- char verbose;
+ unsigned char verbose;
/* Nonzero means use extra default include directories for C++. */
-
- char cplusplus;
+ unsigned char cplusplus;
/* Nonzero means handle cplusplus style comments */
-
- char cplusplus_comments;
+ unsigned char cplusplus_comments;
/* Nonzero means handle #import, for objective C. */
-
- char objc;
+ unsigned char objc;
/* Nonzero means this is an assembly file, so ignore unrecognized
directives and the "# 33" form of #line, both of which are
probably comments. Also, permit unbalanced ' strings (again,
likely to be in comments). */
-
- char lang_asm;
+ unsigned char lang_asm;
/* Nonzero means this is Fortran, and we don't know where the
comments are, so permit unbalanced ' strings. Unlike lang_asm,
this does not ignore unrecognized directives. */
+ unsigned char lang_fortran;
- char lang_fortran;
-
- /* Nonzero means handle CHILL comment syntax
- and output CHILL string delimiter for __DATE___ etc. */
-
- char chill;
+ /* Nonzero means handle CHILL comment syntax and output CHILL string
+ delimiters for __DATE__ etc. */
+ unsigned char chill;
/* Nonzero means don't copy comments into the output file. */
-
- char discard_comments;
+ unsigned char discard_comments;
/* Nonzero means process the ANSI trigraph sequences. */
+ unsigned char trigraphs;
- char trigraphs;
+ /* Nonzero means print the names of included files rather than the
+ preprocessed output. 1 means just the #include "...", 2 means
+ #include <...> as well. */
+ unsigned char print_deps;
- /* Nonzero means print the names of included files rather than
- the preprocessed output. 1 means just the #include "...",
- 2 means #include <...> as well. */
-
- char print_deps;
-
- /* Nonzero if missing .h files in -M output are assumed to be generated
- files and not errors. */
-
- char print_deps_missing_files;
+ /* Nonzero if missing .h files in -M output are assumed to be
+ generated files and not errors. */
+ unsigned char print_deps_missing_files;
/* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */
- char print_deps_append;
+ unsigned char print_deps_append;
/* Nonzero means print names of header files (-H). */
+ unsigned char print_include_names;
- char print_include_names;
-
- /* Nonzero means try to make failure to fit ANSI C an error. */
-
- char pedantic_errors;
+ /* Nonzero means cpp_pedwarn causes a hard error. */
+ unsigned char pedantic_errors;
/* Nonzero means don't print warning messages. */
+ unsigned char inhibit_warnings;
- char inhibit_warnings;
-
- /* Nonzero means don't print error messages. Has no option to select it,
- but can be set by a user of cpplib (e.g. fix-header). */
-
- char inhibit_errors;
+ /* Nonzero means don't print error messages. Has no option to
+ select it, but can be set by a user of cpplib (e.g. fix-header). */
+ unsigned char inhibit_errors;
/* Nonzero means warn if slash-star appears in a comment. */
-
- char warn_comments;
+ unsigned char warn_comments;
/* Nonzero means warn if there are any trigraphs. */
-
- char warn_trigraphs;
+ unsigned char warn_trigraphs;
/* Nonzero means warn if #import is used. */
-
- char warn_import;
+ unsigned char warn_import;
/* Nonzero means warn if a macro argument is (or would be)
stringified with -traditional. */
-
- char warn_stringify;
+ unsigned char warn_stringify;
/* Nonzero means turn warnings into errors. */
+ unsigned char warnings_are_errors;
- char warnings_are_errors;
-
- /* Nonzero causes output not to be done,
- but directives such as #define that have side effects
- are still obeyed. */
-
- char no_output;
+ /* Nonzero causes output not to be done, but directives such as
+ #define that have side effects are still obeyed. */
+ unsigned char no_output;
/* Nonzero means we should look for header.gcc files that remap file
names. */
- char remap;
+ unsigned char remap;
/* Nonzero means don't output line number information. */
- char no_line_commands;
+ unsigned char no_line_commands;
- /* Nonzero means -I- has been seen,
- so don't look for #include "foo" the source-file directory. */
- char ignore_srcdir;
+ /* Nonzero means -I- has been seen, so don't look for #include "foo"
+ the source-file directory. */
+ unsigned char ignore_srcdir;
- /* Zero means dollar signs are punctuation.
- This used to be needed for conformance to the C Standard,
- before the C Standard was corrected. */
- char dollars_in_ident;
+ /* Zero means dollar signs are punctuation. */
+ unsigned char dollars_in_ident;
/* Nonzero means try to imitate old fashioned non-ANSI preprocessor. */
- char traditional;
+ unsigned char traditional;
/* Nonzero means warn if undefined identifiers are evaluated in an #if. */
- char warn_undef;
+ unsigned char warn_undef;
/* Nonzero for the 1989 C Standard, including corrigenda and amendments. */
- char c89;
+ unsigned char c89;
/* Nonzero for the 1999 C Standard, including corrigenda and amendments. */
- char c99;
+ unsigned char c99;
/* Nonzero means give all the error messages the ANSI standard requires. */
- char pedantic;
+ unsigned char pedantic;
/* Nonzero means we're looking at already preprocessed code, so don't
bother trying to do macro expansion and whatnot. */
- char preprocessed;
+ unsigned char preprocessed;
- char done_initializing;
+ /* Nonzero disables all the standard directories for headers. */
+ unsigned char no_standard_includes;
- /* Search paths for include files. */
- struct file_name_list *quote_include; /* First dir to search for "file" */
- struct file_name_list *bracket_include;/* First dir to search for <file> */
+ /* Nonzero disables the C++-specific standard directories for headers. */
+ unsigned char no_standard_cplusplus_includes;
- /* Directory prefix that should replace `/usr/lib/gcc-lib/TARGET/VERSION'
- in the standard include file directories. */
- const char *include_prefix;
- int include_prefix_len;
+ /* Nonzero means dump macros in some fashion - see above. */
+ unsigned char dump_macros;
- char no_standard_includes;
- char no_standard_cplusplus_includes;
+ /* Nonzero means pass all #define and #undef directives which we
+ actually process through to the output stream. This feature is
+ used primarily to allow cc1 to record the #defines and #undefs
+ for the sake of debuggers which understand about preprocessor
+ macros, but it may also be useful with -E to figure out how
+ symbols are defined, and where they are defined. */
+ unsigned char debug_output;
-/* dump_only means inhibit output of the preprocessed text
- and instead output the definitions of all user-defined
- macros in a form suitable for use as input to cccp.
- dump_names means pass #define and the macro name through to output.
- dump_definitions means pass the whole definition (plus #define) through
-*/
+ /* Nonzero means pass #include lines through to the output. */
+ unsigned char dump_includes;
- enum {dump_none = 0, dump_only, dump_names, dump_definitions}
- dump_macros;
+ /* Print column number in error messages. */
+ unsigned char show_column;
+};
-/* Nonzero means pass all #define and #undef directives which we actually
- process through to the output stream. This feature is used primarily
- to allow cc1 to record the #defines and #undefs for the sake of
- debuggers which understand about preprocessor macros, but it may
- also be useful with -E to figure out how symbols are defined, and
- where they are defined. */
- int debug_output;
- /* Nonzero means pass #include lines through to the output,
- even if they are ifdefed out. */
- int dump_includes;
+/* A cpp_reader encapsulates the "state" of a pre-processor run.
+ Applying cpp_get_token repeatedly yields a stream of pre-processor
+ tokens. Usually, there is only one cpp_reader object active. */
- /* Pending options - -D, -U, -A, -I, -ixxx. */
- struct cpp_pending *pending;
+struct cpp_reader
+{
+ cpp_buffer *buffer;
- /* File name which deps are being written to.
- This is 0 if deps are being written to stdout. */
- const char *deps_file;
+ /* A buffer used for both for cpp_get_token's output, and also internally. */
+ unsigned char *token_buffer;
+ /* Allocated size of token_buffer. CPP_RESERVE allocates space. */
+ unsigned int token_buffer_size;
+ /* End of the written part of token_buffer. */
+ unsigned char *limit;
- /* Target-name to write with the dependency information. */
- char *deps_target;
+ /* Error counter for exit code */
+ int errors;
+
+ /* Line where a newline was first seen in a string constant. */
+ int multiline_string_line;
+
+ /* Current depth in #include directives that use <...>. */
+ int system_include_depth;
+
+ /* Current depth of buffer stack. */
+ int buffer_stack_depth;
+
+ /* Hash table of macros and assertions. See cpphash.c */
+ struct htab *hashtab;
+
+ /* Hash table of other included files. See cppfiles.c */
+ struct htab *all_include_files;
+
+ /* Chain of `actual directory' file_name_list entries,
+ for "" inclusion. */
+ struct file_name_list *actual_dirs;
+
+ /* Current maximum length of directory names in the search path
+ for include files. (Altered as we get more of them.) */
+ unsigned int max_include_len;
+
+ struct if_stack *if_stack;
+
+ long lineno;
+
+ struct tm *timebuf;
+
+ /* Buffer of -M output. */
+ struct deps *deps;
+
+ /* A buffer and a table, used only by read_and_prescan (in cppfiles.c)
+ which are allocated once per cpp_reader object to keep them off the
+ stack and avoid setup costs. */
+ unsigned char *input_buffer;
+ unsigned char *input_speccase;
+ size_t input_buffer_len;
+
+ /* User visible options. */
+ struct cpp_options opts;
+
+ /* Nonzero means we have printed (while error reporting) a list of
+ containing files that matches the current status. */
+ unsigned char input_stack_listing_current;
+
+ /* If non-zero, macros are not expanded. */
+ unsigned char no_macro_expand;
+
+ /* If non-zero, directives cause a hard error. Used when parsing
+ macro arguments. */
+ unsigned char no_directives;
+
+ /* We're printed a warning recommending against using #import. */
+ unsigned char import_warning;
+
+ /* If true, characters between '<' and '>' are a single (string) token. */
+ unsigned char parsing_include_directive;
+
+ /* If true, # introduces an assertion (see do_assert) */
+ unsigned char parsing_if_directive;
+
+ /* If true, # and ## are the STRINGIZE and TOKPASTE operators */
+ unsigned char parsing_define_directive;
+
+ /* True if escape sequences (as described for has_escapes in
+ parse_buffer) should be emitted. */
+ unsigned char output_escapes;
+
+ /* 0: Have seen non-white-space on this line.
+ 1: Only seen white space so far on this line.
+ 2: Only seen white space so far in this file. */
+ unsigned char only_seen_white;
+
+ /* True after cpp_start_read completes. Used to inhibit some
+ warnings while parsing the command line. */
+ unsigned char done_initializing;
};
+#define CPP_FATAL_LIMIT 1000
+/* True if we have seen a "fatal" error. */
+#define CPP_FATAL_ERRORS(READER) ((READER)->errors >= CPP_FATAL_LIMIT)
+
+/* Macros for manipulating the token_buffer. */
+
+/* Number of characters currently in PFILE's output buffer. */
+#define CPP_WRITTEN(PFILE) ((size_t)((PFILE)->limit - (PFILE)->token_buffer))
+#define CPP_PWRITTEN(PFILE) ((PFILE)->limit)
+#define CPP_ADJUST_WRITTEN(PFILE,DELTA) ((PFILE)->limit += (DELTA))
+#define CPP_SET_WRITTEN(PFILE,N) ((PFILE)->limit = (PFILE)->token_buffer + (N))
+
+#define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
+#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
+
/* Name under which this program was invoked. */
extern const char *progname;
@@ -436,7 +424,6 @@ extern enum cpp_token cpp_get_token PARAMS ((cpp_reader *));
extern enum cpp_token cpp_get_non_space_token PARAMS ((cpp_reader *));
extern void cpp_reader_init PARAMS ((cpp_reader *));
-extern void cpp_options_init PARAMS ((cpp_options *));
extern int cpp_start_read PARAMS ((cpp_reader *, const char *));
extern void cpp_finish PARAMS ((cpp_reader *));
extern void cpp_cleanup PARAMS ((cpp_reader *PFILE));