xref: /llvm-project/clang/test/Index/binop.cpp (revision a972a394afcb276abb3029d0f2753d4403e379c2)
1*a972a394SThomas Wucher // RUN: c-index-test -test-print-binops %s | FileCheck %s
2*a972a394SThomas Wucher 
3*a972a394SThomas Wucher struct C {
4*a972a394SThomas Wucher   int m;
5*a972a394SThomas Wucher };
6*a972a394SThomas Wucher 
7*a972a394SThomas Wucher void func(void) {
8*a972a394SThomas Wucher #pragma clang diagnostic push
9*a972a394SThomas Wucher #pragma clang diagnostic ignored "-Wunused-value"
10*a972a394SThomas Wucher   int a, b;
11*a972a394SThomas Wucher   int C::*p = &C::m;
12*a972a394SThomas Wucher 
13*a972a394SThomas Wucher   C c;
14*a972a394SThomas Wucher   c.*p;
15*a972a394SThomas Wucher 
16*a972a394SThomas Wucher   C *pc;
17*a972a394SThomas Wucher   pc->*p;
18*a972a394SThomas Wucher 
19*a972a394SThomas Wucher   a *b;
20*a972a394SThomas Wucher   a / b;
21*a972a394SThomas Wucher   a % b;
22*a972a394SThomas Wucher   a + b;
23*a972a394SThomas Wucher   a - b;
24*a972a394SThomas Wucher 
25*a972a394SThomas Wucher   a << b;
26*a972a394SThomas Wucher   a >> b;
27*a972a394SThomas Wucher 
28*a972a394SThomas Wucher   a < b;
29*a972a394SThomas Wucher   a > b;
30*a972a394SThomas Wucher 
31*a972a394SThomas Wucher   a <= b;
32*a972a394SThomas Wucher   a >= b;
33*a972a394SThomas Wucher   a == b;
34*a972a394SThomas Wucher   a != b;
35*a972a394SThomas Wucher 
36*a972a394SThomas Wucher   a &b;
37*a972a394SThomas Wucher   a ^ b;
38*a972a394SThomas Wucher   a | b;
39*a972a394SThomas Wucher 
40*a972a394SThomas Wucher   a &&b;
41*a972a394SThomas Wucher   a || b;
42*a972a394SThomas Wucher 
43*a972a394SThomas Wucher   a = b;
44*a972a394SThomas Wucher 
45*a972a394SThomas Wucher   a *= b;
46*a972a394SThomas Wucher   a /= b;
47*a972a394SThomas Wucher   a %= b;
48*a972a394SThomas Wucher   a += b;
49*a972a394SThomas Wucher   a -= b;
50*a972a394SThomas Wucher 
51*a972a394SThomas Wucher   a <<= b;
52*a972a394SThomas Wucher   a >>= b;
53*a972a394SThomas Wucher 
54*a972a394SThomas Wucher   a &= b;
55*a972a394SThomas Wucher   a ^= b;
56*a972a394SThomas Wucher   a |= b;
57*a972a394SThomas Wucher   a, b;
58*a972a394SThomas Wucher #pragma clang diagnostic pop
59*a972a394SThomas Wucher }
60*a972a394SThomas Wucher 
61*a972a394SThomas Wucher // CHECK: BinaryOperator=.* BinOp=.* 1
62*a972a394SThomas Wucher // CHECK: BinaryOperator=->* BinOp=->* 2
63*a972a394SThomas Wucher // CHECK: BinaryOperator=* BinOp=* 3
64*a972a394SThomas Wucher // CHECK: BinaryOperator=/ BinOp=/ 4
65*a972a394SThomas Wucher // CHECK: BinaryOperator=% BinOp=% 5
66*a972a394SThomas Wucher // CHECK: BinaryOperator=+ BinOp=+ 6
67*a972a394SThomas Wucher // CHECK: BinaryOperator=- BinOp=- 7
68*a972a394SThomas Wucher // CHECK: BinaryOperator=<< BinOp=<< 8
69*a972a394SThomas Wucher // CHECK: BinaryOperator=>> BinOp=>> 9
70*a972a394SThomas Wucher // CHECK: BinaryOperator=< BinOp=< 11
71*a972a394SThomas Wucher // CHECK: BinaryOperator=> BinOp=> 12
72*a972a394SThomas Wucher // CHECK: BinaryOperator=<= BinOp=<= 13
73*a972a394SThomas Wucher // CHECK: BinaryOperator=>= BinOp=>= 14
74*a972a394SThomas Wucher // CHECK: BinaryOperator=== BinOp=== 15
75*a972a394SThomas Wucher // CHECK: BinaryOperator=!= BinOp=!= 16
76*a972a394SThomas Wucher // CHECK: BinaryOperator=& BinOp=& 17
77*a972a394SThomas Wucher // CHECK: BinaryOperator=^ BinOp=^ 18
78*a972a394SThomas Wucher // CHECK: BinaryOperator=| BinOp=| 19
79*a972a394SThomas Wucher // CHECK: BinaryOperator=&& BinOp=&& 20
80*a972a394SThomas Wucher // CHECK: BinaryOperator=|| BinOp=|| 21
81*a972a394SThomas Wucher // CHECK: BinaryOperator== BinOp== 22
82*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=*= BinOp=*= 23
83*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=/= BinOp=/= 24
84*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=%= BinOp=%= 25
85*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=+= BinOp=+= 26
86*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=-= BinOp=-= 27
87*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=<<= BinOp=<<= 28
88*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=>>= BinOp=>>= 29
89*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=&= BinOp=&= 30
90*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=^= BinOp=^= 31
91*a972a394SThomas Wucher // CHECK: CompoundAssignOperator=|= BinOp=|= 32
92*a972a394SThomas Wucher // CHECK: BinaryOperator=, BinOp=, 33
93