aboutsummaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode/builtin-functions.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-01-02 10:59:08 +0100
committerGitHub <noreply@github.com>2025-01-02 10:59:08 +0100
commit34097c07e151fef0e5c645e1dac7f4872774317b (patch)
tree0942145d671f0fb01b32489e6eb26eb76b3cb5c0 /clang/test/AST/ByteCode/builtin-functions.cpp
parentd5c8af492f2d8620b04330024d46a5f48db546fe (diff)
downloadllvm-34097c07e151fef0e5c645e1dac7f4872774317b.zip
llvm-34097c07e151fef0e5c645e1dac7f4872774317b.tar.gz
llvm-34097c07e151fef0e5c645e1dac7f4872774317b.tar.bz2
[clang][bytecode] Consider unknown-size arrays in memcpy/memcmp (#121462)
When emitting diagnostics for the number of elements.
Diffstat (limited to 'clang/test/AST/ByteCode/builtin-functions.cpp')
-rw-r--r--clang/test/AST/ByteCode/builtin-functions.cpp9
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 0188e829..7237640 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1263,6 +1263,15 @@ namespace BuiltinMemcpy {
return arr[0].ok() && arr[1].ok() && arr[2].ok();
}
static_assert(test_trivial());
+
+ // Check that an incomplete array is rejected.
+ constexpr int test_incomplete_array_type() { // both-error {{never produces a constant}}
+ extern int arr[];
+ __builtin_memmove(arr, arr, 4 * sizeof(arr[0]));
+ // both-note@-1 2{{'memmove' not supported: source is not a contiguous array of at least 4 elements of type 'int'}}
+ 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}}
}
namespace Memcmp {