Fixed parsing of '\'' at the prompt (ROOT-7159).

This commit is contained in:
Liza Sakellari 2015-03-31 10:38:13 +02:00 committed by sftnight
parent 91b011604b
commit 529b0aed53
4 changed files with 17 additions and 25 deletions

View File

@ -127,6 +127,9 @@ namespace cling {
bool skipComments /*false*/) {
Tok.startToken(curPos);
while (true) {
if(*curPos == '\\')
curPos += 2;
// On comment skip until the eof token.
if (!skipComments && curPos[0] == '/' && curPos[1] == '/') {
while (*curPos != '\0' && *curPos != '\r' && *curPos != '\n')

View File

@ -89,6 +89,7 @@ namespace cling {
Value* result) {
// Check if there is a function named after the file.
assert(!args.empty() && "Arguments must be provided (at least \"()\"");
cling::Transaction* T = 0;
MetaSema::ActionResult actionResult = actOnLCommand(file, &T);
if (actionResult == AR_Success) {
@ -120,30 +121,6 @@ namespace cling {
<< pairFuncExt.first;
return AR_Success;
}
else if (args.empty()) {
// No arguments passed - can we call it?
if (FunctionDecl* FD = dyn_cast<FunctionDecl>(ND)) {
// Check whether we can call it with no arguments.
bool canCall = true;
for (auto Param: FD->params()) {
if (!Param->hasDefaultArg()) {
canCall = false;
break;
}
}
if (!canCall) {
// FIXME: Produce clang diagnostics no viable function to call.
unsigned diagID
= Diags.getCustomDiagID (DiagnosticsEngine::Level::Warning,
"function '%0' cannot be called with no arguments.");
//FIXME: Figure out how to pass in proper source locations, which we
// can use with -verify.
Diags.Report(noLoc, diagID)
<< FD->getNameAsString();
return AR_Success;
}
} // FIXME: else no function to call!
}
if (m_Interpreter.echo(expression, result) != Interpreter::kSuccess)
actionResult = AR_Failure;

13
test/Driver/Init.C Normal file
View File

@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// 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 2>&1 | FileCheck %s
#include <initializer_list>
auto l {'a', 'b', '\''};
l // CHECK: (class std::initializer_list<char> &) @0x{{.*}}

View File

@ -10,7 +10,6 @@
//RUN: %cling '.x %s(42,"AAA)BBB")' 2>&1 | FileCheck -check-prefix=CHECK-DOTX %s
//CHECK-NOT: {{.*error|note:.*}}
//CHECK-DOTX-NOT: {{.*error|note:.*}}
//CHECK: warning: function 'args' cannot be called with no arguments.
extern "C" int printf(const char* fmt, ...);