| 1 |
/* { dg-additional-options "-fanalyzer-call-summaries -Wno-analyzer-symbol-too-complex" } */ |
| 2 |
|
| 3 |
typedef __SIZE_TYPE__ size_t; |
| 4 |
enum { _ISspace = ((5) < 8 ? ((1 << (5)) << 8) : ((1 << (5)) >> 8)) }; |
| 5 |
extern const unsigned short int **__ctype_b_loc(void) |
| 6 |
__attribute__((__nothrow__, __leaf__, __const__)); |
| 7 |
extern void *malloc(size_t __size) |
| 8 |
__attribute__((__nothrow__, __leaf__, __malloc__, __alloc_size__(1))); |
| 9 |
extern char *strcpy(char *__restrict __dest, const char *__restrict __src) |
| 10 |
__attribute__((__nothrow__, __leaf__, __nonnull__(1, 2))); |
| 11 |
extern size_t strlen(const char *__s) |
| 12 |
__attribute__((__nothrow__, __leaf__, __pure__, __nonnull__(1))); |
| 13 |
|
| 14 |
struct mydata { |
| 15 |
struct mydata *link; |
| 16 |
char *name; |
| 17 |
char *type; |
| 18 |
}; |
| 19 |
|
| 20 |
static struct mydata *all_data; |
| 21 |
static int line_no; |
| 22 |
|
| 23 |
__attribute__((__noreturn__)) void failed(const char *message); |
| 24 |
|
| 25 |
static char *string_dup(const char *string) { |
| 26 |
char *buf; |
| 27 |
|
| 28 |
if ((buf = (char *) malloc(strlen(string) + 1)) == ((void *)0)) |
| 29 |
failed("malloc() failed"); |
| 30 |
|
| 31 |
return strcpy(buf, string); |
| 32 |
} |
| 33 |
|
| 34 |
static void store_data(const char *name, const char *type) { |
| 35 |
struct mydata *p, *q; |
| 36 |
|
| 37 |
if ((p = (struct mydata *)malloc(sizeof(struct mydata))) == ((void *)0)) |
| 38 |
failed("malloc() failed"); |
| 39 |
|
| 40 |
p->link = (struct mydata *)((void *)0); |
| 41 |
p->name = string_dup(name); |
| 42 |
p->type = string_dup(type); |
| 43 |
|
| 44 |
if ((q = all_data) == ((void *)0)) |
| 45 |
all_data = p; |
| 46 |
else { |
| 47 |
while (q->link != ((void *)0)) |
| 48 |
q = q->link; |
| 49 |
q->link = p; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
static void parse_tbl(char *buffer) { |
| 54 |
char *s = buffer; |
| 55 |
char *t = s + strlen(s); |
| 56 |
|
| 57 |
do { |
| 58 |
t--; |
| 59 |
if (((*__ctype_b_loc())[(int)(((int)*t))] & (unsigned short int)_ISspace)) |
| 60 |
*t = '\0'; |
| 61 |
else |
| 62 |
break; |
| 63 |
} while (t > s); |
| 64 |
while (((*__ctype_b_loc())[(int)(((int)*s))] & (unsigned short int)_ISspace)) |
| 65 |
s++; |
| 66 |
buffer = s; |
| 67 |
|
| 68 |
line_no++; |
| 69 |
if (*buffer != ';' && *buffer != '\0') { |
| 70 |
if (*buffer == '#') { |
| 71 |
store_data(buffer, ""); /* { dg-bogus "leak" "PR analyzer/107158" { xfail *-*-* } } */ |
| 72 |
} else { |
| 73 |
|
| 74 |
while (*s && !((*__ctype_b_loc())[(int)(((int)*s))] & |
| 75 |
(unsigned short int)_ISspace)) |
| 76 |
s++; |
| 77 |
while ( |
| 78 |
((*__ctype_b_loc())[(int)(((int)*s))] & (unsigned short int)_ISspace)) |
| 79 |
*s++ = '\0'; |
| 80 |
store_data(buffer, s); /* { dg-bogus "leak" "PR analyzer/107158" { xfail *-*-* } } */ |
| 81 |
} |
| 82 |
} |
| 83 |
} |