aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/signal-registration-loc.c
blob: 4bac1269b1e1b053798c5960bb31a6952170aee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* Ensure we use the correct location when reporting where the
   signal handler was registered (PR analyzer/95188).  */

/* { dg-require-effective-target signal } */

#include <stdio.h>
#include <signal.h>

int g;
extern int foo (void);

static void
handler (int n)
{
  fprintf (stderr, "got here: %i\n", g); /* { dg-warning "call to 'fprintf' from within signal handler" } */
}

int main (int argc, char *argv[])
{
  g = foo (); /* { dg-bogus "registering" } */
  signal (SIGSEGV, handler); /* { dg-message "registering 'handler' as signal handler" } */
  return 0;
}