| 1 |
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */ |
| 2 |
/* { dg-enable-nn-line-numbers "" } */ |
| 3 |
/* { dg-require-effective-target indirect_jumps } */ |
| 4 |
|
| 5 |
#include "../../gcc.dg/analyzer/test-setjmp.h" |
| 6 |
#include <stddef.h> |
| 7 |
#include "../../gcc.dg/analyzer/analyzer-decls.h" |
| 8 |
|
| 9 |
static jmp_buf env; |
| 10 |
|
| 11 |
static void inner (void) |
| 12 |
{ |
| 13 |
SETJMP (env); |
| 14 |
} |
| 15 |
|
| 16 |
void outer (void) |
| 17 |
{ |
| 18 |
int i; |
| 19 |
|
| 20 |
inner (); |
| 21 |
|
| 22 |
longjmp (env, 42); /* { dg-warning "'longjmp' called after enclosing function of 'setjmp' has returned" } */ |
| 23 |
} |
| 24 |
|
| 25 |
/* { dg-begin-multiline-output "" } |
| 26 |
NN | longjmp (env, 42); |
| 27 |
| ^~~~~~~~~~~~~~~~~ |
| 28 |
'outer': events 1-2 |
| 29 |
| |
| 30 |
| NN | void outer (void) |
| 31 |
| | ^~~~~ |
| 32 |
| | | |
| 33 |
| | (1) entry to 'outer' |
| 34 |
|...... |
| 35 |
| NN | inner (); |
| 36 |
| | ~~~~~~~~ |
| 37 |
| | | |
| 38 |
| | (2) calling 'inner' from 'outer' |
| 39 |
| |
| 40 |
+--> 'inner': event 3 |
| 41 |
| |
| 42 |
| NN | static void inner (void) |
| 43 |
| | ^~~~~ |
| 44 |
| | | |
| 45 |
| | (3) entry to 'inner' |
| 46 |
| |
| 47 |
'inner': event 4 |
| 48 |
| |
| 49 |
| NN | SETJMP (env); |
| 50 |
| | ^~~~~~ |
| 51 |
| | | |
| 52 |
| | (4) 'setjmp' called here |
| 53 |
| |
| 54 |
'inner': event 5 |
| 55 |
| |
| 56 |
| NN | } |
| 57 |
| | ^ |
| 58 |
| | | |
| 59 |
| | (5) stack frame is popped here, invalidating saved environment |
| 60 |
| |
| 61 |
<------+ |
| 62 |
| |
| 63 |
'outer': events 6-7 |
| 64 |
| |
| 65 |
| NN | inner (); |
| 66 |
| | ^~~~~~~~ |
| 67 |
| | | |
| 68 |
| | (6) returning to 'outer' from 'inner' |
| 69 |
| NN | |
| 70 |
| NN | longjmp (env, 42); |
| 71 |
| | ~~~~~~~~~~~~~~~~~ |
| 72 |
| | | |
| 73 |
| | (7) 'longjmp' called after enclosing function of 'setjmp' returned at (5) |
| 74 |
| |
| 75 |
{ dg-end-multiline-output "" { target c } } */ |
| 76 |
/* { dg-begin-multiline-output "" } |
| 77 |
NN | longjmp (env, 42); |
| 78 |
| ~~~~~~~~^~~~~~~~~ |
| 79 |
'void outer()': events 1-2 |
| 80 |
| |
| 81 |
| NN | void outer (void) |
| 82 |
| | ^~~~~ |
| 83 |
| | | |
| 84 |
| | (1) entry to 'outer' |
| 85 |
|...... |
| 86 |
| NN | inner (); |
| 87 |
| | ~~~~~~~~ |
| 88 |
| | | |
| 89 |
| | (2) calling 'inner' from 'outer' |
| 90 |
| |
| 91 |
+--> 'void inner()': event 3 |
| 92 |
| |
| 93 |
| NN | static void inner (void) |
| 94 |
| | ^~~~~ |
| 95 |
| | | |
| 96 |
| | (3) entry to 'inner' |
| 97 |
| |
| 98 |
'void inner()': event 4 |
| 99 |
| |
| 100 |
| NN | SETJMP (env); |
| 101 |
| | ^~~~~~ |
| 102 |
| | | |
| 103 |
| | (4) 'setjmp' called here |
| 104 |
| |
| 105 |
'void inner()': event 5 |
| 106 |
| |
| 107 |
| NN | } |
| 108 |
| | ^ |
| 109 |
| | | |
| 110 |
| | (5) stack frame is popped here, invalidating saved environment |
| 111 |
| |
| 112 |
<------+ |
| 113 |
| |
| 114 |
'void outer()': events 6-7 |
| 115 |
| |
| 116 |
| NN | inner (); |
| 117 |
| | ~~~~~~^~ |
| 118 |
| | | |
| 119 |
| | (6) returning to 'outer' from 'inner' |
| 120 |
| NN | |
| 121 |
| NN | longjmp (env, 42); |
| 122 |
| | ~~~~~~~~~~~~~~~~~ |
| 123 |
| | | |
| 124 |
| | (7) 'longjmp' called after enclosing function of 'setjmp' returned at (5) |
| 125 |
| |
| 126 |
{ dg-end-multiline-output "" { target c++ } } */ |