(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
c11-generic-2.c
       1  /* Test C11 _Generic.  Error cases.  */
       2  /* { dg-do compile } */
       3  /* { dg-options "-std=c11 -pedantic-errors" } */
       4  
       5  struct incomplete;
       6  
       7  void
       8  f (int n)
       9  {
      10    /* Multiple 'default's.  */
      11    _Generic (n, default: 1, default: 2); /* { dg-error "duplicate .*default.* case" } */
      12  
      13    /* Variably-modified type not ok.  */
      14    _Generic (n, int[n]: 0, default: 1);	/* { dg-error "variable length type" } */
      15    /* Type must be complete.  */
      16    _Generic (n, struct incomplete: 0, default: 1); /* { dg-error "incomplete type" } */
      17    _Generic (n, void: 0, default: 1); /* { dg-error "incomplete type" } */
      18  
      19    /* Type must be object type.  */
      20    _Generic (n, void (void): 0, default: 1); /* { dg-error "function type" } */
      21  
      22    /* Two compatible types in association list.  */
      23    _Generic (&n, int: 5, signed int: 7, default: 23); /* { dg-error "two compatible types" } */
      24  
      25    /* No matching association.  */
      26    _Generic (n, void *: 5);	/* { dg-error "not compatible with any association" } */
      27  }