Fix cexpl when compiled with latest GCC
[glibc.git] / argp / bug-argp2.c
blob133e5cf6e8cb6c9679fa29edb3d16859f8cc5443
1 #include <argp.h>
2 #include <stdio.h>
3 #include <stdlib.h>
5 static struct argp_option argp_options[] = {
6 { "dstaddr", 'd', "ADDR", 0,
7 "set destination (peer) address to ADDR" },
8 { "peer", 'p', "ADDR", OPTION_ALIAS },
9 { NULL }
12 static error_t parse_opt (int key, char *arg, struct argp_state *state);
14 static struct argp argp =
16 argp_options, parse_opt
19 static int cnt;
21 static int
22 do_test (int argc, char *argv[])
24 int remaining;
25 argp_parse (&argp, argc, argv, 0, &remaining, NULL);
26 return cnt != 4;
29 static error_t
30 parse_opt (int key, char *arg, struct argp_state *state)
32 switch (key)
34 case 'd':
35 case 'p':
36 printf ("got '%c' with argument '%s'\n", key, arg);
37 ++cnt;
38 break;
39 case 0:
40 case ARGP_KEY_END:
41 case ARGP_KEY_NO_ARGS:
42 case ARGP_KEY_INIT:
43 case ARGP_KEY_SUCCESS:
44 case ARGP_KEY_FINI:
45 // Ignore.
46 return ARGP_ERR_UNKNOWN;
47 default:
48 printf ("invalid key '%x'\n", key);
49 exit (1);
51 return 0;
54 #define TEST_FUNCTION do_test (argc, argv)
55 #include "../test-skeleton.c"