diff options
Diffstat (limited to 'clang/test/AST/ByteCode/builtin-functions.cpp')
-rw-r--r-- | clang/test/AST/ByteCode/builtin-functions.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 7dd08cb..ef6faae 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -1207,4 +1207,19 @@ namespace BuiltinMemcpy { } static_assert(memcpyTypeRem() == 12); // both-error {{not an integral constant expression}} \ // both-note {{in call to}} + + template<typename T> + constexpr T result(T (&arr)[4]) { + return arr[0] * 1000 + arr[1] * 100 + arr[2] * 10 + arr[3]; + } + + constexpr int test_memcpy(int a, int b, int n) { + int arr[4] = {1, 2, 3, 4}; + __builtin_memcpy(arr + a, arr + b, n); // both-note {{overlapping memory regions}} + return result(arr); + } + + static_assert(test_memcpy(1, 2, sizeof(int)) == 1334); + static_assert(test_memcpy(0, 1, sizeof(int) * 2) == 2334); // both-error {{not an integral constant expression}} \ + // both-note {{in call}} } |