From f0d60170cc501447c999569db8fe91aacaad5fe2 Mon Sep 17 00:00:00 2001 From: Timm Baeder Date: Tue, 31 Dec 2024 12:14:27 +0100 Subject: [clang][bytecode] Check memove/memcpy for available elements (#121383) Both destination and source pointer need to have at least as many elements as requested. --- clang/test/AST/ByteCode/builtin-functions.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clang/test/AST/ByteCode/builtin-functions.cpp') 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 { -- cgit v1.1