return nullopt;
}
+ if (config.compiler_type() != CompilerType::clang
+ && (args[i] == "-fcolor-diagnostics"
+ || args[i] == "-fno-color-diagnostics")) {
+ // Special case: If a non-Clang compiler gets -f(no-)color-diagnostics we'll
+ // bail out and just execute the compiler. The reason is that we don't
+ // include -f(no-)color-diagnostics in the hash so there can be a false
+ // cache hit in the following scenario:
+ //
+ // 1. ccache gcc -c example.c # adds a cache entry
+ // 2. ccache gcc -c example.c -fcolor-diagnostics # unexpectedly succeeds
+ return Statistic::unsupported_compiler_option;
+ }
+
if (args[i] == "-fcolor-diagnostics" || args[i] == "-fdiagnostics-color"
|| args[i] == "-fdiagnostics-color=always") {
state.color_diagnostics = ColorDiagnostics::always;
expect_stat 'cache miss' 1
expect_stat 'cache hit (preprocessed)' 1
- # -------------------------------------------------------------------------
if $COMPILER_TYPE_GCC; then
+ # ---------------------------------------------------------------------
TEST "-fcolor-diagnostics not accepted for GCC"
generate_code 1 test.c
+
+ if $CCACHE_COMPILE -fcolor-diagnostics -c test.c >&/dev/null; then
+ test_failed "-fcolor-diagnostics unexpectedly accepted by GCC"
+ fi
+
+ # ---------------------------------------------------------------------
+ TEST "-fcolor-diagnostics not accepted for GCC for cached result"
+
+ generate_code 1 test.c
+
+ if ! $CCACHE_COMPILE -c test.c >&/dev/null; then
+ test_failed "unknown error compiling"
+ fi
+
if $CCACHE_COMPILE -fcolor-diagnostics -c test.c >&/dev/null; then
test_failed "-fcolor-diagnostics unexpectedly accepted by GCC"
fi
fi
while read -r case; do
+ # ---------------------------------------------------------------------
TEST "Cache object shared across ${case} (run_second_cpp=$run_second_cpp)"
color_diagnostics_generate_code test1.c