Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Darwin / mixing-global-constructors.cpp
blob0b0f15cc78d5e50c2d3e6499f31a10cbcea8018c
1 // A global constructor from a non-instrumented part calls a function
2 // in an instrumented part.
3 // Regression test for https://code.google.com/p/address-sanitizer/issues/detail?id=363.
5 // RUN: %clangxx -DINSTRUMENTED_PART=0 -c %s -o %t-uninst.o
6 // RUN: %clangxx_asan -DINSTRUMENTED_PART=1 -c %s -o %t-inst.o
7 // RUN: %clangxx_asan %t-uninst.o %t-inst.o -o %t
9 // RUN: %run %t 2>&1 | FileCheck %s
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
15 void func(char *ptr);
17 #if INSTRUMENTED_PART == 1
19 void func(char *ptr) {
20 *ptr = 'X';
23 #else // INSTRUMENTED_PART == 1
25 struct C1 {
26 C1() {
27 printf("Hello ");
28 char buffer[10] = "world";
29 func(buffer);
30 printf("%s\n", buffer);
34 C1 *obj = new C1();
36 int main(int argc, const char *argv[]) {
37 return 0;
40 #endif // INSTRUMENTED_PART == 1
42 // CHECK: Hello Xorld