aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/bad-binary-ops-highlight-colors.C34
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/bad-binary-ops-no-highlight-colors.C29
-rw-r--r--gcc/testsuite/g++.dg/plugin/plugin.exp1
-rw-r--r--gcc/testsuite/g++.dg/plugin/show-template-tree-color-labels.C20
-rw-r--r--gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-elide-type.C8
-rw-r--r--gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-highlight-colors.C32
-rw-r--r--gcc/testsuite/g++.dg/plugin/show-template-tree-color.C8
-rw-r--r--gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-1.C200
-rw-r--r--gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-2.C52
-rw-r--r--gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-3.C54
-rw-r--r--gcc/testsuite/gcc.dg/bad-binary-ops-highlight-colors.c35
-rw-r--r--gcc/testsuite/gcc.dg/bad-binary-ops-no-highlight-colors.c30
-rw-r--r--gcc/testsuite/gcc.dg/format/colors.c27
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c2
14 files changed, 513 insertions, 19 deletions
diff --git a/gcc/testsuite/g++.dg/diagnostic/bad-binary-ops-highlight-colors.C b/gcc/testsuite/g++.dg/diagnostic/bad-binary-ops-highlight-colors.C
new file mode 100644
index 0000000..1260345
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/bad-binary-ops-highlight-colors.C
@@ -0,0 +1,34 @@
+/* Verify that colorization affects both text within diagnostic messages
+ and underlined ranges of quoted source, and that the types we use
+ match up between them.
+ Also implicitly verify that -fdiagnostics-show-highlight-colors is
+ on by default. */
+
+/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-color=always" } */
+
+struct s {};
+struct t {};
+typedef struct s S;
+typedef struct t T;
+
+extern S callee_4a (void);
+extern T callee_4b (void);
+
+int test_4 (void)
+{
+ return callee_4a () + callee_4b ();
+
+ /* { dg-begin-multiline-output "" }
+  error: no match for 'operator+' (operand types are 'S' {aka 's'} and 'T' {aka 't'})
+ { dg-end-multiline-output "" } */
+
+ /* { dg-begin-multiline-output "" }
+ return callee_4a () + callee_4b ();
+ ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
+ | |
+ S {aka s} T {aka t}
+ { dg-end-multiline-output "" } */
+
+ /* { dg-prune-output "In function" } */
+ /* { dg-prune-output "bad-binary-ops-highlight-colors.C" } */
+}
diff --git a/gcc/testsuite/g++.dg/diagnostic/bad-binary-ops-no-highlight-colors.C b/gcc/testsuite/g++.dg/diagnostic/bad-binary-ops-no-highlight-colors.C
new file mode 100644
index 0000000..5b1b65a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/bad-binary-ops-no-highlight-colors.C
@@ -0,0 +1,29 @@
+/* Verify that -fno-diagnostics-show-highlight-colors works. */
+/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-color=always -fno-diagnostics-show-highlight-colors" } */
+
+struct s {};
+struct t {};
+typedef struct s S;
+typedef struct t T;
+
+extern S callee_4a (void);
+extern T callee_4b (void);
+
+int test_4 (void)
+{
+ return callee_4a () + callee_4b ();
+
+ /* { dg-begin-multiline-output "" }
+  error: no match for 'operator+' (operand types are 'S' {aka 's'} and 'T' {aka 't'})
+ { dg-end-multiline-output "" } */
+
+ /* { dg-begin-multiline-output "" }
+ return callee_4a () + callee_4b ();
+ ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
+ | |
+ S {aka s} T {aka t}
+ { dg-end-multiline-output "" } */
+
+ /* { dg-prune-output "In function" } */
+ /* { dg-prune-output "bad-binary-ops-no-highlight-colors.C" } */
+}
diff --git a/gcc/testsuite/g++.dg/plugin/plugin.exp b/gcc/testsuite/g++.dg/plugin/plugin.exp
index 88f9b49..b5f8743 100644
--- a/gcc/testsuite/g++.dg/plugin/plugin.exp
+++ b/gcc/testsuite/g++.dg/plugin/plugin.exp
@@ -77,6 +77,7 @@ set plugin_test_list [list \
location-overflow-test-pr100796.c } \
{ show_template_tree_color_plugin.c \
show-template-tree-color.C \
+ show-template-tree-color-no-highlight-colors.C \
show-template-tree-color-labels.C \
show-template-tree-color-no-elide-type.C } \
{ comment_plugin.c comments-1.C } \
diff --git a/gcc/testsuite/g++.dg/plugin/show-template-tree-color-labels.C b/gcc/testsuite/g++.dg/plugin/show-template-tree-color-labels.C
index 462e1bd..75488cb 100644
--- a/gcc/testsuite/g++.dg/plugin/show-template-tree-color-labels.C
+++ b/gcc/testsuite/g++.dg/plugin/show-template-tree-color-labels.C
@@ -15,11 +15,11 @@ void test_1 (vector<double> vec)
{
fn_1 (vec);
/* { dg-begin-multiline-output "" }
-could not convert 'vec' from 'vector<double>' to 'vector<int>'
- fn_1 (vec);
- ^~~
- |
- vector<double>
+could not convert 'vec' from 'vector<double>' to 'vector<int>'
+ fn_1 (vec);
+ ^~~
+ |
+ vector<double>
{ dg-end-multiline-output "" } */
// TODO: we don't yet highlight the mismatching part with color
}
@@ -28,11 +28,11 @@ void test_2 (const map<int, double> &m)
{
fn_2 (m);
/* { dg-begin-multiline-output "" }
-could not convert 'm' from 'map<[...],double>' to 'map<[...],int>'
- fn_2 (m);
- ^
- |
- map<[...],double>
+could not convert 'm' from 'map<[...],double>' to 'map<[...],int>'
+ fn_2 (m);
+ ^
+ |
+ map<[...],double>
{ dg-end-multiline-output "" } */
// TODO: we don't yet highlight the mismatching part with color
}
diff --git a/gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-elide-type.C b/gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-elide-type.C
index cab0359..758a77f 100644
--- a/gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-elide-type.C
+++ b/gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-elide-type.C
@@ -15,16 +15,16 @@ void test ()
{
fn_1 (vector<double> ());
/* { dg-begin-multiline-output "" }
-could not convert 'vector<double>()' from 'vector<double>' to 'vector<int>'
+could not convert 'vector<double>()' from 'vector<double>' to 'vector<int>'
vector<
- [double != int]>
+ [double != int]>
{ dg-end-multiline-output "" } */
fn_2 (map<int, double>());
/* { dg-begin-multiline-output "" }
-could not convert 'map<int, double>()' from 'map<int,double>' to 'map<int,int>'
+could not convert 'map<int, double>()' from 'map<int,double>' to 'map<int,int>'
map<
int,
- [double != int]>
+ [double != int]>
{ dg-end-multiline-output "" } */
}
diff --git a/gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-highlight-colors.C b/gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-highlight-colors.C
new file mode 100644
index 0000000..5329f90
--- /dev/null
+++ b/gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-highlight-colors.C
@@ -0,0 +1,32 @@
+/* Verify colorization of the output of -fdiagnostics-show-template-tree,
+ and within the %H and %I format codes, but with
+ -fno-diagnostics-show-highlight-colors.
+
+ Doing so requires a plugin; see the comments in the plugin for the
+ rationale. */
+
+// { dg-options "-fdiagnostics-show-template-tree -fdiagnostics-color=always -fno-diagnostics-show-highlight-colors" }
+
+template<typename> struct vector {};
+template<typename, typename> struct map {};
+
+void fn_1(vector<int>);
+void fn_2(map<int, int>);
+
+void test ()
+{
+ fn_1 (vector<double> ());
+ /* { dg-begin-multiline-output "" }
+could not convert 'vector<double>()' from 'vector<double>' to 'vector<int>'
+ vector<
+ [double != int]>
+ { dg-end-multiline-output "" } */
+
+ fn_2 (map<int, double>());
+ /* { dg-begin-multiline-output "" }
+could not convert 'map<int, double>()' from 'map<[...],double>' to 'map<[...],int>'
+ map<
+ [...],
+ [double != int]>
+ { dg-end-multiline-output "" } */
+}
diff --git a/gcc/testsuite/g++.dg/plugin/show-template-tree-color.C b/gcc/testsuite/g++.dg/plugin/show-template-tree-color.C
index eb99a3e..cc60ba6 100644
--- a/gcc/testsuite/g++.dg/plugin/show-template-tree-color.C
+++ b/gcc/testsuite/g++.dg/plugin/show-template-tree-color.C
@@ -15,16 +15,16 @@ void test ()
{
fn_1 (vector<double> ());
/* { dg-begin-multiline-output "" }
-could not convert 'vector<double>()' from 'vector<double>' to 'vector<int>'
+could not convert 'vector<double>()' from 'vector<double>' to 'vector<int>'
vector<
- [double != int]>
+ [double != int]>
{ dg-end-multiline-output "" } */
fn_2 (map<int, double>());
/* { dg-begin-multiline-output "" }
-could not convert 'map<int, double>()' from 'map<[...],double>' to 'map<[...],int>'
+could not convert 'map<int, double>()' from 'map<[...],double>' to 'map<[...],int>'
map<
[...],
- [double != int]>
+ [double != int]>
{ dg-end-multiline-output "" } */
}
diff --git a/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-1.C b/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-1.C
new file mode 100644
index 0000000..dd41b08
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-1.C
@@ -0,0 +1,200 @@
+// Test of -Wformat for GCC-specific formats
+// Copy of gcc.dg/format/gcc_diag-10.c, with class pp_element added.
+// { dg-do compile }
+// { dg-options "-Wformat" }
+
+/* Magic identifiers must be set before the attribute is used. */
+
+typedef long long __gcc_host_wide_int__;
+
+typedef struct location_s
+{
+ const char *file;
+ int line;
+} location_t;
+
+union tree_node;
+typedef union tree_node *tree;
+
+/* Define gimple as a dummy type. The typedef must be provided for
+ the C test to find the symbol. */
+typedef struct gimple gimple;
+
+/* Likewise for gimple. */
+typedef struct cgraph_node cgraph_node;
+
+/* Likewise for diagnostic_event_id_t. */
+typedef struct diagnostic_event_id_t diagnostic_event_id_t;
+
+namespace pp_markup { class element; }
+typedef pp_markup::element pp_element;
+
+#define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2)))
+
+void diag (const char*, ...) FORMAT (diag);
+void cdiag (const char*, ...) FORMAT (cdiag);
+void tdiag (const char*, ...) FORMAT (tdiag);
+void cxxdiag (const char*, ...) FORMAT (cxxdiag);
+void dump (const char*, ...) FORMAT (dump_printf);
+
+void test_diag (tree t, gimple *gc, diagnostic_event_id_t *event_id_ptr,
+ pp_element *elem)
+{
+ diag ("%<"); /* { dg-warning "unterminated quoting directive" } */
+ diag ("%>"); /* { dg-warning "unmatched quoting directive " } */
+ diag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
+
+ diag ("%G", gc); /* { dg-warning "format" } */
+ diag ("%K", t); /* { dg-warning "format" } */
+ diag ("%@", event_id_ptr);
+
+ diag ("%R"); /* { dg-warning "unmatched color reset directive" } */
+ diag ("%r", ""); /* { dg-warning "unterminated color directive" } */
+ diag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
+ diag ("%r%R", "");
+ diag ("%r%r%R", "", "");
+ diag ("%r%R%r%R", "", "");
+
+ diag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
+ diag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
+ diag ("%<%r%R%>", "");
+
+ diag ("%e", elem);
+ diag ("%e", 42); /* { dg-warning "format" } */
+}
+
+void test_cdiag (tree t, gimple *gc)
+{
+ cdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
+ cdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
+ cdiag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
+
+ cdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
+ cdiag ("%E", t);
+ cdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */
+ cdiag ("%G", gc); /* { dg-warning "format" } */
+ cdiag ("%K", t); /* { dg-warning "format" } */
+
+ cdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
+ cdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
+ cdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
+ cdiag ("%r%R", "");
+ cdiag ("%r%r%R", "", "");
+ cdiag ("%r%R%r%R", "", "");
+
+ cdiag ("%T", t); /* { dg-warning ".T. conversion used unquoted" } */
+ cdiag ("%V", t); /* { dg-warning ".V. conversion used unquoted" } */
+
+ cdiag ("%<%D%>", t);
+ cdiag ("%<%E%>", t);
+ cdiag ("%<%F%>", t);
+ cdiag ("%<%G%>", gc); /* { dg-warning "format" } */
+ cdiag ("%<%K%>", t); /* { dg-warning "format" } */
+
+ cdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
+ cdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
+ cdiag ("%<%r%R%>", "");
+
+ cdiag ("%<%T%>", t);
+ cdiag ("%<%V%>", t);
+
+ cdiag ("%<%qD%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
+ cdiag ("%<%qE%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
+ cdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
+}
+
+void test_tdiag (tree t, gimple *gc)
+{
+ tdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
+ tdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
+ tdiag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
+
+ tdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
+ tdiag ("%E", t);
+ tdiag ("%G", gc); /* { dg-warning "format" } */
+ tdiag ("%K", t); /* { dg-warning "format" } */
+
+ tdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
+ tdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
+ tdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
+ tdiag ("%r%R", "");
+ tdiag ("%r%R", "");
+ tdiag ("%r%r%R", "", "");
+ tdiag ("%r%R%r%R", "", "");
+
+ tdiag ("%T", t); /* { dg-warning ".T. conversion used unquoted" } */
+
+ tdiag ("%<%D%>", t);
+ tdiag ("%<%E%>", t);
+ tdiag ("%<%G%>", gc); /* { dg-warning "format" } */
+ tdiag ("%<%K%>", t); /* { dg-warning "format" } */
+
+ tdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
+ tdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
+ tdiag ("%<%r%R%>", "");
+
+ tdiag ("%<%T%>", t);
+
+ tdiag ("%<%qD%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
+ tdiag ("%<%qE%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
+ tdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
+}
+
+void test_cxxdiag (tree t, gimple *gc)
+{
+ cxxdiag ("%A", t); /* { dg-warning ".A. conversion used unquoted" } */
+ cxxdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
+ cxxdiag ("%E", t);
+ cxxdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */
+ cxxdiag ("%G", gc); /* { dg-warning "format" } */
+ cxxdiag ("%K", t); /* { dg-warning "format" } */
+
+ cxxdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
+ cxxdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
+ cxxdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
+ cxxdiag ("%r%R", "");
+ cxxdiag ("%r%R", "");
+ cxxdiag ("%r%r%R", "", "");
+ cxxdiag ("%r%R%r%R", "", "");
+
+ cxxdiag ("%S", t); /* { dg-warning ".S. conversion used unquoted" } */
+ cxxdiag ("%T", t); /* { dg-warning ".T. conversion used unquoted" } */
+ cxxdiag ("%V", t); /* { dg-warning ".V. conversion used unquoted" } */
+ cxxdiag ("%X", t); /* { dg-warning ".X. conversion used unquoted" } */
+
+ cxxdiag ("%<%A%>", t);
+ cxxdiag ("%<%D%>", t);
+ cxxdiag ("%<%E%>", t);
+ cxxdiag ("%<%F%>", t);
+ cxxdiag ("%<%R%>"); /* { dg-warning "unmatched color reset" } */
+ cxxdiag ("%<%r%R%>", "");
+ cxxdiag ("%<%S%>", t);
+ cxxdiag ("%<%T%>", t);
+ cxxdiag ("%<%V%>", t);
+ cxxdiag ("%<%X%>", t);
+}
+
+void test_dump (tree t, gimple *stmt, cgraph_node *node)
+{
+ dump ("%<"); /* { dg-warning "unterminated quoting directive" } */
+ dump ("%>"); /* { dg-warning "unmatched quoting directive " } */
+ dump ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
+
+ dump ("%R"); /* { dg-warning "unmatched color reset directive" } */
+ dump ("%r", ""); /* { dg-warning "unterminated color directive" } */
+ dump ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
+ dump ("%r%R", "");
+ dump ("%r%r%R", "", "");
+ dump ("%r%R%r%R", "", "");
+
+ dump ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
+ dump ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
+ dump ("%<%r%R%>", "");
+
+ dump ("%E", stmt);
+ dump ("%T", t);
+ dump ("%G", stmt);
+ dump ("%C", node);
+ dump ("%f", 1.0);
+ dump ("%4.2f", 1.0); /* { dg-warning "format" } */
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-2.C b/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-2.C
new file mode 100644
index 0000000..0cce53c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-2.C
@@ -0,0 +1,52 @@
+// Test of -Wformat for subclasses of pp_element
+// { dg-do compile }
+// { dg-options "-Wformat" }
+
+/* Magic identifiers must be set before the attribute is used. */
+
+typedef long long __gcc_host_wide_int__;
+
+typedef struct location_s
+{
+ const char *file;
+ int line;
+} location_t;
+
+union tree_node;
+typedef union tree_node *tree;
+
+/* Define gimple as a dummy type. The typedef must be provided for
+ the C test to find the symbol. */
+typedef struct gimple gimple;
+
+/* Likewise for gimple. */
+typedef struct cgraph_node cgraph_node;
+
+/* Likewise for diagnostic_event_id_t. */
+typedef struct diagnostic_event_id_t diagnostic_event_id_t;
+
+namespace pp_markup {
+class element
+{
+};
+} // namespace pp_markup
+typedef pp_markup::element pp_element;
+
+#define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2)))
+
+void diag (const char*, ...) FORMAT (diag);
+
+class sub_element : public pp_element
+{
+};
+
+class sub_sub_element : public sub_element
+{
+};
+
+void test_diag ()
+{
+ sub_element e1;
+ sub_sub_element e2;
+ diag ("%e %e", &e1, &e2);
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-3.C b/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-3.C
new file mode 100644
index 0000000..f474778
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-3.C
@@ -0,0 +1,54 @@
+// Test of -Wformat for subclasses of pp_element
+// { dg-do compile }
+// { dg-options "-Wformat" }
+
+union tree_node;
+typedef union tree_node *tree;
+class rich_location;
+class pretty_printer;
+
+namespace pp_markup {
+class element {};
+
+} // namespace pp_markup
+
+typedef pp_markup::element pp_element;
+
+extern void error_at (rich_location *, const char *, ...)
+ __attribute__ ((__format__ (__gcc_cdiag__, 2, 3),
+ __nonnull__ (2)));
+
+namespace highlight_colors {
+
+extern const char *const lhs;
+extern const char *const rhs;
+
+} // namespace highlight_colors
+
+namespace pp_markup {
+
+class element_quoted_type : public element
+{
+public:
+ element_quoted_type (tree type, const char *highlight_color)
+ : m_type (type),
+ m_highlight_color (highlight_color)
+ {
+ }
+private:
+ tree m_type;
+ const char *m_highlight_color;
+};
+
+}
+
+void
+binary_op_error (rich_location *richloc, const char *opname,
+ tree type0, tree type1)
+{
+ pp_markup::element_quoted_type element_0 (type0, highlight_colors::lhs);
+ pp_markup::element_quoted_type element_1 (type1, highlight_colors::rhs);
+ error_at (richloc,
+ "invalid operands to binary %s (have %e and %e)",
+ opname, &element_0, &element_1);
+}
diff --git a/gcc/testsuite/gcc.dg/bad-binary-ops-highlight-colors.c b/gcc/testsuite/gcc.dg/bad-binary-ops-highlight-colors.c
new file mode 100644
index 0000000..efbcdf3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bad-binary-ops-highlight-colors.c
@@ -0,0 +1,35 @@
+/* Verify that colorization affects both text within diagnostic messages
+ and underlined ranges of quoted source, and that the types we use
+ match up between them.
+ Also implicitly verify that -fdiagnostics-show-highlight-colors is
+ on by default. */
+
+/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-color=always" } */
+
+struct s {};
+struct t {};
+typedef struct s S;
+typedef struct t T;
+
+extern S callee_4a (void);
+extern T callee_4b (void);
+
+int test_4 (void)
+{
+ return callee_4a () + callee_4b ();
+
+ /* { dg-begin-multiline-output "" }
+  error: invalid operands to binary + (have 'S' {aka 'struct s'} and 'T' {aka 'struct t'})
+ { dg-end-multiline-output "" } */
+
+ /* { dg-begin-multiline-output "" }
+ return callee_4a () + callee_4b ();
+ ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
+ | |
+ | T {aka struct t}
+ S {aka struct s}
+ { dg-end-multiline-output "" } */
+
+ /* { dg-prune-output "In function" } */
+ /* { dg-prune-output "bad-binary-ops-highlight-colors.c" } */
+}
diff --git a/gcc/testsuite/gcc.dg/bad-binary-ops-no-highlight-colors.c b/gcc/testsuite/gcc.dg/bad-binary-ops-no-highlight-colors.c
new file mode 100644
index 0000000..9eb22cb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bad-binary-ops-no-highlight-colors.c
@@ -0,0 +1,30 @@
+/* Verify that -fno-diagnostics-show-highlight-colors works. */
+/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-color=always -fno-diagnostics-show-highlight-colors" } */
+
+struct s {};
+struct t {};
+typedef struct s S;
+typedef struct t T;
+
+extern S callee_4a (void);
+extern T callee_4b (void);
+
+int test_4 (void)
+{
+ return callee_4a () + callee_4b ();
+
+ /* { dg-begin-multiline-output "" }
+  error: invalid operands to binary + (have 'S' {aka 'struct s'} and 'T' {aka 'struct t'})
+ { dg-end-multiline-output "" } */
+
+ /* { dg-begin-multiline-output "" }
+ return callee_4a () + callee_4b ();
+ ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
+ | |
+ | T {aka struct t}
+ S {aka struct s}
+ { dg-end-multiline-output "" } */
+
+ /* { dg-prune-output "In function" } */
+ /* { dg-prune-output "bad-binary-ops-no-highlight-colors.c" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/colors.c b/gcc/testsuite/gcc.dg/format/colors.c
new file mode 100644
index 0000000..43484b7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/format/colors.c
@@ -0,0 +1,27 @@
+/* Verify that colorization affects both text within diagnostic messages
+ and underlined ranges of quoted source, and that the types we use
+ match up between them. */
+
+/* { dg-do compile } */
+/* { dg-options "-Wformat -fdiagnostics-show-caret -fdiagnostics-color=always" } */
+
+#include "format.h"
+
+void test_mismatching_types (const char *msg)
+{
+ printf("hello %i", msg);
+
+/* { dg-begin-multiline-output "" }
+warning: format '%i' expects argument of type 'int', but argument 2 has type 'const char *' [-Wformat=]
+ { dg-end-multiline-output "" } */
+/* { dg-begin-multiline-output "" }
+ printf("hello %i", msg);
+ ~^ ~~~
+ | |
+ int const char *
+ %s
+ { dg-end-multiline-output "" } */
+}
+
+/* { dg-prune-output "In function" } */
+/* { dg-prune-output "colors.c" } */
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
index f5c6fc5..44b94da 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
@@ -41,7 +41,7 @@ show_tree (tree node)
return;
gcc_rich_location richloc (EXPR_LOCATION (node));
- richloc.add_expr (node, NULL);
+ richloc.add_expr (node, nullptr, nullptr);
if (richloc.get_num_locations () < 2)
{