| 1 |
/* { dg-additional-options "-Wno-analyzer-fd-leak" } */ |
| 2 |
// TODO: remove need for this option |
| 3 |
/* C only: C++ does not support transparent_union. */ |
| 4 |
|
| 5 |
typedef __SIZE_TYPE__ size_t; |
| 6 |
#define NULL ((void *)0) |
| 7 |
#define POLLIN 0x001 |
| 8 |
|
| 9 |
typedef struct { |
| 10 |
unsigned long int __val[(1024 / (8 * sizeof(unsigned long int)))]; |
| 11 |
} __sigset_t; |
| 12 |
|
| 13 |
typedef unsigned int socklen_t; |
| 14 |
|
| 15 |
struct timespec { |
| 16 |
/* [...snip...] */ |
| 17 |
}; |
| 18 |
|
| 19 |
typedef unsigned long int nfds_t; |
| 20 |
|
| 21 |
struct pollfd { |
| 22 |
int fd; |
| 23 |
short int events; |
| 24 |
short int revents; |
| 25 |
}; |
| 26 |
|
| 27 |
extern int ppoll(struct pollfd *__fds, nfds_t __nfds, |
| 28 |
const struct timespec *__timeout, const __sigset_t *__ss); |
| 29 |
|
| 30 |
struct sockaddr_un { |
| 31 |
/* [...snip...] */ |
| 32 |
char sun_path[108]; |
| 33 |
}; |
| 34 |
|
| 35 |
typedef union { |
| 36 |
/* [...snip...] */ |
| 37 |
struct sockaddr_un *__restrict __sockaddr_un__; |
| 38 |
/* [...snip...] */ |
| 39 |
} __SOCKADDR_ARG __attribute__((transparent_union)); |
| 40 |
|
| 41 |
extern int accept(int __fd, __SOCKADDR_ARG __addr, |
| 42 |
socklen_t *__restrict __addr_len); |
| 43 |
|
| 44 |
extern void *calloc(size_t __nmemb, size_t __size) |
| 45 |
__attribute__((__nothrow__, __leaf__)) |
| 46 |
__attribute__((__malloc__)) |
| 47 |
__attribute__((__alloc_size__(1, 2))); |
| 48 |
|
| 49 |
extern void *realloc(void *__ptr, size_t __size) |
| 50 |
__attribute__((__nothrow__, __leaf__)) |
| 51 |
__attribute__((__warn_unused_result__)) |
| 52 |
__attribute__((__alloc_size__(2))); |
| 53 |
|
| 54 |
extern void exit(int __status) |
| 55 |
__attribute__((__nothrow__, __leaf__)) |
| 56 |
__attribute__((__noreturn__)); |
| 57 |
|
| 58 |
int main() { |
| 59 |
int rc; |
| 60 |
int nsockets = 1; |
| 61 |
struct pollfd *pollfds, *newpollfds; |
| 62 |
struct sockaddr_un remote; |
| 63 |
socklen_t len = sizeof(remote); |
| 64 |
|
| 65 |
pollfds = (struct pollfd *) calloc(1, sizeof(struct pollfd)); |
| 66 |
if (!pollfds) { |
| 67 |
exit(1); |
| 68 |
} |
| 69 |
|
| 70 |
rc = ppoll(pollfds, nsockets, NULL, NULL); |
| 71 |
if (rc < 0) { |
| 72 |
exit(2); |
| 73 |
} |
| 74 |
|
| 75 |
nsockets++; |
| 76 |
newpollfds = (struct pollfd *) realloc(pollfds, nsockets * sizeof(*pollfds)); |
| 77 |
if (!newpollfds) { |
| 78 |
exit(3); |
| 79 |
} |
| 80 |
pollfds = newpollfds; |
| 81 |
pollfds[nsockets - 1].fd = accept(pollfds[0].fd, &remote, &len); |
| 82 |
/* { dg-error "could not convert '& remote' from 'sockaddr_un*' to '__SOCKADDR_ARG'" "G++ doesn't support transparent_union" { target c++ } .-1 } */ |
| 83 |
|
| 84 |
exit(4); |
| 85 |
} |