blob: 62176bdaee89b4b49053b56ec2b59f5c5da46973 (
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
|
/* As pr94851-1.c, but verify that we don't get confused by a call to
an unknown function (PR analyzer/98575). */
/* { dg-additional-options "-O2" } */
#include <stdio.h>
#include <stdlib.h>
typedef struct AMARK {
struct AMARK *m_next;
char m_name;
} AMARK;
struct buf {
AMARK *b_amark;
};
struct buf *curbp;
extern void unknown_fn (void);
int pamark(void) {
int c;
AMARK *p = curbp->b_amark;
AMARK *last = curbp->b_amark;
unknown_fn ();
c = getchar ();
while (p != (AMARK *)NULL && p->m_name != (char)c) {
last = p;
p = p->m_next;
}
if (p != (AMARK *)NULL) {
printf("over writing mark %c\n", c);
} else {
if ((p = (AMARK *)malloc(sizeof(AMARK))) == (AMARK *)NULL)
return 0;
p->m_next = (AMARK *)NULL;
if (curbp->b_amark == (AMARK *)NULL)
curbp->b_amark = p;
else
last->m_next = p; /* { dg-warning "dereference of NULL 'last'" "deref" } */
}
p->m_name = (char)c; /* { dg-bogus "leak of 'p'" "bogus leak" } */
return 1;
}
|