mstorsjo wrote:
This test fails on mingw targets, see e.g.
https://github.com/mstorsjo/llvm-mingw/actions/runs/24308566576/job/70974063490.
Mingw targets are windows, but with gnu C extensions.
Ways of fixing it could be:
```diff
diff --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c
index f343aaec4330..810241accffa 100644
--- a/clang/test/Analysis/bstring.c
+++ b/clang/test/Analysis/bstring.c
@@ -539,7 +539,7 @@ void nocrash_on_locint_offset(void *addr, void* from,
struct S s) {
void nocrash_on_empty_struct_memcpy(void) {
struct {} a[10];
__builtin_memcpy(&a[2], a, 2); // no-crash
-#if !defined(_WIN32)
+#if !defined(_WIN32) || defined(__MINGW32__)
// expected-warning@-2 {{'memcpy' will always overflow; destination buffer
has size 0, but size argument is 2}}
// expected-warning@-3 {{Memory copy function overflows the destination
buffer}}
#endif
```
Or
```diff
diff --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c
index f343aaec4330..7e2ee1af006a 100644
--- a/clang/test/Analysis/bstring.c
+++ b/clang/test/Analysis/bstring.c
@@ -539,7 +539,7 @@ void nocrash_on_locint_offset(void *addr, void* from,
struct S s) {
void nocrash_on_empty_struct_memcpy(void) {
struct {} a[10];
__builtin_memcpy(&a[2], a, 2); // no-crash
-#if !defined(_WIN32)
+#if defined(__GNUC__)
// expected-warning@-2 {{'memcpy' will always overflow; destination buffer
has size 0, but size argument is 2}}
// expected-warning@-3 {{Memory copy function overflows the destination
buffer}}
#endif
```
Out of these, I think the latter is to be preferred, as it exactly captures the
condition where this happens, as explained by the comment above the function.
https://github.com/llvm/llvm-project/pull/191061
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits