Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / builtins-memset-inline.cpp
blobe445b3bcb3c254fe8956c895ff5262f32568df68
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 #define NULL ((char *)0)
5 #if __has_builtin(__builtin_memset_inline)
6 #warning defined as expected
7 // expected-warning@-1 {{defined as expected}}
8 #endif
10 void test_memset_inline_invalid_arg_types() {
11 __builtin_memset_inline(1, 2, 3); // expected-error {{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
14 void test_memset_inline_null_dst(void *ptr) {
15 __builtin_memset_inline(NULL, 1, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
18 void test_memset_inline_null_buffer_is_ok_if_size_is_zero(void *ptr, char value) {
19 __builtin_memset_inline(NULL, value, /*size */ 0);
22 void test_memset_inline_non_constant_size(void *dst, char value, unsigned size) {
23 __builtin_memset_inline(dst, value, size); // expected-error {{argument to '__builtin_memset_inline' must be a constant integer}}
26 template <unsigned size>
27 void test_memset_inline_template(void *dst, char value) {
28 // we do not try to evaluate size in non intantiated templates.
29 __builtin_memset_inline(dst, value, size);
32 void test_memset_inline_implicit_conversion(void *ptr, char value) {
33 char a[5];
34 __builtin_memset_inline(a, value, 5);
37 void test_memset_inline_num_args(void *dst, char value) {
38 __builtin_memset_inline(); // expected-error {{too few arguments to function call}}
39 __builtin_memset_inline(dst, value, 4, NULL); // expected-error {{too many arguments to function call}}