diff --git a/src/kernel_services/ast_queries/file.ml b/src/kernel_services/ast_queries/file.ml index 8021b38c897f4a58823353ebb5f6d325c89602cb..b26c3d0487045d078e9aaab35946321d12bdba7c 100644 --- a/src/kernel_services/ast_queries/file.ml +++ b/src/kernel_services/ast_queries/file.ml @@ -520,9 +520,16 @@ let build_cpp_cmd = function else [] in let fc_define_args = ["__FRAMAC__"] in + let exe = cpp_name cmdl in let clang_no_warn = - if cpp_name cmdl = "clang" then - ["-Wno-builtin-macro-redefined"] + if exe = "clang" || exe = "gcc" then + (* NB: For gcc only old versions (still found in Ubuntu 18.04, + supported until 2028, though) activate builtin-macro-redefined. + This is also the case for newer clangs, while older ones will + complain about the unknown warning (gcc does not seem to care, + so that it is safe to keep the unknown-warning-option in every + case. *) + ["-Wno-builtin-macro-redefined"; "-Wno-unknown-warning-option"] else [] in diff --git a/tests/syntax/oracle/cpp-command.4.res.oracle b/tests/syntax/oracle/cpp-command.4.res.oracle index e42375af42082ed6fd520737d8a4bde16a1b9289..8a7eb85e889dcb788b90ebf762e3df7deaf6cfad 100644 --- a/tests/syntax/oracle/cpp-command.4.res.oracle +++ b/tests/syntax/oracle/cpp-command.4.res.oracle @@ -1,2 +1,2 @@ [kernel] Preprocessing command: - gcc -E -C -I. -ITMP_MACHDEP -IFRAMAC_SHARE/libc -D__FRAMAC__ -dD -nostdinc 'cpp-command.c' -o 'TMPDIR/FILE.i' + gcc -E -C -I. -ITMP_MACHDEP -IFRAMAC_SHARE/libc -D__FRAMAC__ -dD -nostdinc -Wno-builtin-macro-redefined -Wno-unknown-warning-option 'cpp-command.c' -o 'TMPDIR/FILE.i'