aboutsummaryrefslogtreecommitdiff
path: root/gcc/diagnostic.c
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2014-12-04 23:09:41 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2014-12-04 23:09:41 +0000
commit97aa8bb6e20579f382357ffaa8f7233133fc1e7c (patch)
tree4ed8367e62b4ba4d6028e2ffb5d23560f80d3d52 /gcc/diagnostic.c
parent87aca3a6aed5f33bc3ead975e96ed8db80c45cd6 (diff)
downloadgcc-97aa8bb6e20579f382357ffaa8f7233133fc1e7c.zip
gcc-97aa8bb6e20579f382357ffaa8f7233133fc1e7c.tar.gz
gcc-97aa8bb6e20579f382357ffaa8f7233133fc1e7c.tar.bz2
diagnostic.c (diagnostic_color_init): New.
gcc/ChangeLog: 2014-12-04 Manuel López-Ibáñez <manu@gcc.gnu.org> * diagnostic.c (diagnostic_color_init): New. * diagnostic.h: Declare. * gcc.c (driver::global_initializations): Use it. (driver_handle_option): Handle -fdiagnostics-color_. * toplev.c: Do not include diagnostic-color.h. (process_options): Do not initialize color diagnostics here. * common.opt (fdiagnostics-color=): Add Driver. * opts-global.c (init_options_once): Initialize color here. * opts.c (common_handle_option): Use diagnostics_color_init. * diagnostic-color.h: Fix comment. From-SVN: r218406
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r--gcc/diagnostic.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 0c8fbe5..07ce602 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -155,6 +155,34 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
context->inhibit_notes_p = false;
}
+/* Maybe initialize the color support. We require clients to do this
+ explicitly, since most clients don't want color. When called
+ without a VALUE, it initializes with DIAGNOSTICS_COLOR_DEFAULT. */
+
+void
+diagnostic_color_init (diagnostic_context *context, int value /*= -1 */)
+{
+ /* value == -1 is the default value. */
+ if (value < 0)
+ {
+ /* If DIAGNOSTICS_COLOR_DEFAULT is -1, default to
+ -fdiagnostics-color=auto if GCC_COLORS is in the environment,
+ otherwise default to -fdiagnostics-color=never, for other
+ values default to that
+ -fdiagnostics-color={never,auto,always}. */
+ if (DIAGNOSTICS_COLOR_DEFAULT == -1)
+ {
+ if (!getenv ("GCC_COLORS"))
+ return;
+ value = DIAGNOSTICS_COLOR_AUTO;
+ }
+ else
+ value = DIAGNOSTICS_COLOR_DEFAULT;
+ }
+ pp_show_color (context->printer)
+ = colorize_init ((diagnostic_color_rule_t) value);
+}
+
/* Do any cleaning up required after the last diagnostic is emitted. */
void