Debian Codegraph @

clang/test/AST/ByteCode/cond.cpp

raw
1 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -fexperimental-new-constant-interpreter %s -verify
2 // RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify
3 // expected-no-diagnostics
4
5 constexpr int cond_then_else(int a, int b) {
6 if (a < b) {
7 return b - a;
8 } else {
9 return a - b;
10 }
11 }
12
13 constexpr int dontCallMe(unsigned m) {
14 if (m == 0) return 0;
15 return dontCallMe(m - 2);
16 }
17
18 // Can't call this because it will run into infinite recursion.
19 constexpr int assertNotReached() {
20 return dontCallMe(3);
21 }
22
23 static_assert(true || true, "");
24 static_assert(true || false, "");
25 static_assert(false || true, "");
26 static_assert(!(false || false), "");
27
28 static_assert(true || assertNotReached(), "");
29 static_assert(true || true || true || false, "");
30
31 static_assert(true && true, "");
32 static_assert(!(true && false), "");
33 static_assert(!(false && true), "");
34 static_assert(!(false && false), "");
35
36 static_assert(!(false && assertNotReached()), "");
37 static_assert(!(true && true && true && false), "");