aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppmain.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2000-12-17 00:13:54 +0000
committerNeil Booth <neil@gcc.gnu.org>2000-12-17 00:13:54 +0000
commitad2a084dbd3fbcacde8a5034ef381b1ee41d09e5 (patch)
treedc9788c071208bc6125b57c49a68337f6a09eb53 /gcc/cppmain.c
parent3b67042af8f91e658c6467d3dad4464c89c069ab (diff)
downloadgcc-ad2a084dbd3fbcacde8a5034ef381b1ee41d09e5.zip
gcc-ad2a084dbd3fbcacde8a5034ef381b1ee41d09e5.tar.gz
gcc-ad2a084dbd3fbcacde8a5034ef381b1ee41d09e5.tar.bz2
c-lex.c: Move main_input_filename handling to FC_ENTER.
* c-lex.c: Move main_input_filename handling to FC_ENTER. Clean up. * cpperror.c (print_containing_files): Get right line number. (print_location): Output column of 1 if 0. * cppfiles.c (stack_include_file): cpp_push_buffer handles the callback. * cpphash.h (_cpp_do_file_change): No longer external. * cpplib.c (do_file_change): Now local to cpplib.c. (do_line): Fake a buffer stack for preprocessed files. (cpp_push_buffer): Create a file_change callback. Handle faked buffers. (cpp_pop_buffer): Similarly. * cpplib.h: BUF_FAKE: New buffer type. * cppmain.c: Update to handle correct file renaming where a #line is the first line of the main file, and produce only the renamed file, not the original file, as output. From-SVN: r38319
Diffstat (limited to 'gcc/cppmain.c')
-rw-r--r--gcc/cppmain.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/gcc/cppmain.c b/gcc/cppmain.c
index cc958e0..7e12d6b 100644
--- a/gcc/cppmain.c
+++ b/gcc/cppmain.c
@@ -263,7 +263,10 @@ maybe_print_line (line)
if (print.no_line_dirs)
return;
- if (line >= print.lineno && line < print.lineno + 8)
+ /* print.lineno is zero if this is the first token of the file. We
+ handle this specially, so that a first line of "# 1 "foo.c" in
+ file foo.i outputs just the foo.c line, and not a foo.i line. */
+ if (line >= print.lineno && line < print.lineno + 8 && print.lineno)
{
while (line > print.lineno)
{
@@ -358,7 +361,6 @@ cb_change_file (pfile, fc)
if (fc->reason == FC_ENTER && fc->from.filename)
maybe_print_line (fc->from.lineno);
- print.lineno = fc->to.lineno;
print.last_fname = fc->to.filename;
if (fc->externc)
print.syshdr_flags = " 3 4";
@@ -367,14 +369,18 @@ cb_change_file (pfile, fc)
else
print.syshdr_flags = "";
- switch (fc->reason)
+ if (print.lineno)
{
- case FC_ENTER : flags = fc->from.filename ? " 1": ""; break;
- case FC_LEAVE : flags = " 2"; break;
- case FC_RENAME: flags = ""; break;
- }
+ print.lineno = fc->to.lineno;
+ switch (fc->reason)
+ {
+ case FC_ENTER : flags = " 1"; break;
+ case FC_LEAVE : flags = " 2"; break;
+ case FC_RENAME: flags = ""; break;
+ }
- print_line (flags);
+ print_line (flags);
+ }
}
static void