From e582b93a1613f86df21f5d8ec80eb8ada030033f Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Sat, 21 Feb 2015 22:37:50 +0100 Subject: [PATCH] No #include in C mode; add basic C mode test (ROOT-7090). --- lib/Interpreter/IncrementalParser.cpp | 13 ++++++++----- test/Driver/C.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 test/Driver/C.c diff --git a/lib/Interpreter/IncrementalParser.cpp b/lib/Interpreter/IncrementalParser.cpp index 5077dd06..c47eeb6f 100644 --- a/lib/Interpreter/IncrementalParser.cpp +++ b/lib/Interpreter/IncrementalParser.cpp @@ -235,11 +235,14 @@ namespace cling { if (External) External->StartTranslationUnit(m_Consumer); - // 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 "); - CheckABICompatibility(m_CI.get()); + if (m_CI->getLangOpts().CPlusPlus) { + // 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 "); + // 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/test/Driver/C.c b/test/Driver/C.c new file mode 100644 index 00000000..f389331f --- /dev/null +++ b/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!