diff --git a/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp b/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp index 41095fc3a9829..f3dde467b87e9 100644 --- a/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp +++ b/interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp @@ -22,6 +22,14 @@ #include "clang/Sema/Sema.h" #include "clang/Sema/SemaDiagnostic.h" +// Implements the CValueExtractionPrinter interface. +extern "C" { +CLING_LIB_EXPORT +void cling_SetValueNoAlloc(void* /*cling::Value* V*/) {} +CLING_LIB_EXPORT +void cling_SetValueWithAlloc(void* /*cling::Value* V*/) {} +} + using namespace clang; namespace cling { @@ -436,6 +444,10 @@ namespace { return VSError(m_Sema, E, "cling::runtime::gCling"); if (!(NSD = utils::Lookup::Namespace(m_Sema, "internal", NSD))) return VSError(m_Sema, E, "cling::runtime::internal namespace"); + } else { + // C, ObjC,... + if (!(NSD = utils::Lookup::Namespace(m_Sema, "cling"))) + return VSError(m_Sema, E, "cling namespace"); } LookupResult R(*m_Sema, &m_Context->Idents.get("setValueNoAlloc"), SourceLocation(), Sema::LookupOrdinaryName, diff --git a/interpreter/cling/test/Driver/C.c b/interpreter/cling/test/Driver/C.c index ee302920495b4..05201877e8dd8 100644 --- a/interpreter/cling/test/Driver/C.c +++ b/interpreter/cling/test/Driver/C.c @@ -11,13 +11,13 @@ // Validate cling C mode. -// Fix value printing! - int printf(const char*,...); printf("CHECK 123 %p\n", gCling); // CHECK: CHECK 123 -12 // expected-error {{ValueExtractionSynthesizer could not find: 'cling::runtime::internal::setValueNoAlloc'.}} - -32 // expected-error {{ValueExtractionSynthesizer could not find: 'cling::runtime::internal::setValueNoAlloc'.}} +int i = 1 // CHECK: (int) 1 +sizeof(int) // CHECK: (unsigned long) 4 +int x = sizeof(int); +printf("CHECK %d\n", x); // CHECK: CHECK 4 +// expected-no-diagnostics .q