diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-10-08 12:11:37 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-10-08 12:16:21 -0700 |
commit | d1c566d72d9361b37213881222c7e2713cdf05b7 (patch) | |
tree | aa7640d9fb655ceb26caddbd903344fb6662a1e1 /libcpp/internal.h | |
parent | cd23ed8af236db2d28314e0652d04e5a0e1540b6 (diff) | |
download | gcc-d1c566d72d9361b37213881222c7e2713cdf05b7.zip gcc-d1c566d72d9361b37213881222c7e2713cdf05b7.tar.gz gcc-d1c566d72d9361b37213881222c7e2713cdf05b7.tar.bz2 |
libcpp: Directly peek for initial line marker
Using the tokenizer to sniff for an initial line marker for
preprocessed input is a little brittle, particularly with
-fdirectives-only. If there is no marker we'll happily munch initial
comments. This patch directly sniffs the buffer. This is safe
because the initial line marker was machine generated and must be
right at the beginning of the file. Anything else is not such a line
marker. The same is true for the initial directory marker. For that
tokenizing the string is simplest, but at that point it's either a
regular line marker or a directory marker. If it's a regular marker,
unwinding tokens is fine.
libcpp/
* internal.h (enum include_type): Rename IT_MAIN_INJECT to
IT_PRE_MAIN.
* init.c (cpp_read_main_file): If there is no line marker, adjust
the initial line marker.
(read_original_filename): Return bool, peek the buffer directly
before trying to tokenize.
(read_original_directory): Likewise. Directly prod the string
literal.
* files.c (_cpp_stack_file): Adjust for IT_PRE_MAIN change.
Diffstat (limited to 'libcpp/internal.h')
-rw-r--r-- | libcpp/internal.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libcpp/internal.h b/libcpp/internal.h index 4bafe1c..b728df7 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -124,8 +124,8 @@ enum include_type IT_CMDLINE, /* -include */ IT_DEFAULT, /* forced header */ IT_MAIN, /* main, start on line 1 */ - IT_MAIN_INJECT, /* main, but there will be an injected preamble - before line 1 */ + IT_PRE_MAIN, /* main, but there will be a preamble before line + 1 */ IT_DIRECTIVE_HWM = IT_IMPORT + 1, /* Directives below this. */ IT_HEADER_HWM = IT_DEFAULT + 1 /* Header files below this. */ |