summaryrefslogtreecommitdiff
path: root/libcpp/include
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-22 15:29:21 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-22 15:29:21 +0000
commite557fc7f73ea0b8206a8d126b43f82e7c5cc4979 (patch)
tree895845f1cef79ed1f8c6a341ccf3973a27e22944 /libcpp/include
parent8469aece13814deddf2cd80538d33c2d0a8d60d9 (diff)
downloadgcc-e557fc7f73ea0b8206a8d126b43f82e7c5cc4979.tar.gz
libcpp: Tweak to missing #include source location
This patch tweaks the error message location for missing header files. Previously these read: test.c:1:17: fatal error: 404.h: No such file or directory #include "404.h" ^ compilation terminated. With this patch, the pertinent string is underlined: test.c:1:10: fatal error: 404.h: No such file or directory #include "404.h" ^~~~~~~ compilation terminated. gcc/testsuite/ChangeLog: * c-c++-common/missing-header-1.c: New test case. * c-c++-common/missing-header-2.c: New test case. * c-c++-common/missing-header-3.c: New test case. * c-c++-common/missing-header-4.c: New test case. libcpp/ChangeLog: * directives.c (do_include_common): Pass on "location" to _cpp_stack_include. * errors.c (cpp_diagnostic): Reimplement in terms of... (cpp_diagnostic_at): New function. (cpp_error_at): New function. (cpp_errno_filename): Add "loc" param and use it by using cpp_error_at rather than cpp_error. * files.c (find_file_in_dir): Add "loc" param and pass it to open_file_failed. (_cpp_find_file): Add "loc" param. Use it to convert calls to cpp_error to cpp_error_at, and pass it to find_file_in_dir and open_file_failed. (read_file_guts): Add "loc" param. Use it to convert calls to cpp_error to cpp_error_at. Pass it to cpp_errno_filename. (read_file): Add "loc" param. Pass it to open_file_failed and read_file_guts. (should_stack_file): Add "loc" param. Pass it to read_file. (_cpp_stack_file): Add "loc" param. Pass it to should_stack_file. (_cpp_stack_include): Add "loc" param. Pass it to _cpp_find_file and _cpp_stack_file. (open_file_failed): Add "loc" param. Pass it to cpp_errno_filename. (_cpp_fake_include): Add 0 as a source_location in call to _cpp_find_file. (_cpp_compare_file_date): Likewise. (cpp_push_include): Likewise for call to _cpp_stack_include. (cpp_push_default_include): Likewise. (_cpp_save_file_entries): Likewise for call to open_file_failed. (_cpp_has_header): Likewise for call to _cpp_find_file. * include/cpplib.h (cpp_errno_filename): Add source_location param. (cpp_error_at): New declaration. * init.c (cpp_read_main_file): Add 0 as a source_location in calls to _cpp_find_file and _cpp_stack_file. * internal.h (_cpp_find_file): Add source_location param. (_cpp_stack_file): Likewise. (_cpp_stack_include): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237715 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/include')
-rw-r--r--libcpp/include/cpplib.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 9d70cc856ef..543f3b97153 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -992,7 +992,8 @@ extern bool cpp_warning_syshdr (cpp_reader *, int, const char *msgid, ...)
extern bool cpp_errno (cpp_reader *, int, const char *msgid);
/* Similarly, but with "FILENAME: " instead of "MSGID: ", where
the filename is not localized. */
-extern bool cpp_errno_filename (cpp_reader *, int, const char *filename);
+extern bool cpp_errno_filename (cpp_reader *, int, const char *filename,
+ source_location loc);
/* Same as cpp_error, except additionally specifies a position as a
(translation unit) physical line and physical column. If the line is
@@ -1010,6 +1011,10 @@ extern bool cpp_warning_with_line_syshdr (cpp_reader *, int, source_location,
unsigned, const char *msgid, ...)
ATTRIBUTE_PRINTF_5;
+extern bool cpp_error_at (cpp_reader * pfile, int level,
+ source_location src_loc, const char *msgid, ...)
+ ATTRIBUTE_PRINTF_4;
+
/* In lex.c */
extern int cpp_ideq (const cpp_token *, const char *);
extern void cpp_output_line (cpp_reader *, FILE *);