xref: /llvm-project/clang/test/Index/ms-if-exists.cpp (revision f44bac2b4cc976bbf3002e660e495e5c4f73490a)
1deb4a2beSDouglas Gregor template<typename T>
f(T t)2deb4a2beSDouglas Gregor void f(T t) {
3deb4a2beSDouglas Gregor   __if_exists(T::foo) {
4deb4a2beSDouglas Gregor     { }
5deb4a2beSDouglas Gregor     t.foo();
6deb4a2beSDouglas Gregor   }
7deb4a2beSDouglas Gregor 
8deb4a2beSDouglas Gregor   __if_not_exists(T::bar) {
9deb4a2beSDouglas Gregor     int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
10deb4a2beSDouglas Gregor     { }
11deb4a2beSDouglas Gregor   }
12deb4a2beSDouglas Gregor }
13deb4a2beSDouglas Gregor 
14*f44bac2bSDouglas Gregor // RUN: c-index-test -test-annotate-tokens=%s:3:1:11:3 -fms-extensions -fno-ms-compatibility -fno-delayed-template-parsing %s | FileCheck %s
15deb4a2beSDouglas Gregor 
16deb4a2beSDouglas Gregor // CHECK: Identifier: "T" [3:15 - 3:16] TypeRef=T:1:19
17deb4a2beSDouglas Gregor // CHECK: Punctuation: "}" [4:7 - 4:8] CompoundStmt=
18deb4a2beSDouglas Gregor // CHECK: Identifier: "t" [5:5 - 5:6] DeclRefExpr=t:2:10
19deb4a2beSDouglas Gregor // CHECK: Punctuation: "." [5:6 - 5:7] MemberRefExpr=
20deb4a2beSDouglas Gregor // CHECK: Identifier: "foo" [5:7 - 5:10] MemberRefExpr=
21deb4a2beSDouglas Gregor // CHECK: Keyword: "int" [9:5 - 9:8] VarDecl=i:9:10 (Definition)
22deb4a2beSDouglas Gregor // CHECK: Punctuation: "*" [9:9 - 9:10] VarDecl=i:9:10 (Definition)
23deb4a2beSDouglas Gregor // CHECK: Identifier: "i" [9:10 - 9:11] VarDecl=i:9:10 (Definition)
24deb4a2beSDouglas Gregor // CHECK: Punctuation: "=" [9:12 - 9:13] VarDecl=i:9:10 (Definition)
25