Debian Codegraph @

clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp

raw
1 // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -fblocks -triple x86_64-apple-darwin10 -o - | FileCheck %s --implicit-check-not=should_not_be_used
2 // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -fblocks -triple x86_64-apple-darwin10 -o - -fexperimental-new-constant-interpreter | FileCheck %s --implicit-check-not=should_not_be_used
3
4 void should_be_used_1();
5 void should_be_used_2();
6 void should_be_used_3();
7 void should_not_be_used();
8
9 struct A {
10 constexpr explicit operator bool() const {
11 return true;
12 }
13 };
14
15 void f() {
16 if constexpr (false)
17 should_not_be_used();
18 else
19 should_be_used_1();
20
21 if constexpr (true || ({ label: false; }))
22 should_be_used_2();
23 else {
24 goto foo;
25 foo: should_not_be_used();
26 }
27 if constexpr (A())
28 should_be_used_3();
29 else
30 should_not_be_used();
31 }
32
33 // CHECK: should_be_used_1
34 // CHECK: should_be_used_2
35 // CHECK: should_be_used_3
36
37 namespace BlockThisCapture {
38 void foo();
39 struct S {
40 template <bool b>
41 void m() {
42 ^{ if constexpr(b) (void)this; else foo(); }();
43 }
44 };
45
46 void test() {
47 S().m<false>();
48 }
49 }
50
51 // CHECK-LABEL: define internal void @___ZN16BlockThisCapture1S1mILb0EEEvv_block_invoke(
52 // CHECK: call void @_ZN16BlockThisCapture3fooEv(