From c393dae4b4799dd0c1eff68b8738427cc021cd86 Mon Sep 17 00:00:00 2001
From: Axel Naumann <Axel.Naumann@cern.ch>
Date: Sat, 21 Feb 2015 22:37:50 +0100
Subject: [PATCH] No #include <new> in C mode; add basic C mode test
 (ROOT-7090).

---
 .../cling/lib/Interpreter/IncrementalParser.cpp  | 13 ++++++++-----
 interpreter/cling/test/Driver/C.c                | 16 ++++++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)
 create mode 100644 interpreter/cling/test/Driver/C.c

diff --git a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp
index 5077dd061fb..c47eeb6f598 100644
--- a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp
+++ b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp
@@ -235,11 +235,14 @@ namespace cling {
     if (External)
       External->StartTranslationUnit(m_Consumer);
 
-    // <new> is needed by the ValuePrinter so it's a good thing to include it.
-    // We need to include it to determine the version number of the standard
-    // library implementation.
-    ParseInternal("#include <new>");
-    CheckABICompatibility(m_CI.get());
+    if (m_CI->getLangOpts().CPlusPlus) {
+      // <new> is needed by the ValuePrinter so it's a good thing to include it.
+      // We need to include it to determine the version number of the standard
+      // library implementation.
+      ParseInternal("#include <new>");
+      // That's really C++ ABI compatibility. C has other problems ;-)
+      CheckABICompatibility(m_CI.get());
+    }
 
     // DO NOT commit the transactions here: static initialization in these
     // transactions requires gCling through local_cxa_atexit(), but that has not
diff --git a/interpreter/cling/test/Driver/C.c b/interpreter/cling/test/Driver/C.c
new file mode 100644
index 00000000000..f389331f234
--- /dev/null
+++ b/interpreter/cling/test/Driver/C.c
@@ -0,0 +1,16 @@
+//------------------------------------------------------------------------------
+// CLING - the C++ LLVM-based InterpreterG :)
+//
+// This file is dual-licensed: you can choose to license it under the University
+// of Illinois Open Source License or the GNU Lesser General Public License. See
+// LICENSE.TXT for details.
+//------------------------------------------------------------------------------
+
+// RUN: cat %s | %cling -x c | FileCheck %s
+
+// Validate cling C mode.
+
+int printf(const char*,...);
+printf("CHECK 123\n"); // CHECK: CHECK 123
+
+// fix value printing!
-- 
GitLab