Home | History | Annotate | Download | only in safestack
      1 // RUN: %clang_safestack %s -o %t
      2 // RUN: %run %t
      3 
      4 #include "utils.h"
      5 
      6 // Test that loads/stores work correctly for VLAs on the unsafe stack.
      7 
      8 int main(int argc, char **argv)
      9 {
     10   int i = 128;
     11   break_optimization(&i);
     12   char buffer[i];
     13 
     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';
     18 
     19   break_optimization(buffer);
     20 
     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;
     26 }
     27