| 1 |
/* As per inlining-4.c, but testing how the ASCII art version of |
| 2 |
the path looks. */ |
| 3 |
|
| 4 |
/* { dg-additional-options "-O2 -fdiagnostics-show-path-depths" } */ |
| 5 |
/* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */ |
| 6 |
|
| 7 |
#include "../../gcc.dg/analyzer/analyzer-decls.h" |
| 8 |
|
| 9 |
|
| 10 |
static inline const char* |
| 11 |
inner (int flag) |
| 12 |
{ |
| 13 |
if (flag) |
| 14 |
return NULL; |
| 15 |
return "foo"; |
| 16 |
} |
| 17 |
|
| 18 |
static inline const char* |
| 19 |
middle (int flag) |
| 20 |
{ |
| 21 |
return inner (flag); |
| 22 |
} |
| 23 |
|
| 24 |
char |
| 25 |
outer (int flag) |
| 26 |
{ |
| 27 |
return *middle (flag); /* { dg-warning "dereference of NULL" "warning" } */ |
| 28 |
} |
| 29 |
|
| 30 |
/* { dg-begin-multiline-output "" } |
| 31 |
return *middle (flag); |
| 32 |
^~~~~~~~~~~~~~ |
| 33 |
'outer': events 1-2 (depth 1) |
| 34 |
| |
| 35 |
| outer (int flag) |
| 36 |
| ^~~~~ |
| 37 |
| | |
| 38 |
| (1) entry to 'outer' |
| 39 |
| |
| 40 |
| return *middle (flag); |
| 41 |
| ~ |
| 42 |
| | |
| 43 |
| (2) inlined call to 'middle' from 'outer' |
| 44 |
| |
| 45 |
+--> 'middle': event 3 (depth 2) |
| 46 |
| |
| 47 |
| return inner (flag); |
| 48 |
| ^ |
| 49 |
| | |
| 50 |
| (3) inlined call to 'inner' from 'middle' |
| 51 |
| |
| 52 |
+--> 'inner': event 4 (depth 3) |
| 53 |
| |
| 54 |
| if (flag) |
| 55 |
| ^ |
| 56 |
| | |
| 57 |
| (4) following 'true' branch (when 'flag != 0')... |
| 58 |
| |
| 59 |
'inner': event 5 (depth 3) |
| 60 |
| |
| 61 |
| |
| 62 |
| #define NULL ((void *)0) |
| 63 |
| ^ |
| 64 |
| | |
| 65 |
| (5) ...to here |
| 66 |
{ dg-end-multiline-output "" { target c } } */ |
| 67 |
/* { dg-begin-multiline-output "" } |
| 68 |
| return NULL; |
| 69 |
| ^~~~ |
| 70 |
| |
| 71 |
<-------------+ |
| 72 |
| |
| 73 |
'outer': event 6 (depth 1) |
| 74 |
| |
| 75 |
| return *middle (flag); |
| 76 |
| ^~~~~~~~~~~~~~ |
| 77 |
| | |
| 78 |
| (6) dereference of NULL '<unknown>' |
| 79 |
| |
| 80 |
{ dg-end-multiline-output "" { target c } } */ |
| 81 |
/* { dg-begin-multiline-output "" } |
| 82 |
return *middle (flag); |
| 83 |
^ |
| 84 |
'char outer(int)': events 1-2 (depth 1) |
| 85 |
| |
| 86 |
| outer (int flag) |
| 87 |
| ^~~~~ |
| 88 |
| | |
| 89 |
| (1) entry to 'outer' |
| 90 |
| |
| 91 |
| return *middle (flag); |
| 92 |
| ~ |
| 93 |
| | |
| 94 |
| (2) inlined call to 'middle' from 'outer' |
| 95 |
| |
| 96 |
+--> 'const char* middle(int)': event 3 (depth 2) |
| 97 |
| |
| 98 |
| return inner (flag); |
| 99 |
| ^ |
| 100 |
| | |
| 101 |
| (3) inlined call to 'inner' from 'middle' |
| 102 |
| |
| 103 |
+--> 'const char* inner(int)': event 4 (depth 3) |
| 104 |
| |
| 105 |
| if (flag) |
| 106 |
| ^~ |
| 107 |
| | |
| 108 |
| (4) following 'true' branch (when 'flag != 0')... |
| 109 |
| |
| 110 |
'const char* inner(int)': event 5 (depth 3) |
| 111 |
| |
| 112 |
| |
| 113 |
| #define NULL |
| 114 |
| |
| 115 |
| | |
| 116 |
| (5) ...to here |
| 117 |
{ dg-end-multiline-output "" { target c++ } } */ |
| 118 |
/* { dg-begin-multiline-output "" } |
| 119 |
| return NULL; |
| 120 |
| ^~~~ |
| 121 |
| |
| 122 |
<-------------+ |
| 123 |
| |
| 124 |
'char outer(int)': event 6 (depth 1) |
| 125 |
| |
| 126 |
| return *middle (flag); |
| 127 |
| ^ |
| 128 |
| | |
| 129 |
| (6) dereference of NULL '<unknown>' |
| 130 |
| |
| 131 |
{ dg-end-multiline-output "" { target c++ } } */ |