Makefile.in (toplev.o): Depend on diagnostic-color.h.
authorJakub Jelinek <jakub@redhat.com>
Fri, 26 Apr 2013 06:55:56 +0000 (08:55 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 26 Apr 2013 06:55:56 +0000 (08:55 +0200)
* 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

gcc/ChangeLog
gcc/Makefile.in
gcc/common.opt
gcc/diagnostic-color.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/lib/c-compat.exp
gcc/testsuite/lib/prune.exp
gcc/toplev.c

index 18a0ac0..749d283 100644 (file)
@@ -1,5 +1,16 @@
 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.
index adb7d0c..f6fe9aa 100644 (file)
@@ -2716,7 +2716,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
    $(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)
 
index 8be32e5..350bf97 100644 (file)
@@ -1033,7 +1033,7 @@ Common Alias(fdiagnostics-color=,always,never)
 ;
 
 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.
index 8680b50..a1c508a 100644 (file)
@@ -264,14 +264,8 @@ parse_gcc_colors (void)
 }
 
 #if defined(_WIN32)
-static bool
-should_colorize (void)
-{
-  return false;
-}
-
 bool
-colorize_init (void)
+colorize_init (diagnostic_color_rule_t)
 {
   return false;
 }
index 86c6945..6eb5c60 100644 (file)
@@ -2964,9 +2964,10 @@ a message which is too long to fit on a single line.
 @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.
 
index 9cc5ce1..5e568fb 100644 (file)
@@ -1,3 +1,10 @@
+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
index 58eaf4d..b42545d 100644 (file)
@@ -34,7 +34,7 @@ load_lib target-supports.exp
 # 
 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
@@ -44,6 +44,9 @@ proc compat-use-alt-compiler { } {
        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
+       }
     }
 }
 
@@ -70,9 +73,11 @@ proc compat_setup_dfp { } {
     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
@@ -88,6 +93,10 @@ proc compat_setup_dfp { } {
                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
     }
 
index c110fc6..7890608 100644 (file)
@@ -19,7 +19,7 @@
 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"
index b85917d..d41283d 100644 (file)
@@ -74,6 +74,7 @@ along with GCC; see the file COPYING3.  If not see
 #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"
@@ -1209,6 +1210,13 @@ process_options (void)
 
   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)