This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

enable fdiagnostics-show-option by default


This patch enables the option -fdiagnostics-show-option by default:

This changes the output from this:

Wconversion-integer.c:52:3: warning: negative integer implicitly
converted to unsigned type

to this:

Wconversion-integer.c:52:3: warning: negative integer implicitly
converted to unsigned type [-Wsign-conversion]

which is much nicer and helpful!

Of course, -fno-diagnostics-show-option disables this.

Since any current parsers of gcc output have to expect anything after
the warning/error marker, then this is quite safe. In fact, only one
testcase needed to be modified.

BTW, when testing a warning, if you are not interested in the text,
you can just match the Woption in the message.

Bootstrapped and regression tested.

OK for trunk?

2010-04-15  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* toplev.c (general_init): Set default for
	fdiagnostics-show-option.
	* opts.c (common_handle_option): Allow disabling it.
	* common.opt (fdiagnostics-show-option): Add Var. Enabled by
	default.
testsuite/	
	* gcc.dg/Wconversion-integer.c: Update.
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c	(revision 158350)
+++ gcc/toplev.c	(working copy)
@@ -1692,10 +1692,11 @@ general_init (const char *argv0)
      can give warnings and errors.  */
   diagnostic_initialize (global_dc);
   /* Set a default printer.  Language specific initializations will
      override it later.  */
   pp_format_decoder (global_dc->printer) = &default_tree_printer;
+  global_dc->show_option_requested = flag_diagnostics_show_option;
 
   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
 #ifdef SIGSEGV
   signal (SIGSEGV, crash_signal);
 #endif
Index: gcc/testsuite/gcc.dg/Wconversion-integer.c
===================================================================
--- gcc/testsuite/gcc.dg/Wconversion-integer.c	(revision 158350)
+++ gcc/testsuite/gcc.dg/Wconversion-integer.c	(working copy)
@@ -38,13 +38,13 @@ void h (int x)
   fsi ('A');
   si = 'A';
   fuc ('A');
   uc = 'A';
 
-  uc = x ? 1U : -1; /* { dg-warning "conversion" } */
+  uc = x ? 1U : -1; /* { dg-warning " conversion" } */
   /* { dg-warning "negative integer implicitly converted to unsigned type" "" { target *-*-* } 43 } */
-  uc = x ? SCHAR_MIN : 1U; /* { dg-warning "conversion" } */
+  uc = x ? SCHAR_MIN : 1U; /* { dg-warning " conversion" } */
   /* { dg-warning "negative integer implicitly converted to unsigned type" "" { target *-*-* } 45 } */
   uc = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
   uc = x ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
   ui = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
   ui = x ? INT_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 158350)
+++ gcc/opts.c	(working copy)
@@ -1755,11 +1755,11 @@ common_handle_option (size_t scode, cons
       else
 	return 0;
       break;
 
     case OPT_fdiagnostics_show_option:
-      global_dc->show_option_requested = true;
+      global_dc->show_option_requested = value;
       break;
 
     case OPT_fdump_:
       if (!dump_switch_p (arg))
 	return 0;
Index: gcc/common.opt
===================================================================
--- gcc/common.opt	(revision 158350)
+++ gcc/common.opt	(working copy)
@@ -463,11 +463,11 @@ Delete useless null pointer checks
 fdiagnostics-show-location=
 Common Joined RejectNegative
 -fdiagnostics-show-location=[once|every-line]	How often to emit source location at the beginning of line-wrapped diagnostics
 
 fdiagnostics-show-option
-Common
+Common Var(flag_diagnostics_show_option) Init(1)
 Amend appropriate diagnostic messages with the command line option that controls them
 
 fdump-
 Common Joined RejectNegative
 -fdump-<type>	Dump various compiler internals to a file

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]