diff options
author | Timm Baeder <tbaeder@redhat.com> | 2024-12-19 16:38:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-19 16:38:58 +0100 |
commit | 1f2d934525833c4aae5f0436fd99551c776fd246 (patch) | |
tree | 66dd7c305eb2494496b469b125ac7943fb138720 /clang/test/AST/ByteCode/builtin-functions.cpp | |
parent | 6f8afafd308d37d9abc4af0801dd5a4451c13718 (diff) | |
download | llvm-1f2d934525833c4aae5f0436fd99551c776fd246.zip llvm-1f2d934525833c4aae5f0436fd99551c776fd246.tar.gz llvm-1f2d934525833c4aae5f0436fd99551c776fd246.tar.bz2 |
[clang][bytecode] Support pointers in __builtin_mem{move,cpy} (#120560)
Unfortunately, that means we can't use the __builtin_bit_cast
implementation for this.
Diffstat (limited to 'clang/test/AST/ByteCode/builtin-functions.cpp')
-rw-r--r-- | clang/test/AST/ByteCode/builtin-functions.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 5906cb9..c1fd1bc 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -1222,6 +1222,28 @@ namespace BuiltinMemcpy { 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}} + + /// Both memcpy and memmove must support pointers. + constexpr bool moveptr() { + int a = 0; + void *x = &a; + void *z = nullptr; + + __builtin_memmove(&z, &x, sizeof(void*)); + return z == x; + } + static_assert(moveptr()); + + constexpr bool cpyptr() { + int a = 0; + void *x = &a; + void *z = nullptr; + + __builtin_memcpy(&z, &x, sizeof(void*)); + return z == x; + } + static_assert(cpyptr()); + } namespace Memcmp { |