]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Correct "-MJ" bail out, identify both "-MJ file" and "-MJfile" (#487)
authorThomas Otto <thomas.otto@pdv-fs.de>
Sun, 10 Nov 2019 20:36:29 +0000 (21:36 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 10 Nov 2019 20:36:29 +0000 (21:36 +0100)
Also added test to detect the invalid case TOO_HARD | TAKES_CONCAT_ARG.

src/ccache.cpp
src/compopt.cpp
unittest/test_compopt.cpp

index cee69139c37b02e0c39e9bc3e4add0413e2e0a31..f46e4239b653a432fca4a31db6ede0582d54fe6e 100644 (file)
@@ -2505,7 +2505,8 @@ cc_process_args(struct args* args,
     }
 
     // These are always too hard.
-    if (compopt_too_hard(argv[i]) || str_startswith(argv[i], "-fdump-")) {
+    if (compopt_too_hard(argv[i]) || str_startswith(argv[i], "-fdump-")
+        || str_startswith(argv[i], "-MJ")) {
       cc_log("Compiler option %s is unsupported", argv[i]);
       stats_update(STATS_UNSUPPORTED_OPTION);
       result = false;
index 933671126cc88394a7c27282ca4aa3119b4f37ad..ecc24da3406d9ed824a25b60e638deef00eef6aa 100644 (file)
@@ -184,13 +184,24 @@ compopt_short(bool (*fn)(const char*), const char* option)
 }
 
 // Used by unittest/test_compopt.c.
-bool compopt_verify_sortedness(void);
+bool compopt_verify_sortedness_and_flags(void);
 
 // For test purposes.
 bool
-compopt_verify_sortedness(void)
+compopt_verify_sortedness_and_flags(void)
 {
-  for (size_t i = 1; i < ARRAY_SIZE(compopts); i++) {
+  for (size_t i = 0; i < ARRAY_SIZE(compopts); i++) {
+    if (compopts[i].type & TOO_HARD && compopts[i].type & TAKES_CONCAT_ARG) {
+      fprintf(stderr,
+              "type (TOO_HARD | TAKES_CONCAT_ARG) not allowed, used by %s\n",
+              compopts[i].name);
+      return false;
+    }
+
+    if (i == 0) {
+      continue;
+    }
+
     if (strcmp(compopts[i - 1].name, compopts[i].name) >= 0) {
       fprintf(stderr,
               "compopt_verify_sortedness: %s >= %s\n",
index 99c3b2bd9a3d9428862e666e17b12191766afdfb..98a834ea3fc1b88f18e9b39bdbcc12ff701321f2 100644 (file)
@@ -26,8 +26,8 @@ TEST_SUITE(compopt)
 
 TEST(option_table_should_be_sorted)
 {
-  bool compopt_verify_sortedness(void);
-  CHECK(compopt_verify_sortedness());
+  bool compopt_verify_sortedness_and_flags(void);
+  CHECK(compopt_verify_sortedness_and_flags());
 }
 
 TEST(dash_I_affects_cpp)