blob: 7dd20544a6b4d6ad3b633cac7bb72f5a346d79cd [file] [log] [blame]
Nico Rieckdfff5d22014-11-24 17:29:35 +00001// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
2// expected-no-diagnostics
3
4struct Type {
5};
6
7void test_if_exists_stmts() {
8 int b = 0;
9 __if_exists(Type) {
10 b++;
11 b++;
12 }
13 __if_exists(Type_not) {
14 this will not compile.
15 }
16 __if_not_exists(Type) {
17 this will not compile.
18 }
19 __if_not_exists(Type_not) {
20 b++;
21 b++;
22 }
23}
24
25int if_exists_creates_no_scope() {
26 __if_exists(Type) {
27 int x; // 'x' is declared in the parent scope.
28 }
29 __if_not_exists(Type_not) {
30 x++;
31 }
32 return x;
33}
34
35__if_exists(Type) {
36 int var23;
37}
38
39__if_exists(Type_not) {
40 this will not compile.
41}
42
43__if_not_exists(Type) {
44 this will not compile.
45}
46
47__if_not_exists(Type_not) {
48 int var244;
49}
50
51void test_if_exists_init_list() {
52
53 int array1[] = {
54 0,
55 __if_exists(Type) {2, }
56 3
57 };
58
59 int array2[] = {
60 0,
61 __if_exists(Type_not) { this will not compile }
62 3
63 };
64
65 int array3[] = {
66 0,
67 __if_not_exists(Type_not) {2, }
68 3
69 };
70
71 int array4[] = {
72 0,
73 __if_not_exists(Type) { this will not compile }
74 3
75 };
76
77}
78
79
80void test_nested_if_exists() {
81 __if_exists(Type) {
82 int x = 42;
83 __if_not_exists(Type_not) {
84 x++;
85 }
86 }
87}