(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
pr103217-2.c
       1  /* { dg-additional-options "-Wno-analyzer-too-complex" } */
       2  
       3  typedef __SIZE_TYPE__ size_t;
       4  
       5  extern void *calloc (size_t __nmemb, size_t __size)
       6    __attribute__ ((__nothrow__ , __leaf__, __malloc__, __alloc_size__ (1, 2)));
       7  
       8  extern char *strdup (const char *__s)
       9    __attribute__ ((__nothrow__ , __leaf__, __malloc__, __nonnull__ (1)));
      10  
      11  extern void abort (void)
      12    __attribute__ ((__nothrow__ , __leaf__, __noreturn__));
      13  
      14  extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
      15    __attribute__ ((__nothrow__ , __leaf__, __nonnull__ (2, 3)));
      16  extern char *optarg;
      17  
      18  extern void free (void *__ptr)
      19    __attribute__ ((__nothrow__ , __leaf__));
      20  
      21  char *xstrdup(const char *src) {
      22  	char *val = strdup(src);
      23  	if (!val)
      24  		abort();
      25  	return val;
      26  }
      27  
      28  struct test {
      29  	char *one, *two;
      30  };
      31  
      32  int main(int argc, char *argv[]) {
      33  	struct test *options = calloc(1, sizeof(*options));
      34  	int rc;
      35  	if (!options)
      36  		abort();
      37  
      38  	while ((rc = getopt(argc, argv, "a:b:")) != -1) {
      39  		switch (rc) {
      40  		case 'a':
      41  			free(options->one);
      42  			options->one = xstrdup(optarg);
      43  			break;
      44  		case 'b':
      45  			free(options->two);
      46  			options->two = xstrdup(optarg);
      47  			break;
      48  		}
      49  	}
      50  	free(options->one);
      51  	free(options->two);
      52  	free(options);
      53  	return 0;
      54  }