From c1212a39e0a00f2e41d266949f1b28de087ad6ff Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 5 Feb 2009 02:43:38 +0000 Subject: [PATCH] ccc: Translate -O to -O1 for clang, and only pass last -O option. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63816 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/ccc/ccclib/Tools.py | 9 ++++++++- tools/ccc/test/ccc/O.c | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tools/ccc/test/ccc/O.c diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py index 13d4a54d85..4b600af448 100644 --- a/tools/ccc/ccclib/Tools.py +++ b/tools/ccc/ccclib/Tools.py @@ -307,7 +307,14 @@ class Clang_CompileTool(Tool): arglist.addAllArgs(cmd_args, arglist.parser.fblocksGroup) - arglist.addAllArgs(cmd_args, arglist.parser.OOption) + # Manually translate -O to -O1; let clang reject others. + arg = arglist.getLastArg(arglist.parser.OOption) + if arg: + if arglist.getValue(arg) == '': + cmd_args.append('-O1') + else: + cmd_args.extend(arglist.render(arg)) + arglist.addAllArgs2(cmd_args, arglist.parser.ClangWGroup, arglist.parser.pedanticGroup) arglist.addLastArg(cmd_args, arglist.parser.wOption) arglist.addAllArgs3(cmd_args, arglist.parser.stdOption, arglist.parser.ansiOption, arglist.parser.trigraphsOption) diff --git a/tools/ccc/test/ccc/O.c b/tools/ccc/test/ccc/O.c new file mode 100644 index 0000000000..7ef0aba61d --- /dev/null +++ b/tools/ccc/test/ccc/O.c @@ -0,0 +1,4 @@ +// Just check that clang accepts these. + +// RUN: xcc -fsyntax-only -O1 -O2 %s && +// RUN: xcc -fsyntax-only -O %s -- 2.50.1