diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-05-08 11:06:49 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-05-08 11:13:29 -0700 |
commit | b224c3763e018e8bdd0047b3eb283992fb655ce0 (patch) | |
tree | 0b9853fb61dcbb380a433dec1f58679c77036663 /libcpp/include | |
parent | bc484e250990393e887f7239157cc85ce6fadcce (diff) | |
download | gcc-b224c3763e018e8bdd0047b3eb283992fb655ce0.zip gcc-b224c3763e018e8bdd0047b3eb283992fb655ce0.tar.gz gcc-b224c3763e018e8bdd0047b3eb283992fb655ce0.tar.bz2 |
preprocessor: Reimplement directives only processing, support raw literals.
The existing directives-only code (a) punched a hole through the
libcpp interface and (b) didn't support raw string literals. This
reimplements this preprocessing mode. I added a proper callback
interface, and adjusted c-ppoutput to use it. Sadly I cannot get rid
of the libcpp/internal.h include for unrelated reasons.
The new scanner is in lex.x, and works doing some backwards scanning
when it finds a charater of interest. This reduces the number of
cases one has to deal with in forward scanning. It may have different
failure mode than forward scanning on bad tokenization.
Finally, Moved some cpp tests from the c-specific dg.gcc/cpp directory
to the c-c++-common/cpp shared directory,
libcpp/
* directives-only.c: Delete.
* Makefile.in (libcpp_a_OBJS, libcpp_a_SOURCES): Remove it.
* include/cpplib.h (enum CPP_DO_task): New enum.
(cpp_directive_only_preprocess): Declare.
* internal.h (_cpp_dir_only_callbacks): Delete.
(_cpp_preprocess_dir_only): Delete.
* lex.c (do_peek_backslask, do_peek_next, do_peek_prev): New.
(cpp_directives_only_process): New implementation.
gcc/c-family/
Reimplement directives only processing.
* c-ppoutput.c (token_streamer): Ne.
(directives_only_cb): New. Swallow ...
(print_lines_directives_only): ... this.
(scan_translation_unit_directives_only): Reimplment using the
published interface.
gcc/testsuite/
* gcc.dg/cpp/counter-[23].c: Move to c-c+_-common/cpp.
* gcc.dg/cpp/dir-only-*: Likewise.
* c-c++-common/cpp/dir-only-[78].c: New.
Diffstat (limited to 'libcpp/include')
-rw-r--r-- | libcpp/include/cpplib.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 03cc72a..2b1e33f 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -1304,6 +1304,18 @@ extern int cpp_read_state (cpp_reader *, const char *, FILE *, /* In lex.c */ extern void cpp_force_token_locations (cpp_reader *, location_t); extern void cpp_stop_forcing_token_locations (cpp_reader *); +enum CPP_DO_task +{ + CPP_DO_print, + CPP_DO_location, + CPP_DO_token +}; + +extern void cpp_directive_only_process (cpp_reader *pfile, + void *data, + void (*cb) (cpp_reader *, + CPP_DO_task, + void *data, ...)); /* In expr.c */ extern enum cpp_ttype cpp_userdef_string_remove_type |