Driver: Fix forwarding of -fpascal-strings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68570 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index a3cea95..f44be0a 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -410,27 +410,24 @@
CmdArgs.push_back("-fblocks=0");
}
- // -fno-pascal-strings is default, only pass non-default.
+ // -fno-pascal-strings is default, only pass non-default. If the
+ // -tool chain happened to translate to -mpascal-strings, we want to
+ // -back translate here.
+ //
+ // FIXME: This is gross; that translation should be pulled from the
+ // tool chain.
if (Args.hasFlag(options::OPT_fpascal_strings,
- options::OPT_fno_pascal_strings))
+ options::OPT_fno_pascal_strings,
+ false) ||
+ Args.hasFlag(options::OPT_mpascal_strings,
+ options::OPT_mno_pascal_strings,
+ false))
CmdArgs.push_back("-fpascal-strings");
// -fcommon is default, only pass non-default.
if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common))
CmdArgs.push_back("-fno-common");
- // If tool chain translates fpascal-strings, we want to back
- // translate here.
- // FIXME: This is gross; that translation should be pulled from the
- // tool chain.
- if (Arg *A = Args.getLastArg(options::OPT_mpascal_strings,
- options::OPT_mno_pascal_strings)) {
- if (A->getOption().matches(options::OPT_mpascal_strings))
- CmdArgs.push_back("-fpascal-strings");
- else
- CmdArgs.push_back("-fno-pascal-strings");
- }
-
Args.AddLastArg(CmdArgs, options::OPT_dM);
// Add -Wp, and -Xassembler if using the preprocessor.
diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c
new file mode 100644
index 0000000..9dc8f63
--- /dev/null
+++ b/test/Driver/clang_f_opts.c
@@ -0,0 +1,10 @@
+// RUN: clang -### -S -x c /dev/null -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fno-math-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings %s 2> %t &&
+// RUN: grep -F '"-fblocks"' %t &&
+// RUN: grep -F '"--fmath-errno=1"' %t &&
+// RUN: grep -F '"-fpascal-strings"' %t &&
+// RUN: clang -### -S -x c /dev/null -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fno-math-errno -fno-common -fno-pascal-strings %s 2> %t &&
+// RUN: grep -F '"-fblocks=0"' %t &&
+// RUN: grep -F '"-fbuiltin=0"' %t &&
+// RUN: grep -F '"-fno-common"' %t &&
+// RUN: grep -F '"--fmath-errno=0"' %t &&
+// RUN: true