[flang] Apply nocapture attribute to dummy arguments (#116182)
[llvm-project.git] / compiler-rt / test / msan / sigaction.cpp
blob0c69f115fdb24ad06d078cdd16f255f03d71fba1
1 // RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t
2 // RUN: %run %t __
3 // RUN: not %run %t A_ 2>&1 | FileCheck %s
4 // RUN: not %run %t AH 2>&1 | FileCheck %s
5 // RUN: not %run %t B_ 2>&1 | FileCheck %s
6 // RUN: not %run %t BH 2>&1 | FileCheck %s
7 // RUN: not %run %t C_ 2>&1 | FileCheck %s
8 // RUN: not %run %t CH 2>&1 | FileCheck %s
10 #include <assert.h>
11 #include <signal.h>
12 #include <string.h>
13 #include <sys/time.h>
14 #include <unistd.h>
16 #include <sanitizer/msan_interface.h>
18 void handler(int) {}
19 void action(int, siginfo_t *, void *) {}
21 int main(int argc, char **argv) {
22 char T = argv[1][0];
23 char H = argv[1][1];
24 struct sigaction sa;
25 memset(&sa, 0, sizeof(sa));
26 if (H == 'H') {
27 sa.sa_handler = handler;
28 } else {
29 sa.sa_sigaction = action;
30 sa.sa_flags = SA_SIGINFO;
33 if (T == 'A') {
34 if (H == 'H')
35 __msan_poison(&sa.sa_handler, sizeof(sa.sa_handler));
36 else
37 __msan_poison(&sa.sa_sigaction, sizeof(sa.sa_sigaction));
39 if (T == 'B')
40 __msan_poison(&sa.sa_flags, sizeof(sa.sa_flags));
41 if (T == 'C')
42 __msan_poison(&sa.sa_mask, sizeof(sa.sa_mask));
43 // CHECK: use-of-uninitialized-value
44 int res = sigaction(SIGUSR1, &sa, nullptr);
45 assert(res == 0);
46 return 0;