return Statistic::unsupported_compiler_option;
}
+ // In the "-Xclang -fcolor-diagnostics" form, -Xclang is skipped and the
+ // -fcolor-diagnostics argument which is passed to cc1 is handled below.
+ if (args[i] == "-Xclang" && i < args.size() - 1
+ && args[i + 1] == "-fcolor-diagnostics") {
+ state.compiler_only_args_no_hash.push_back(args[i]);
+ ++i;
+ }
+
if (args[i] == "-fcolor-diagnostics" || args[i] == "-fdiagnostics-color"
|| args[i] == "-fdiagnostics-color=always") {
state.color_diagnostics = ColorDiagnostics::always;
fi
fi
+ if $COMPILER_TYPE_CLANG; then
+ # ---------------------------------------------------------------------
+ TEST "-fcolor-diagnostics works when passed to cc1 with -Xclang"
+
+ color_diagnostics_generate_code test1.c
+ $CCACHE_COMPILE -Xclang -fcolor-diagnostics -Wreturn-type -c -o test1.o test1.c 2>test1.stderr
+ color_diagnostics_expect_color test1.stderr
+ fi
+
while read -r case; do
# ---------------------------------------------------------------------
TEST "Cache object shared across ${case} (run_second_cpp=$run_second_cpp)"
"-Xclang -fno-pch-timestamp"
" -Xclang unsupported";
+ const std::string color_diag = "-Xclang -fcolor-diagnostics";
+
const std::string extra_args =
"-Xclang -emit-pch"
" -Xclang -emit-pth";
" -Xclang -include-pth pth_path1"
" -Xclang -include-pth -Xclang pth_path2";
- ctx.orig_args = Args::from_string("gcc -c foo.c " + common_args + " "
- + extra_args + " " + pch_pth_variants);
+ ctx.orig_args =
+ Args::from_string("gcc -c foo.c " + common_args + " " + color_diag + " "
+ + extra_args + " " + pch_pth_variants);
Util::write_file("foo.c", "");
const ProcessArgsResult result = process_args(ctx);
== "gcc " + common_args + " " + pch_pth_variants);
CHECK(result.extra_args_to_hash.to_string() == extra_args);
CHECK(result.compiler_args.to_string()
- == "gcc " + common_args + " " + extra_args + " " + pch_pth_variants
- + " -c");
+ == "gcc " + common_args + " " + color_diag + " " + extra_args + " "
+ + pch_pth_variants + " -c");
}
TEST_CASE("-x")