diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-02-11 08:45:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-11 08:45:24 +0100 |
commit | dfbd764a551bf1a0c72bd3e76ac86297221448c0 (patch) | |
tree | 852b5f857d1b88f4198758a16fbb178b2e563ce4 /clang/test/AST/ByteCode/builtin-functions.cpp | |
parent | 2cd8207b26ea4269630feba661f68554d7ae3c15 (diff) | |
download | llvm-dfbd764a551bf1a0c72bd3e76ac86297221448c0.zip llvm-dfbd764a551bf1a0c72bd3e76ac86297221448c0.tar.gz llvm-dfbd764a551bf1a0c72bd3e76ac86297221448c0.tar.bz2 |
[clang][bytecode][NFC] Add failing memmove testcase (#126682)
Reduced from
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp
Diffstat (limited to 'clang/test/AST/ByteCode/builtin-functions.cpp')
-rw-r--r-- | clang/test/AST/ByteCode/builtin-functions.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 7034e8c..d51b039 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -1272,6 +1272,22 @@ namespace BuiltinMemcpy { return arr[0] * 1000 + arr[1] * 100 + arr[2] * 10 + arr[3]; } static_assert(test_incomplete_array_type() == 1234); // both-error {{constant}} both-note {{in call}} + + + /// FIXME: memmove needs to support overlapping memory regions. + constexpr bool memmoveOverlapping() { + char s1[] {1, 2, 3}; + __builtin_memmove(s1, s1 + 1, 2 * sizeof(char)); + // Now: 2, 3, 3 + bool Result1 = (s1[0] == 2 && s1[1] == 3 && s1[2]== 3); + + __builtin_memmove(s1 + 1, s1, 2 * sizeof(char)); + // Now: 2, 2, 3 + bool Result2 = (s1[0] == 2 && s1[1] == 2 && s1[2]== 3); + + return Result1 && Result2; + } + static_assert(memmoveOverlapping()); // expected-error {{failed}} } namespace Memcmp { |