28 lines · cpp
1// REQUIRES: host-supports-jit2// clang-repl can be called from the prompt in non-interactive mode as a3// calculator in shell scripts, for example. In that case if there is an error4// we should set the exit code as failure.5// RUN: not clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"6 7// In interactive (REPL) mode, we can have errors but we should exit with8// success because errors in the input code are part of the interactive use.9// RUN: cat %s | clang-repl | FileCheck %s10 11// However, interactive mode should fail when we specified -verify and there12// was a diagnostic mismatches. This will make the testsuite fail as intended.13// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s14 15BOOM! // expected-error {{intended to fail the -verify test}}16extern "C" int printf(const char *, ...);17int i = 42;18auto r1 = printf("i = %d\n", i);19// CHECK: i = 4220 211aap = 42; // expected-error {{invalid digit 'a' in decimal constant}}221aap = 42; i = 5; // expected-error {{invalid digit 'a' in decimal constant}}23 24printf("i = %d\n", i);25// CHECK: i = 4226 27%quit28