1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc
foo(int n)3*f4a2713aSLionel Sambuc void foo(int n) {
4*f4a2713aSLionel Sambuc (void) _Generic(0,
5*f4a2713aSLionel Sambuc struct A: 0, // expected-error {{type 'struct A' in generic association incomplete}}
6*f4a2713aSLionel Sambuc void(): 0, // expected-error {{type 'void ()' in generic association not an object type}}
7*f4a2713aSLionel Sambuc int[n]: 0); // expected-error {{type 'int [n]' in generic association is a variably modified type}}
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambuc (void) _Generic(0,
10*f4a2713aSLionel Sambuc void (*)(): 0, // expected-note {{compatible type 'void (*)()' specified here}}
11*f4a2713aSLionel Sambuc void (*)(void): 0); // expected-error {{type 'void (*)(void)' in generic association compatible with previously specified type 'void (*)()'}}
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambuc (void) _Generic((void (*)()) 0, // expected-error {{controlling expression type 'void (*)()' compatible with 2 generic association types}}
14*f4a2713aSLionel Sambuc void (*)(int): 0, // expected-note {{compatible type 'void (*)(int)' specified here}}
15*f4a2713aSLionel Sambuc void (*)(void): 0); // expected-note {{compatible type 'void (*)(void)' specified here}}
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc (void) _Generic(0, // expected-error {{controlling expression type 'int' not compatible with any generic association type}}
18*f4a2713aSLionel Sambuc char: 0, short: 0, long: 0);
19*f4a2713aSLionel Sambuc
20*f4a2713aSLionel Sambuc int a1[_Generic(0, int: 1, short: 2, float: 3, default: 4) == 1 ? 1 : -1];
21*f4a2713aSLionel Sambuc int a2[_Generic(0, default: 1, short: 2, float: 3, int: 4) == 4 ? 1 : -1];
22*f4a2713aSLionel Sambuc int a3[_Generic(0L, int: 1, short: 2, float: 3, default: 4) == 4 ? 1 : -1];
23*f4a2713aSLionel Sambuc int a4[_Generic(0L, default: 1, short: 2, float: 3, int: 4) == 1 ? 1 : -1];
24*f4a2713aSLionel Sambuc int a5[_Generic(0, int: 1, short: 2, float: 3) == 1 ? 1 : -1];
25*f4a2713aSLionel Sambuc int a6[_Generic(0, short: 1, float: 2, int: 3) == 3 ? 1 : -1];
26*f4a2713aSLionel Sambuc }
27