Testsuite: fix analyzer tests on Darwin
[official-gcc.git] / gcc / testsuite / gcc.dg / analyzer / pr103217-3.c
blobe5f1e4bd62d1900452de4dafe9132049d5620fb0
1 /* { dg-additional-options "-Wno-analyzer-too-complex" } */
3 extern char *strdup (const char *__s)
4 __attribute__ ((__nothrow__ , __leaf__, __malloc__, __nonnull__ (1)));
6 extern void abort (void)
7 __attribute__ ((__nothrow__ , __leaf__, __noreturn__));
9 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
10 __attribute__ ((__nothrow__ , __leaf__, __nonnull__ (2, 3)));
11 extern char *optarg;
13 extern void free (void *__ptr)
14 __attribute__ ((__nothrow__ , __leaf__));
16 struct state {
17 const char *confpath;
18 const char *host;
19 const char *port;
20 const char *state_dir_prefix;
23 static inline char *xstrdup(const char *s) {
24 char *val = strdup(s);
25 if (!val)
26 abort();
27 return val;
30 int config_init(struct state *config);
32 int main(int argc, char *argv[]) {
33 int rc;
34 struct state state = { 0 };
36 config_init(&state);
38 while ((rc = getopt(argc, argv, "H:p:")) != -1) {
39 switch (rc) {
40 case 'H':
41 free((void*)state.host);
42 state.host = xstrdup(optarg);
43 break;
44 case 'p':
45 free((void*)state.port);
46 state.port = xstrdup(optarg);
47 break;
51 free((void*)state.host);
52 free((void*)state.port);
53 return rc;