brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 66b8542 Raw
88 lines · c
1// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions2// expected-no-diagnostics3 4struct Type {5};6 7void test_if_exists_stmts(void) {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(void) {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(void) {52 53  int array1[] = {54    0,55    __if_exists(Type) {2, }56    357  };58 59  int array2[] = {60    0,61    __if_exists(Type_not) { this will not compile }62    363  };64 65  int array3[] = {66    0,67    __if_not_exists(Type_not) {2, }68    369  };70 71  int array4[] = {72    0,73    __if_not_exists(Type) { this will not compile }74    375  };76 77}78 79 80void test_nested_if_exists(void) {81  __if_exists(Type) {82    int x = 42;83    __if_not_exists(Type_not) {84      x++;85    }86  }87}88