aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorNeil Booth <neil@gcc.gnu.org>2001-08-02 23:03:31 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-08-02 23:03:31 +0000
commitd82fc1085fad2fd7a776bcc88dbac88f081dd10f (patch)
treeaedb0e3e4381261de71d4d7cee777f2ccde7880d /gcc/cppinit.c
parent6ff02a9579cfb21fd184f3e634c4c837732d7cb5 (diff)
downloadgcc-d82fc1085fad2fd7a776bcc88dbac88f081dd10f.zip
gcc-d82fc1085fad2fd7a776bcc88dbac88f081dd10f.tar.gz
gcc-d82fc1085fad2fd7a776bcc88dbac88f081dd10f.tar.bz2
line-map.c: New.
* line-map.c: New. * line-map.h: New. * Makefile.in (line-map.o): New. (LIBCPP_OBJS, LIBCPP_DEPS): Update. * c-lex.c (cb_file_change): Update for new cpp_file_change structure. * cpperror.c (print_containing_files): Similarly. (print_location): Update. Don't output a space before _Pragma. * cppfiles.c (stack_include_file): Set to line 1 immediately. (stack_include_filee, cpp_make_system_header): Update. (_cpp_execute_include): Get logical line number right for calling as-yet-unterminated #include. * cpphash.h (struct cpp_reader): Add line_maps. (_cpp_do_file_change): Update. * cppinit.c (cpp_create_reader): Initialize line maps. (cpp_destroy): Destroy line maps. (cpp_start_read): Get logical line number right. * cpplex.c (parse_string): Only warn once for multi-line strings. Use boolean variable for null warning. * cpplib.c (_cpp_handle_directive): End the directive if it isn't already. (do_include_common): End the directive early. (do_line): Don't warn about out-of-range lines in preprocessed source. Update. Remove unused variables. (_cpp_do_file_change): Update for new line mapping. (pragma_cb): New typedef. (cpp_register_pragma): Stop looking ahead before calling the handler. Clean up. (do_pragma_system_header): End directive early. (cpp_get_line_maps): New. (cpp_pop_buffer): Fudge logical line. Update. * cpplib.h: Include line-map.h (enum cpp_fc_reason): Remove. (struct cpp_file_change): Update. (cpp_get_line_maps): New. * cppmain.c (struct_printer): New member map. (cb_file_change): Update for new mappings. * fix-header.c (cb_file_change): Similarly. testsuite: * gcc.dg/cpp/19951025-1.c: Update. From-SVN: r44584
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 9c19410..fa01b34 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -496,6 +496,9 @@ cpp_create_reader (table, lang)
be needed. */
pfile->deps = deps_init ();
+ /* Initialise the line map. */
+ init_line_maps (&pfile->line_maps);
+
/* Initialize lexer state. */
pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
@@ -585,6 +588,8 @@ cpp_destroy (pfile)
free (context);
}
+ free_line_maps (&pfile->line_maps);
+
result = pfile->errors;
free (pfile);
@@ -941,6 +946,11 @@ cpp_start_read (pfile, fname)
p = q;
}
+ /* This was zero when the initial buffer was stacked; so we must
+ make up for a non-existent new line, as well as the intervening
+ macro definitions, by setting it to 1. */
+ pfile->line = 1;
+
/* The -imacros files can be scanned now, but the -include files
have to be pushed onto the buffer stack and processed later,
otherwise cppmain.c won't see the tokens. include_head was built