* Makefile.in (toplev.o): Depend on diagnostic-color.h.
* diagnostic-color.c (should_colorize): Remove _WIN32 version.
(colorize_init): Add argument to _WIN32 version.
* toplev.c: Include diagnostic-color.h.
(process_options): Default to -fdiagnostics-color=auto if
GCC_COLORS env var is in the environment.
* common.opt (fdiagnostics-color=): Add Var and Init.
* doc/invoke.texi (-fdiagnostics-color=): Document that if
GCC_COLORS env var is in the environment, the default is auto
rather than never.
* lib/prune.exp: Add -fdiagnostics-color=never to TEST_ALWAYS_FLAGS.
* lib/c-compat.exp (compat-use-alt-compiler, compat_setup_dfp): Handle
-fdiagnostics-color=never option similarly to
-fno-diagnostics-show-caret option.
From-SVN: r198332
2013-04-26 Jakub Jelinek <jakub@redhat.com>
+ * Makefile.in (toplev.o): Depend on diagnostic-color.h.
+ * diagnostic-color.c (should_colorize): Remove _WIN32 version.
+ (colorize_init): Add argument to _WIN32 version.
+ * toplev.c: Include diagnostic-color.h.
+ (process_options): Default to -fdiagnostics-color=auto if
+ GCC_COLORS env var is in the environment.
+ * common.opt (fdiagnostics-color=): Add Var and Init.
+ * doc/invoke.texi (-fdiagnostics-color=): Document that if
+ GCC_COLORS env var is in the environment, the default is auto
+ rather than never.
+
* diagnostic.h (file_name_as_prefix): Add context argument.
* diagnostic.c (file_name_as_prefix): Likewise. Colorize
the string as locus.
$(OPTS_H) params.def tree-mudflap.h $(TREE_PASS_H) $(GIMPLE_H) \
tree-ssa-alias.h $(PLUGIN_H) realmpfr.h tree-diagnostic.h \
$(TREE_PRETTY_PRINT_H) opts-diagnostic.h $(COMMON_TARGET_H) \
- tsan.h
+ tsan.h diagnostic-color.h
hwint.o : hwint.c $(CONFIG_H) $(SYSTEM_H) $(DIAGNOSTIC_CORE_H)
;
fdiagnostics-color=
-Common Joined RejectNegative Enum(diagnostic_color_rule)
+Common Joined RejectNegative Var(flag_diagnostics_show_color) Enum(diagnostic_color_rule) Init(DIAGNOSTICS_COLOR_NO)
-fdiagnostics-color=[never|always|auto] Colorize diagnostics
; Required for these enum values.
}
#if defined(_WIN32)
-static bool
-should_colorize (void)
-{
- return false;
-}
-
bool
-colorize_init (void)
+colorize_init (diagnostic_color_rule_t)
{
return false;
}
@cindex highlight, color, colour
@vindex GCC_COLORS @r{environment variable}
Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
-or @samp{auto}. The default is @samp{never}, @samp{auto} means to use color
-only when the standard error is a terminal. The forms
-@option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
+or @samp{auto}. The default is @samp{never} if @env{GCC_COLORS} environment
+variable isn't present in the environment, and @samp{auto} otherwise.
+@samp{auto} means to use color only when the standard error is a terminal.
+The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
aliases for @option{-fdiagnostics-color=always} and
@option{-fdiagnostics-color=never}, respectively.
+2013-04-26 Jakub Jelinek <jakub@redhat.com>
+
+ * lib/prune.exp: Add -fdiagnostics-color=never to TEST_ALWAYS_FLAGS.
+ * lib/c-compat.exp (compat-use-alt-compiler, compat_setup_dfp): Handle
+ -fdiagnostics-color=never option similarly to
+ -fno-diagnostics-show-caret option.
+
2013-04-25 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/57003
#
proc compat-use-alt-compiler { } {
global GCC_UNDER_TEST ALT_CC_UNDER_TEST
- global compat_same_alt compat_alt_caret
+ global compat_same_alt compat_alt_caret compat_alt_color
global TEST_ALWAYS_FLAGS
# We don't need to do this if the alternate compiler is actually
if { $compat_alt_caret == 0 } then {
regsub -- "-fno-diagnostics-show-caret" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
}
+ if { $compat_alt_color == 0 } then {
+ regsub -- "-fdiagnostics-color=never" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
+ }
}
}
global compat_same_alt
global compat_have_dfp
global compat_alt_caret
+ global compat_alt_color
global TEST_ALWAYS_FLAGS compat_save_TEST_ALWAYS_FLAGS
set compat_alt_caret 0
+ set compat_alt_color 0
set compat_save_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
verbose "compat_setup_dfp: $compat_use_alt $compat_same_alt" 2
int dummy; } "-fno-diagnostics-show-caret"] != 0 } {
set compat_alt_caret 1
}
+ if { [check_no_compiler_messages_nocache compat_alt_has_color object {
+ int dummy; } "-fdiagnostics-color=never"] != 0 } {
+ set compat_alt_color 1
+ }
compat-use-tst-compiler
}
if ![info exists TEST_ALWAYS_FLAGS] {
set TEST_ALWAYS_FLAGS ""
}
-set TEST_ALWAYS_FLAGS "-fno-diagnostics-show-caret $TEST_ALWAYS_FLAGS"
+set TEST_ALWAYS_FLAGS "-fno-diagnostics-show-caret -fdiagnostics-color=never $TEST_ALWAYS_FLAGS"
proc prune_gcc_output { text } {
#send_user "Before:$text\n"
#include "gimple.h"
#include "tree-ssa-alias.h"
#include "plugin.h"
+#include "diagnostic-color.h"
#if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
#include "dbxout.h"
maximum_field_alignment = initial_max_fld_align * BITS_PER_UNIT;
+ /* Default to -fdiagnostics-color=auto if GCC_COLORS is in the environment,
+ otherwise default to -fdiagnostics-color=never. */
+ if (!global_options_set.x_flag_diagnostics_show_color
+ && getenv ("GCC_COLORS"))
+ pp_show_color (global_dc->printer)
+ = colorize_init (DIAGNOSTICS_COLOR_AUTO);
+
/* Allow the front end to perform consistency checks and do further
initialization based on the command line options. This hook also
sets the original filename if appropriate (e.g. foo.i -> foo.c)