llvm-project
87 строк · 1.2 Кб
1// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
2// expected-no-diagnostics
3
4struct Type {5};6
7void test_if_exists_stmts(void) {8int b = 0;9__if_exists(Type) {10b++;11b++;12}13__if_exists(Type_not) {14this will not compile.15}16__if_not_exists(Type) {17this will not compile.18}19__if_not_exists(Type_not) {20b++;21b++;22}23}
24
25int if_exists_creates_no_scope(void) {26__if_exists(Type) {27int x; // 'x' is declared in the parent scope.28}29__if_not_exists(Type_not) {30x++;31}32return x;33}
34
35__if_exists(Type) {36int var23;37}
38
39__if_exists(Type_not) {40this will not compile.41}
42
43__if_not_exists(Type) {44this will not compile.45}
46
47__if_not_exists(Type_not) {48int var244;49}
50
51void test_if_exists_init_list(void) {52
53int array1[] = {540,55__if_exists(Type) {2, }56357};58
59int array2[] = {600,61__if_exists(Type_not) { this will not compile }62363};64
65int array3[] = {660,67__if_not_exists(Type_not) {2, }68369};70
71int array4[] = {720,73__if_not_exists(Type) { this will not compile }74375};76
77}
78
79
80void test_nested_if_exists(void) {81__if_exists(Type) {82int x = 42;83__if_not_exists(Type_not) {84x++;85}86}87}
88