| 1 |
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter %s -Wno-constant-evaluated -verify -fms-extensions |
| 2 |
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter %s -Wno-constant-evaluated -fms-extensions -emit-llvm -o - | FileCheck %s |
| 3 |
// RUN: %clang_cc1 -verify=ref %s -Wno-constant-evaluated -fms-extensions |
| 4 |
// RUN: %clang_cc1 -verify=ref %s -Wno-constant-evaluated %s -fms-extensions -emit-llvm -o - | FileCheck %s |
| 5 |
|
| 6 |
// expected-no-diagnostics |
| 7 |
// ref-no-diagnostics |
| 8 |
|
| 9 |
using size_t = decltype(sizeof(int)); |
| 10 |
|
| 11 |
namespace std { |
| 12 |
inline constexpr bool is_constant_evaluated() noexcept { |
| 13 |
return __builtin_is_constant_evaluated(); |
| 14 |
} |
| 15 |
} // namespace std |
| 16 |
|
| 17 |
constexpr bool b = std::is_constant_evaluated(); |
| 18 |
static_assert(b, ""); |
| 19 |
static_assert(std::is_constant_evaluated() , ""); |
| 20 |
|
| 21 |
|
| 22 |
bool is_this_constant() { |
| 23 |
return __builtin_is_constant_evaluated(); // CHECK: ret i1 false |
| 24 |
} |
| 25 |
|
| 26 |
constexpr bool assume() { |
| 27 |
__builtin_assume(true); |
| 28 |
__builtin_assume(false); |
| 29 |
__assume(1); |
| 30 |
__assume(false); |
| 31 |
return true; |
| 32 |
} |
| 33 |
static_assert(assume(), ""); |
| 34 |
|
| 35 |
void test_builtin_os_log(void *buf, int i, const char *data) { |
| 36 |
constexpr int len = __builtin_os_log_format_buffer_size("%d %{public}s %{private}.16P", i, data, data); |
| 37 |
static_assert(len > 0, "Expect len > 0"); |
| 38 |
} |
| 39 |
|
| 40 |
void addc_dummy() |
| 41 |
{ |
| 42 |
unsigned int a; |
| 43 |
if (__builtin_addc (1, 42, 0, &a)) |
| 44 |
__builtin_abort (); |
| 45 |
} |