1 /* { dg-additional-options "-Wno-analyzer-too-complex" } */
2
3 extern char *strdup (const char *__s)
4 __attribute__ ((__nothrow__ , __leaf__, __malloc__, __nonnull__ (1)));
5
6 extern void abort (void)
7 __attribute__ ((__nothrow__ , __leaf__, __noreturn__));
8
9 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
10 __attribute__ ((__nothrow__ , __leaf__, __nonnull__ (2, 3)));
11 extern char *optarg;
12
13 extern void free (void *__ptr)
14 __attribute__ ((__nothrow__ , __leaf__));
15
16 #define NULL ((void *)0)
17
18 char *xstrdup(const char *src) {
19 char *val = strdup(src);
20 if (!val)
21 abort();
22 return val;
23 }
24
25 int main(int argc, char *argv[]) {
26 char *one = NULL, *two = NULL;
27 int rc;
28
29 while ((rc = getopt(argc, argv, "a:b:")) != -1) {
30 switch (rc) {
31 case 'a':
32 free(one);
33 one = xstrdup(optarg);
34 break;
35 case 'b':
36 free(two);
37 two = xstrdup(optarg);
38 break;
39 }
40 }
41 free(one);
42 free(two);
43 return 0;
44 }