]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Detect PCH for concatenated -include option
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 24 Aug 2022 17:41:07 +0000 (19:41 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 24 Aug 2022 18:27:03 +0000 (20:27 +0200)
Fixes #1143.

src/argprocessing.cpp
test/suites/pch.bash

index daf3b5ff023e4595d9999357edc4077547093f66..ca8d379d4004d64698c2548302eb080519dd1bef 100644 (file)
@@ -962,8 +962,10 @@ process_option_arg(const Context& ctx,
   }
 
   // Detect PCH for options with concatenated path (relative or absolute).
-  if (util::starts_with(args[i], "-Fp") || util::starts_with(args[i], "-Yu")) {
-    const size_t path_pos = 3;
+  if (util::starts_with(args[i], "-include")
+      || util::starts_with(args[i], "-Fp")
+      || util::starts_with(args[i], "-Yu")) {
+    const size_t path_pos = util::starts_with(args[i], "-include") ? 8 : 3;
     if (!detect_pch(args[i].substr(0, path_pos),
                     args[i].substr(path_pos),
                     args_info.included_pch_file,
index ec5fc08ad62037b28a16c5730ffd59d7e513d03d..12968b4101fb5859a7925cd37d4f450d3b3c4a31 100644 (file)
@@ -134,17 +134,23 @@ pch_suite_common() {
     expect_stat preprocessor_error 1
 
     # -------------------------------------------------------------------------
-    TEST "Use .gch, -include, no sloppiness"
-
-    $COMPILER $SYSROOT -c pch.h
-    backdate pch.h.gch
-
-    $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c
-    expect_stat direct_cache_hit 0
-    expect_stat preprocessed_cache_hit 0
-    expect_stat cache_miss 0
-    # Must enable sloppy time macros:
-    expect_stat could_not_use_precompiled_header 1
+    include_pch_variants=(
+        "-include pch.h"
+        "-includepch.h"
+    )
+    for args in "${include_pch_variants[@]}"; do
+        TEST "Use .gch, $args, no sloppiness"
+
+        $COMPILER $SYSROOT -c pch.h
+        backdate pch.h.gch
+
+        $CCACHE_COMPILE $SYSROOT -c $args pch2.c
+        expect_stat direct_cache_hit 0
+        expect_stat preprocessed_cache_hit 0
+        expect_stat cache_miss 0
+        # Must enable sloppy time macros:
+        expect_stat could_not_use_precompiled_header 1
+    done
 
     # -------------------------------------------------------------------------
     TEST "Use .gch, -include"