diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/Sema/generic-selection.c | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/Sema/generic-selection.c')
-rw-r--r-- | clang/test/Sema/generic-selection.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/test/Sema/generic-selection.c b/clang/test/Sema/generic-selection.c new file mode 100644 index 0000000..8cef975 --- /dev/null +++ b/clang/test/Sema/generic-selection.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s + +void foo(int n) { + (void) _Generic(0, + struct A: 0, // expected-error {{type 'struct A' in generic association incomplete}} + void(): 0, // expected-error {{type 'void ()' in generic association not an object type}} + int[n]: 0); // expected-error {{type 'int [n]' in generic association is a variably modified type}} + + (void) _Generic(0, + void (*)(): 0, // expected-note {{compatible type 'void (*)()' specified here}} + void (*)(void): 0); // expected-error {{type 'void (*)(void)' in generic association compatible with previously specified type 'void (*)()'}} + + (void) _Generic((void (*)()) 0, // expected-error {{controlling expression type 'void (*)()' compatible with 2 generic association types}} + void (*)(int): 0, // expected-note {{compatible type 'void (*)(int)' specified here}} + void (*)(void): 0); // expected-note {{compatible type 'void (*)(void)' specified here}} + + (void) _Generic(0, // expected-error {{controlling expression type 'int' not compatible with any generic association type}} + char: 0, short: 0, long: 0); + + int a1[_Generic(0, int: 1, short: 2, float: 3, default: 4) == 1 ? 1 : -1]; + int a2[_Generic(0, default: 1, short: 2, float: 3, int: 4) == 4 ? 1 : -1]; + int a3[_Generic(0L, int: 1, short: 2, float: 3, default: 4) == 4 ? 1 : -1]; + int a4[_Generic(0L, default: 1, short: 2, float: 3, int: 4) == 1 ? 1 : -1]; + int a5[_Generic(0, int: 1, short: 2, float: 3) == 1 ? 1 : -1]; + int a6[_Generic(0, short: 1, float: 2, int: 3) == 3 ? 1 : -1]; +} |