aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-06-22 15:29:21 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-06-22 15:29:21 +0000
commitac81cf0b2bf5efdd716d10d1c218eb5a17e1035b (patch)
tree895845f1cef79ed1f8c6a341ccf3973a27e22944 /gcc
parent1a4f11c88ae761d4c618e540e07e4e32e85850d1 (diff)
downloadgcc-ac81cf0b2bf5efdd716d10d1c218eb5a17e1035b.zip
gcc-ac81cf0b2bf5efdd716d10d1c218eb5a17e1035b.tar.gz
gcc-ac81cf0b2bf5efdd716d10d1c218eb5a17e1035b.tar.bz2
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. From-SVN: r237715
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/c-c++-common/missing-header-1.c8
-rw-r--r--gcc/testsuite/c-c++-common/missing-header-2.c8
-rw-r--r--gcc/testsuite/c-c++-common/missing-header-3.c8
-rw-r--r--gcc/testsuite/c-c++-common/missing-header-4.c8
5 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2082fff..9c54022 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,12 @@
2016-06-22 David Malcolm <dmalcolm@redhat.com>
+ * 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.
+
+2016-06-22 David Malcolm <dmalcolm@redhat.com>
+
PR c/70339
* c-c++-common/attributes-1.c: Update dg-prune-output to include
hint.
diff --git a/gcc/testsuite/c-c++-common/missing-header-1.c b/gcc/testsuite/c-c++-common/missing-header-1.c
new file mode 100644
index 0000000..30e92ad
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/missing-header-1.c
@@ -0,0 +1,8 @@
+/* { dg-options "-fdiagnostics-show-caret" } */
+#include "this-file-does-not-exist.h" /* { dg-error "10: this-file-does-not-exist.h: No such file or directory" } */
+
+/* { dg-begin-multiline-output "" }
+ #include "this-file-does-not-exist.h"
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
+compilation terminated.
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/missing-header-2.c b/gcc/testsuite/c-c++-common/missing-header-2.c
new file mode 100644
index 0000000..a634703
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/missing-header-2.c
@@ -0,0 +1,8 @@
+/* { dg-options "-fdiagnostics-show-caret" } */
+#include <this-file-does-not-exist.h> /* { dg-error "10: this-file-does-not-exist.h: No such file or directory" } */
+
+/* { dg-begin-multiline-output "" }
+ #include <this-file-does-not-exist.h>
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
+compilation terminated.
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/missing-header-3.c b/gcc/testsuite/c-c++-common/missing-header-3.c
new file mode 100644
index 0000000..4147367
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/missing-header-3.c
@@ -0,0 +1,8 @@
+/* { dg-options "-fdiagnostics-show-caret -Wno-deprecated" } */
+#import <this-file-does-not-exist.h> /* { dg-error "9: this-file-does-not-exist.h: No such file or directory" } */
+
+/* { dg-begin-multiline-output "" }
+ #import <this-file-does-not-exist.h>
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
+compilation terminated.
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/missing-header-4.c b/gcc/testsuite/c-c++-common/missing-header-4.c
new file mode 100644
index 0000000..d528d0d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/missing-header-4.c
@@ -0,0 +1,8 @@
+/* { dg-options "-fdiagnostics-show-caret -Wno-deprecated" } */
+#import "this-file-does-not-exist.h" /* { dg-error "9: this-file-does-not-exist.h: No such file or directory" } */
+
+/* { dg-begin-multiline-output "" }
+ #import "this-file-does-not-exist.h"
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
+compilation terminated.
+ { dg-end-multiline-output "" } */