From efefb0127e52956eec61d48269ad8f5214f3e9c9 Mon Sep 17 00:00:00 2001 From: Virgile Prevosto <virgile.prevosto@m4x.org> Date: Fri, 2 Jun 2023 14:23:42 +0200 Subject: [PATCH] [cpp] also silence warnings on older gccs and clangs. --- src/kernel_services/ast_queries/file.ml | 11 +++++++++-- tests/syntax/oracle/cpp-command.4.res.oracle | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/kernel_services/ast_queries/file.ml b/src/kernel_services/ast_queries/file.ml index 8021b38c897..b26c3d04870 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 e42375af420..8a7eb85e889 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' -- GitLab