From: Thomas Otto Date: Sun, 10 Nov 2019 20:36:29 +0000 (+0100) Subject: Correct "-MJ" bail out, identify both "-MJ file" and "-MJfile" (#487) X-Git-Tag: v4.0~712 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87fdad7aae3f003cd1ac0eb9500a3dc1aa05ed4a;p=thirdparty%2Fccache.git Correct "-MJ" bail out, identify both "-MJ file" and "-MJfile" (#487) Also added test to detect the invalid case TOO_HARD | TAKES_CONCAT_ARG. --- diff --git a/src/ccache.cpp b/src/ccache.cpp index cee69139c..f46e4239b 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -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; diff --git a/src/compopt.cpp b/src/compopt.cpp index 933671126..ecc24da34 100644 --- a/src/compopt.cpp +++ b/src/compopt.cpp @@ -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", diff --git a/unittest/test_compopt.cpp b/unittest/test_compopt.cpp index 99c3b2bd9..98a834ea3 100644 --- a/unittest/test_compopt.cpp +++ b/unittest/test_compopt.cpp @@ -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)