aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/inlining-5-multiline.c
blob: 8fefe380e9a2b19fa002404a562ff99603c3cf8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* As per inlining-5.c, but testing how the ASCII art version of
   the path looks.  */

/* { dg-additional-options "-O2 -fdiagnostics-show-path-depths" } */
/* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */

static inline void
inner (void *p)
{
  __builtin_free (p); /* { dg-warning "double-'free' of 'r'" } */
}

static inline void
middle (void *q)
{
  __builtin_free (q);
  inner (q);
}

void
outer (void *r)
{
  middle (r);
}

/* { dg-begin-multiline-output "" }
   __builtin_free (p);
   ^~~~~~~~~~~~~~~~~~
  'outer': events 1-2 (depth 1)
    |
    | outer (void *r)
    | ^~~~~
    | |
    | (1) entry to 'outer'
    |
    |   middle (r);
    |   ~
    |   |
    |   (2) inlined call to 'middle' from 'outer'
    |
    +--> 'middle': events 3-4 (depth 2)
           |
           |   __builtin_free (q);
           |   ^~~~~~~~~~~~~~~~~~
           |   |
           |   (3) first 'free' here
           |   inner (q);
           |   ~
           |   |
           |   (4) inlined call to 'inner' from 'middle'
           |
           +--> 'inner': event 5 (depth 3)
                  |
                  |   __builtin_free (p);
                  |   ^~~~~~~~~~~~~~~~~~
                  |   |
                  |   (5) second 'free' here; first 'free' was at (3)
                  |
   { dg-end-multiline-output "" { target c } } */
/* { dg-begin-multiline-output "" }
   __builtin_free (p);
   ~~~~~~~~~~~~~~~^~~
  'void outer(void*)': events 1-2 (depth 1)
    |
    | outer (void *r)
    | ^~~~~
    | |
    | (1) entry to 'outer'
    |
    |   middle (r);
    |          ~
    |          |
    |          (2) inlined call to 'middle' from 'outer'
    |
    +--> 'void middle(void*)': events 3-4 (depth 2)
           |
           |   __builtin_free (q);
           |   ~~~~~~~~~~~~~~~^~~
           |                  |
           |                  (3) first 'free' here
           |   inner (q);
           |         ~         
           |         |
           |         (4) inlined call to 'inner' from 'middle'
           |
           +--> 'void inner(void*)': event 5 (depth 3)
                  |
                  |   __builtin_free (p);
                  |   ~~~~~~~~~~~~~~~^~~
                  |                  |
                  |                  (5) second 'free' here; first 'free' was at (3)
                  |
   { dg-end-multiline-output "" { target c++ } } */