]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/compiler-rt/test/asan/TestCases/Darwin/odr-lto.cc
New upstream version 1.24.1+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / asan / TestCases / Darwin / odr-lto.cc
CommitLineData
7cac9316
XL
1// Check that -asan-use-private-alias and use_odr_indicator=1 silence the false
2// positive ODR violation on Darwin with LTO.
3
4// REQUIRES: lto
5
6// RUN: %clangxx_asan -DPART=0 -c %s -o %t-1.o -flto
7// RUN: %clangxx_asan -DPART=1 -c %s -o %t-2.o -flto
8// RUN: %clangxx_asan %t-1.o %t-2.o -o %t -flto
9// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ODR
10
11// RUN: %clangxx_asan -DPART=0 -c %s -o %t-1.o -flto -mllvm -asan-use-private-alias
12// RUN: %clangxx_asan -DPART=1 -c %s -o %t-2.o -flto -mllvm -asan-use-private-alias
13// RUN: %clangxx_asan %t-1.o %t-2.o -o %t -flto
14// RUN: %env_asan_opts=use_odr_indicator=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ODR
15
16#include <stdio.h>
17#include <stdlib.h>
18void putstest();
19
20#if PART == 1
21
22static const char *my_global = "test\n\00abc";
23
24int main()
25{
26 fputs(my_global, stderr);
27 putstest();
28 fprintf(stderr, "Done.\n");
29 return 0;
30}
31
32#else // PART == 1
33
34static const char *my_other_global = "test\n\00abc";
35
36void putstest()
37{
38 fputs(my_other_global, stderr);
39}
40
41#endif // PART == 1
42
43// CHECK-ODR: ERROR: AddressSanitizer: odr-violation
44// CHECK-NO-ODR-NOT: ERROR: AddressSanitizer: odr-violation
45// CHECK-NO-ODR: Done.