xref: /llvm-project/clang/test/Interpreter/fail.cpp (revision fd5f06eb6d8d8b05846c8d7bd2431079ef707b37)
1 // REQUIRES: host-supports-jit
2 // UNSUPPORTED: system-aix
3 // clang-repl can be called from the prompt in non-interactive mode as a
4 // calculator in shell scripts, for example. In that case if there is an error
5 // we should set the exit code as failure.
6 // RUN: not clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
7 
8 // In interactive (REPL) mode, we can have errors but we should exit with
9 // success because errors in the input code are part of the interactive use.
10 // RUN: cat %s | clang-repl | FileCheck %s
11 
12 // However, interactive mode should fail when we specified -verify and there
13 // was a diagnostic mismatches. This will make the testsuite fail as intended.
14 // RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s
15 
16 BOOM! // expected-error {{intended to fail the -verify test}}
17 extern "C" int printf(const char *, ...);
18 int i = 42;
19 auto r1 = printf("i = %d\n", i);
20 // CHECK: i = 42
21 %quit
22