aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Driver/Tools.cpp11
-rw-r--r--test/Frontend/cpp-output.c15
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index f5b017c39c..bfc247a015 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -43,8 +43,17 @@ void Clang::AddPreprocessingOptions(const Driver &D,
ArgStringList &CmdArgs,
const InputInfo &Output,
const InputInfoList &Inputs) const {
- // Handle dependency file generation.
Arg *A;
+
+ if ((A = Args.getLastArg(options::OPT_C)) ||
+ (A = Args.getLastArg(options::OPT_CC))) {
+ if (!Args.hasArg(options::OPT_E))
+ D.Diag(clang::diag::err_drv_argument_only_allowed_with)
+ << A->getAsString(Args) << "-E";
+ A->render(Args, CmdArgs);
+ }
+
+ // Handle dependency file generation.
if ((A = Args.getLastArg(options::OPT_M)) ||
(A = Args.getLastArg(options::OPT_MM)) ||
(A = Args.getLastArg(options::OPT_MD)) ||
diff --git a/test/Frontend/cpp-output.c b/test/Frontend/cpp-output.c
new file mode 100644
index 0000000000..ee37f4cd68
--- /dev/null
+++ b/test/Frontend/cpp-output.c
@@ -0,0 +1,15 @@
+// RUN: clang -E -o %t -C %s &&
+// RUN: grep '^int x; // comment' %t &&
+// RUN: grep '^x x' %t &&
+// RUN: clang -E -o %t -CC %s &&
+// RUN: grep '^int x; // comment' %t &&
+// RUN: grep '^x /\* comment \*/ x /\* comment \*/' %t &&
+// RUN: true
+
+int x; // comment
+
+#define A(foo, bar) foo bar
+#define B x // comment
+
+A(B, B)
+