comparison gcc/testsuite/gcc.dg/analyzer/signal-3.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 #include <stdio.h>
2 #include <signal.h>
3 #include <stdlib.h>
4
5 extern void body_of_program(void);
6
7 void custom_logger(const char *msg)
8 {
9 fprintf(stderr, "LOG: %s", msg); /* { dg-warning "call to 'fprintf' from within signal handler" } */
10 }
11
12 static void handler(int signum)
13 {
14 custom_logger("got signal");
15 }
16
17 void test (void)
18 {
19 void *ptr = malloc (1024);
20 signal(SIGINT, handler); /* { dg-message "registering 'handler' as signal handler" } */
21 body_of_program();
22 free (ptr);
23 }