diff options
author | Timm Baeder <tbaeder@redhat.com> | 2024-12-31 12:14:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-31 12:14:27 +0100 |
commit | f0d60170cc501447c999569db8fe91aacaad5fe2 (patch) | |
tree | 27a449b8a5bb8bb96d432afb70333db48464b0a8 /clang/test/AST/ByteCode/builtin-functions.cpp | |
parent | b35d3453ddf14e9564a6b65bd325051f4492311c (diff) | |
download | llvm-f0d60170cc501447c999569db8fe91aacaad5fe2.zip llvm-f0d60170cc501447c999569db8fe91aacaad5fe2.tar.gz llvm-f0d60170cc501447c999569db8fe91aacaad5fe2.tar.bz2 |
[clang][bytecode] Check memove/memcpy for available elements (#121383)
Both destination and source pointer need to have at least as many
elements as requested.
Diffstat (limited to 'clang/test/AST/ByteCode/builtin-functions.cpp')
-rw-r--r-- | clang/test/AST/ByteCode/builtin-functions.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index c1fd1bc..b0f8ea2 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -1244,6 +1244,15 @@ namespace BuiltinMemcpy { } static_assert(cpyptr()); +#ifndef __AVR__ + constexpr int test_memmove(int a, int b, int n) { + int arr[4] = {1, 2, 3, 4}; + __builtin_memmove(arr + a, arr + b, n); // both-note {{destination is not a contiguous array of at least 3 elements of type 'int'}} + return result(arr); + } + static_assert(test_memmove(2, 0, 12) == 4234); // both-error {{constant}} \ + // both-note {{in call}} +#endif } namespace Memcmp { |