preprocessor: Reimplement directives only processing, support raw literals.
authorNathan Sidwell <nathan@acm.org>
Fri, 8 May 2020 18:06:49 +0000 (11:06 -0700)
committerNathan Sidwell <nathan@acm.org>
Fri, 8 May 2020 18:13:29 +0000 (11:13 -0700)
commitb224c3763e018e8bdd0047b3eb283992fb655ce0
tree0b9853fb61dcbb380a433dec1f58679c77036663
parentbc484e250990393e887f7239157cc85ce6fadcce
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.
33 files changed:
gcc/c-family/ChangeLog
gcc/c-family/c-ppoutput.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/cpp/counter-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/counter-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-1.h [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-3a.h [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-3b.h [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-4.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-5.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-6.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-7.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/dir-only-8.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/counter-2.c [deleted file]
gcc/testsuite/gcc.dg/cpp/counter-3.c [deleted file]
gcc/testsuite/gcc.dg/cpp/dir-only-1.c [deleted file]
gcc/testsuite/gcc.dg/cpp/dir-only-1.h [deleted file]
gcc/testsuite/gcc.dg/cpp/dir-only-2.c [deleted file]
gcc/testsuite/gcc.dg/cpp/dir-only-3.c [deleted file]
gcc/testsuite/gcc.dg/cpp/dir-only-3a.h [deleted file]
gcc/testsuite/gcc.dg/cpp/dir-only-3b.h [deleted file]
gcc/testsuite/gcc.dg/cpp/dir-only-4.c [deleted file]
gcc/testsuite/gcc.dg/cpp/dir-only-5.c [deleted file]
gcc/testsuite/gcc.dg/cpp/dir-only-6.c [deleted file]
libcpp/ChangeLog
libcpp/Makefile.in
libcpp/directives-only.c [deleted file]
libcpp/include/cpplib.h
libcpp/internal.h
libcpp/lex.c