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