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