Home | History | Annotate | Download | only in Integer
      1 // RUN: %clangxx -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s
      2 // RUN: %clangxx -DOP=++n -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s
      3 // RUN: %clangxx -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s
      4 // RUN: %clangxx -DOP=--m -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s
      5 
      6 #include <stdint.h>
      7 
      8 int main() {
      9   int n = 0x7ffffffd;
     10   n++;
     11   n++;
     12   int m = -n - 1;
     13   // CHECK: incdec-overflow.cpp:15:3: runtime error: signed integer overflow: [[MINUS:-?]]214748364
     14   // CHECK: + [[MINUS]]1 cannot be represented in type 'int'
     15   OP;
     16 }
     17