]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: tweak colorization of incompatible declspecs
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 11 Dec 2024 15:32:14 +0000 (10:32 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 11 Dec 2024 15:32:14 +0000 (10:32 -0500)
commit4b4023d52986b20369a0bdc9366d82c2b2f1efc7
tree657eb2daa6249e7af3e71e0f842946d171bd9cc2
parent7435d1dbae8ae1db239228811b1e1f2452674704
c++: tweak colorization of incompatible declspecs

Introduce a helper function for complaining about "signed unsigned"
and "short long".  Add colorization there so that e.g. the 'signed'
and 'unsigned' are given consistent contrasting colors in both the
message and the quoted source.

gcc/cp/ChangeLog:
* decl.cc: Add #include "diagnostic-highlight-colors.h"
and #include "pretty-print-markup.h".
(complain_about_incompatible_declspecs): New.
(grokdeclarator): Use it when complaining about both 'signed' and
'unsigned', and both 'long' and 'short'.

gcc/ChangeLog:
* diagnostic-highlight-colors.h: Tweak comment.
* pretty-print-markup.h (class pp_element_quoted_string): New,
based on pretty-print.cc's selftest::test_element, adding an
optional highlight color.
* pretty-print.cc (class test_element): Drop.
(selftest::test_pp_format): Use pp_element_quoted_string.
(selftest::test_urlification): Likewise.

gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/long-short-colorization.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/cp/decl.cc
gcc/diagnostic-highlight-colors.h
gcc/pretty-print-markup.h
gcc/pretty-print.cc
gcc/testsuite/g++.dg/diagnostic/long-short-colorization.C [new file with mode: 0644]