Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Parser / ms-if-exists.cpp
blob79cc571a357ff9a408b9e7931b64017f9c4c4729
1 // RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -Wmicrosoft -verify -fms-extensions
3 class MayExist {
4 private:
5 typedef int Type;
6 };
8 void test_if_exists_stmts() {
9 int b = 0;
10 __if_exists(MayExist::Type) {
11 b++;
12 b++;
14 __if_exists(MayExist::Type_not) {
15 this will not compile.
17 __if_not_exists(MayExist::Type) {
18 this will not compile.
20 __if_not_exists(MayExist::Type_not) {
21 b++;
22 b++;
26 int if_exists_creates_no_scope() {
27 __if_exists(MayExist::Type) {
28 int x; // 'x' is declared in the parent scope.
30 __if_not_exists(MayExist::Type_not) {
31 x++;
33 return x;
36 __if_exists(MayExist::Type) {
37 int var23;
40 __if_exists(MayExist::Type_not) {
41 this will not compile.
44 __if_not_exists(MayExist::Type) {
45 this will not compile.
48 __if_not_exists(MayExist::Type_not) {
49 int var244;
52 void test_if_exists_init_list() {
54 int array1[] = {
56 __if_exists(MayExist::Type) {2, }
60 int array2[] = {
62 __if_exists(MayExist::Type_not) { this will not compile }
66 int array3[] = {
68 __if_not_exists(MayExist::Type_not) {2, }
72 int array4[] = {
74 __if_not_exists(MayExist::Type) { this will not compile }
81 class IfExistsClassScope {
82 __if_exists(MayExist::Type) {
83 // __if_exists, __if_not_exists can nest
84 __if_not_exists(MayExist::Type_not) {
85 int var123;
87 int var23;
90 __if_exists(MayExist::Type_not) {
91 this will not compile.
94 __if_not_exists(MayExist::Type) {
95 this will not compile.
98 __if_not_exists(MayExist::Type_not) {
99 int var244;
103 void test_nested_if_exists() {
104 __if_exists(MayExist::Type) {
105 int x = 42;
106 __if_not_exists(MayExist::Type_not) {
107 x++;
112 void test_attribute_on_if_exists() {
113 [[clang::fallthrough]] // expected-error {{an attribute list cannot appear here}}
114 __if_exists(MayExist::Type) {
115 int x;