diff options
author | David Malcolm <dmalcolm@redhat.com> | 2019-10-10 17:03:46 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2019-10-10 17:03:46 +0000 |
commit | b4c7ca2ef3915a0b2292499dabcaabefdca04d89 (patch) | |
tree | f5fd667cc19b7b0c467092967160fc6a00594a43 /gcc/testsuite/c-c++-common | |
parent | 3245582f7d5cf4a5f69218add91a15aa606e8822 (diff) | |
download | gcc-b4c7ca2ef3915a0b2292499dabcaabefdca04d89.zip gcc-b4c7ca2ef3915a0b2292499dabcaabefdca04d89.tar.gz gcc-b4c7ca2ef3915a0b2292499dabcaabefdca04d89.tar.bz2 |
Documentation hyperlinks for [-Wname-of-option] (PR 87488)
This patch uses the support for pretty-printing escaped URLs added in
the previous patch (PR 87488) so that in a sufficiently capable terminal
the [-Wname-of-option] emitted at the end of each diagnostic becomes a
hyperlink to the documentation for that option on the GCC website.
I've tested it with Fedora 30's GNOME Terminal (3.32.2 with VTE 0.56.3);
the option text is printed with a dotted underline, hovering shows the
URL, and on right-clicking it offers menu items to visit/copy the URL.
gcc/ChangeLog:
PR 87488
* Makefile.in (CFLAGS-opts.o): Pass in DOCUMENTATION_ROOT_URL via
-D.
* configure.ac (--with-documentation-root-url): New option.
* configure: Regenerate.
* diagnostic-format-json.cc (json_end_diagnostic): If there is an
option URL, add it as a new string field of the diagnostic option.
* diagnostic.c (diagnostic_initialize): Initialize get_option_url.
(print_option_information): If get_option_url is non-NULL, call
it, and if the result is non-NULL, potentially emit an escape
sequence to markup the option text with the resulting URL.
* diagnostic.h (diagnostic_context::get_option_url): New callback.
* doc/invoke.texi (-fdiagnostics-format=): Add "option_url" to
example of JSON output.
* opts-diagnostic.h (get_option_url): New decl.
* opts.c (get_option_url): New function.
* toplev.c (general_init): Initialize the get_option_url callback.
gcc/testsuite/ChangeLog:
PR 87488
* c-c++-common/diagnostic-format-json-2.c: Expect an "option_url"
field.
* c-c++-common/diagnostic-format-json-3.c: Likewise.
* gfortran.dg/diagnostic-format-json-2.F90: Likewise.
* gfortran.dg/diagnostic-format-json-3.F90: Likewise.
* jit.dg/test-error-array-bounds.c (create_code): Ensure that
error messages don't contain escaped URLs.
From-SVN: r276843
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r-- | gcc/testsuite/c-c++-common/diagnostic-format-json-2.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/diagnostic-format-json-3.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/diagnostic-format-json-4.c | 10 |
3 files changed, 10 insertions, 2 deletions
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c index 239c75e..557ccf8 100644 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c +++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c @@ -10,6 +10,7 @@ /* { dg-regexp "\"kind\": \"warning\"" } */ /* { dg-regexp "\"message\": \"#warning message\"" } */ /* { dg-regexp "\"option\": \"-Wcpp\"" } */ +/* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\"" } */ /* { dg-regexp "\"caret\": \{" } */ /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-2.c\"" } */ diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c index 1c54eca..378205c 100644 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c +++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c @@ -10,6 +10,7 @@ /* { dg-regexp "\"kind\": \"error\"" } */ /* { dg-regexp "\"message\": \"#warning message\"" } */ /* { dg-regexp "\"option\": \"-Werror=cpp\"" } */ +/* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\"" } */ /* { dg-regexp "\"caret\": \{" } */ /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-3.c\"" } */ diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c index 1c3b034..2738be6 100644 --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c +++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c @@ -30,13 +30,12 @@ int test (void) /* { dg-regexp "\"line\": 8" } */ /* { dg-regexp "\"column\": 10" } */ -/* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */ - /* The outer diagnostic. */ /* { dg-regexp "\"kind\": \"warning\"" } */ /* { dg-regexp "\"message\": \"this 'if' clause does not guard...\"" } */ /* { dg-regexp "\"option\": \"-Wmisleading-indentation\"" } */ +/* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wmisleading-indentation\"" } */ /* { dg-regexp "\"caret\": \{" } */ /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */ @@ -48,6 +47,13 @@ int test (void) /* { dg-regexp "\"line\": 6" } */ /* { dg-regexp "\"column\": 4" } */ +/* More from the nested diagnostic (we can't guarantee what order the + "file" keys are consumed). */ + +/* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */ + +/* More from the outer diagnostic. */ + /* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */ /* { dg-regexp "\"children\": \[\[\{\}, \]*\]" } */ |