summaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2015-09-24 16:37:43 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2015-09-24 16:37:43 +0000
commit3563212292d643dee54ff75771032ea92fe34e78 (patch)
tree65b1cf01a9ae795a5ecb148e8eac6ed626108fc6 /gcc/opts-common.c
parent2af16a7c1e190f54a2d276a1088d39bcc9cbdce4 (diff)
fdiagnostics-color=never does not disable color for some diagnostics
Actually, I was trying to reject non-warning options as argument to -Werror=. However, the new test fails because -fdiagnostics-color=never is always placed by the driver after the warning options when calling the compiler proper. This patch prunes all -fdiagnostics-color from the command-line but the last one, which is moved to the first position. gcc/ChangeLog: 2015-09-24 Manuel López-Ibáñez <manu@gcc.gnu.org> PR driver/67640 * opts-common.c (prune_options): Discard all -fdiagnostics-color but the last one, which is moved to the front to be processed first. * opts.c (enable_warning_as_error): Reject options that do not control warnings. gcc/testsuite/ChangeLog: 2015-09-24 Manuel López-Ibáñez <manu@gcc.gnu.org> PR driver/67640 * gcc.dg/Werror-13.c: New test. From-SVN: r228094
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r--gcc/opts-common.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 3bcbaf18b22..d9bf4d4b897 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -825,6 +825,7 @@ prune_options (struct cl_decoded_option **decoded_options,
= XNEWVEC (struct cl_decoded_option, old_decoded_options_count);
unsigned int i;
const struct cl_option *option;
+ unsigned int fdiagnostics_color_idx = 0;
/* Remove arguments which are negated by others after them. */
new_decoded_options_count = 0;
@@ -844,6 +845,11 @@ prune_options (struct cl_decoded_option **decoded_options,
case OPT_SPECIAL_input_file:
goto keep;
+ /* Do not save OPT_fdiagnostics_color_, just remember the last one. */
+ case OPT_fdiagnostics_color_:
+ fdiagnostics_color_idx = i;
+ continue;
+
default:
gcc_assert (opt_idx < cl_options_count);
option = &cl_options[opt_idx];
@@ -879,6 +885,17 @@ keep:
}
}
+ if (fdiagnostics_color_idx > 1)
+ {
+ /* We put the last -fdiagnostics-color= at the first position
+ after argv[0] so it can take effect immediately. */
+ memmove (new_decoded_options + 2, new_decoded_options + 1,
+ sizeof (struct cl_decoded_option)
+ * (new_decoded_options_count - 1));
+ new_decoded_options[1] = old_decoded_options[fdiagnostics_color_idx];
+ new_decoded_options_count++;
+ }
+
free (old_decoded_options);
new_decoded_options = XRESIZEVEC (struct cl_decoded_option,
new_decoded_options,