Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / safestack / buffer-copy-vla.c
blob356a1ac5c65c0e3c01c37978add3720a9f95b81a
1 // RUN: %clang_safestack %s -o %t
2 // RUN: %run %t
4 #include "utils.h"
6 // Test that loads/stores work correctly for VLAs on the unsafe stack.
8 int main(int argc, char **argv)
10 int i = 128;
11 break_optimization(&i);
12 char buffer[i];
14 // check that we can write to a buffer
15 for (i = 0; argv[0][i] && i < sizeof (buffer) - 1; ++i)
16 buffer[i] = argv[0][i];
17 buffer[i] = '\0';
19 break_optimization(buffer);
21 // check that we can read from a buffer
22 for (i = 0; argv[0][i] && i < sizeof (buffer) - 1; ++i)
23 if (buffer[i] != argv[0][i])
24 return 1;
25 return 0;