[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / CodeGenCXX / cxx1z-constexpr-if.cpp
blobd14e36406a45e604518bb2b1ebc9b2bb88ef171e
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
3 void should_be_used_1();
4 void should_be_used_2();
5 void should_be_used_3();
6 void should_not_be_used();
8 struct A {
9 constexpr explicit operator bool() const {
10 return true;
14 void f() {
15 if constexpr (false)
16 should_not_be_used();
17 else
18 should_be_used_1();
20 if constexpr (true || ({ label: false; }))
21 should_be_used_2();
22 else {
23 goto foo;
24 foo: should_not_be_used();
26 if constexpr (A())
27 should_be_used_3();
28 else
29 should_not_be_used();
32 // CHECK: should_be_used_1
33 // CHECK: should_be_used_2
34 // CHECK: should_be_used_3
36 namespace BlockThisCapture {
37 void foo();
38 struct S {
39 template <bool b>
40 void m() {
41 ^{ if constexpr(b) (void)this; else foo(); }();
45 void test() {
46 S().m<false>();
50 // CHECK-LABEL: define internal void @___ZN16BlockThisCapture1S1mILb0EEEvv_block_invoke(
51 // CHECK: call void @_ZN16BlockThisCapture3fooEv(