summaryrefslogtreecommitdiff
path: root/test/ubsan/TestCases/Misc/deduplication.cpp
blob: 4b02590fa0ac20b9ef8459b92e2ec8bdee508c0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// RUN: %clangxx -fsanitize=undefined %s -o %t && %run %t 2>&1 | FileCheck %s
// Verify deduplication works by ensuring only one diag is emitted.
#include <limits.h>
#include <stdio.h>

void overflow() {
  int i = INT_MIN;
  --i;
}

int main() {
  // CHECK: Start
  fprintf(stderr, "Start\n");
  fflush(stderr);

  // CHECK: runtime error
  // CHECK-NOT: runtime error
  // CHECK-NOT: runtime error
  overflow();
  overflow();
  overflow();

  // CHECK: End
  fprintf(stderr, "End\n");
  return 0;
}