| 1 |
/* { dg-additional-options "-Wno-analyzer-too-complex" } */ |
| 2 |
/* TODO: remove the need for -Wno-analyzer-too-complex. */ |
| 3 |
|
| 4 |
struct lisp; |
| 5 |
union vectorlike_header { long size; }; |
| 6 |
|
| 7 |
static struct lisp * |
| 8 |
make_lisp_ptr (void *ptr, int type) |
| 9 |
{ |
| 10 |
char *p = ptr; |
| 11 |
void *q = p + type; |
| 12 |
return q; |
| 13 |
} |
| 14 |
|
| 15 |
static _Bool |
| 16 |
TAGGEDP (struct lisp *a, unsigned tag) |
| 17 |
{ |
| 18 |
return ! (((unsigned) (__INTPTR_TYPE__) a - tag) & 7); |
| 19 |
} |
| 20 |
|
| 21 |
static _Bool |
| 22 |
VECTORLIKEP (struct lisp *x) |
| 23 |
{ |
| 24 |
return TAGGEDP (x, 5); |
| 25 |
} |
| 26 |
|
| 27 |
extern _Bool |
| 28 |
PSEUDOVECTOR_TYPEP (union vectorlike_header const *a, int code); |
| 29 |
|
| 30 |
static _Bool |
| 31 |
PSEUDOVECTORP (struct lisp *a, int code) |
| 32 |
{ |
| 33 |
if (! VECTORLIKEP (a)) |
| 34 |
return 0; |
| 35 |
else |
| 36 |
return PSEUDOVECTOR_TYPEP ((union vectorlike_header *) ((char *) a - 5), |
| 37 |
code); |
| 38 |
} |
| 39 |
|
| 40 |
struct Lisp_Overlay |
| 41 |
{ |
| 42 |
union vectorlike_header header; |
| 43 |
struct lisp *end; |
| 44 |
struct Lisp_Overlay *next; |
| 45 |
}; |
| 46 |
|
| 47 |
static _Bool |
| 48 |
OVERLAYP (struct lisp *x) |
| 49 |
{ |
| 50 |
return PSEUDOVECTORP (x, 4); |
| 51 |
} |
| 52 |
|
| 53 |
static struct Lisp_Overlay * |
| 54 |
XOVERLAY (struct lisp *a) |
| 55 |
{ |
| 56 |
void *r = (char *) a - 5; |
| 57 |
return r; |
| 58 |
} |
| 59 |
struct buffer { struct Lisp_Overlay *overlays_before; }; |
| 60 |
|
| 61 |
long marker_position (struct lisp *); |
| 62 |
|
| 63 |
void |
| 64 |
fix_overlays_before (struct buffer *bp, long prev, long pos) |
| 65 |
{ |
| 66 |
struct Lisp_Overlay *tail = bp->overlays_before, *parent = 0, *right_pair; |
| 67 |
struct lisp *tem; |
| 68 |
long end; |
| 69 |
while (tail |
| 70 |
&& (tem = make_lisp_ptr (tail, 5), |
| 71 |
(end = marker_position (XOVERLAY (tem)->end)) >= pos)) |
| 72 |
{ |
| 73 |
parent = tail; |
| 74 |
tail = tail->next; |
| 75 |
} |
| 76 |
if (!tail || end < prev || !tail->next) /* { dg-bogus "use of uninitialized value 'end'" "uninit" } */ |
| 77 |
/* { dg-bogus "dereference of NULL 'tail'" "null deref" { target *-*-* } .-1 } */ |
| 78 |
return; |
| 79 |
right_pair = parent; |
| 80 |
parent = tail; |
| 81 |
tail = tail->next; |
| 82 |
while (tail) |
| 83 |
{ |
| 84 |
tem = make_lisp_ptr (tail, 5); |
| 85 |
end = marker_position (XOVERLAY (tem)->end); |
| 86 |
if (end == pos) |
| 87 |
{ |
| 88 |
struct Lisp_Overlay *found = tail; |
| 89 |
tail = found->next; |
| 90 |
parent->next = tail; |
| 91 |
if (!right_pair) |
| 92 |
{ |
| 93 |
found->next = bp->overlays_before; |
| 94 |
bp->overlays_before = found; |
| 95 |
} |
| 96 |
else |
| 97 |
{ |
| 98 |
found->next = right_pair->next; |
| 99 |
right_pair->next = found; |
| 100 |
} |
| 101 |
} |
| 102 |
else if (end == prev) |
| 103 |
{ |
| 104 |
parent = tail; |
| 105 |
tail = tail->next; |
| 106 |
} |
| 107 |
else |
| 108 |
break; |
| 109 |
} |
| 110 |
} |