File: ms-if-exists.cpp

package info (click to toggle)
llvm-toolchain-6.0 1%3A6.0.1-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 598,080 kB
  • sloc: cpp: 3,046,253; ansic: 595,057; asm: 271,965; python: 128,926; objc: 106,554; sh: 21,906; lisp: 10,191; pascal: 6,094; ml: 5,544; perl: 5,265; makefile: 2,227; cs: 2,027; xml: 686; php: 212; csh: 117
file content (24 lines) | stat: -rw-r--r-- 898 bytes parent folder | download | duplicates (38)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
template<typename T>
void f(T t) {
  __if_exists(T::foo) {
    { }
    t.foo();
  }

  __if_not_exists(T::bar) {
    int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
    { }
  }
}

// RUN: c-index-test -test-annotate-tokens=%s:3:1:11:3 -fms-extensions -fno-ms-compatibility -fno-delayed-template-parsing %s | FileCheck %s

// CHECK: Identifier: "T" [3:15 - 3:16] TypeRef=T:1:19
// CHECK: Punctuation: "}" [4:7 - 4:8] CompoundStmt=
// CHECK: Identifier: "t" [5:5 - 5:6] DeclRefExpr=t:2:10
// CHECK: Punctuation: "." [5:6 - 5:7] MemberRefExpr=
// CHECK: Identifier: "foo" [5:7 - 5:10] MemberRefExpr=
// CHECK: Keyword: "int" [9:5 - 9:8] VarDecl=i:9:10 (Definition)
// CHECK: Punctuation: "*" [9:9 - 9:10] VarDecl=i:9:10 (Definition)
// CHECK: Identifier: "i" [9:10 - 9:11] VarDecl=i:9:10 (Definition)
// CHECK: Punctuation: "=" [9:12 - 9:13] VarDecl=i:9:10 (Definition)