1 // RUN: %clang_cc1 -std=c++17 -Wno-unused -ast-dump %s -ast-dump-filter Test | FileCheck %s
4 template<typename T
, typename U
>
5 void Unary(T t
, T
* pt
, T
U::* mpt
, T(&ft
)(), T(&at
)[4]) {
6 // CHECK: UnaryOperator {{.*}} '<dependent type>' lvalue prefix '*' cannot overflow
7 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
10 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '+' cannot overflow
11 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
14 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '-' cannot overflow
15 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
18 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '!' cannot overflow
19 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
22 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '~' cannot overflow
23 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
26 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
27 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
30 // CHECK: UnaryOperator {{.*}} '<dependent type>' lvalue prefix '++' cannot overflow
31 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
34 // CHECK: UnaryOperator {{.*}} '<dependent type>' lvalue prefix '--' cannot overflow
35 // CHECK-NEXT: DeclRefExpr {{.*}} 'T' lvalue ParmVar {{.*}} 't' 'T'
38 // CHECK: UnaryOperator {{.*}} 'T' lvalue prefix '*' cannot overflow
39 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <LValueToRValue>
40 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
43 // CHECK: UnaryOperator {{.*}} 'T *' prefix '+' cannot overflow
44 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <LValueToRValue>
45 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
48 // CHECK: UnaryOperator {{.*}} 'bool' prefix '!' cannot overflow
49 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool' <PointerToBoolean>
50 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <LValueToRValue>
51 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
54 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
55 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
58 // CHECK: UnaryOperator {{.*}} 'T *' lvalue prefix '++' cannot overflow
59 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
62 // CHECK: UnaryOperator {{.*}} 'T *' lvalue prefix '--' cannot overflow
63 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
66 // CHECK: UnaryOperator {{.*}} 'bool' prefix '!' cannot overflow
67 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool' <MemberPointerToBoolean>
68 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T U::*' <LValueToRValue>
69 // CHECK-NEXT: DeclRefExpr {{.*}} 'T U::*' lvalue ParmVar {{.*}} 'mpt' 'T U::*'
72 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
73 // CHECK-NEXT: DeclRefExpr {{.*}} 'T U::*' lvalue ParmVar {{.*}} 'mpt' 'T U::*'
76 // CHECK: UnaryOperator {{.*}} 'T ()' lvalue prefix '*' cannot overflow
77 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T (*)()' <FunctionToPointerDecay>
78 // CHECK-NEXT: DeclRefExpr {{.*}} 'T ()' lvalue ParmVar {{.*}} 'ft' 'T (&)()'
81 // CHECK: UnaryOperator {{.*}} 'T (*)()' prefix '+' cannot overflow
82 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T (*)()' <FunctionToPointerDecay>
83 // CHECK-NEXT: DeclRefExpr {{.*}} 'T ()' lvalue ParmVar {{.*}} 'ft' 'T (&)()'
86 // CHECK: UnaryOperator {{.*}} 'bool' prefix '!' cannot overflow
87 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool' <PointerToBoolean>
88 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T (*)()' <FunctionToPointerDecay>
89 // CHECK-NEXT: DeclRefExpr {{.*}} 'T ()' lvalue ParmVar {{.*}} 'ft' 'T (&)()'
92 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
93 // CHECK-NEXT: DeclRefExpr {{.*}} 'T ()' lvalue ParmVar {{.*}} 'ft' 'T (&)()'
96 // CHECK: UnaryOperator {{.*}} 'T' lvalue prefix '*' cannot overflow
97 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <ArrayToPointerDecay>
98 // CHECK-NEXT: DeclRefExpr {{.*}} 'T[4]' lvalue ParmVar {{.*}} 'at' 'T (&)[4]'
101 // CHECK: UnaryOperator {{.*}} 'T *' prefix '+' cannot overflow
102 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <ArrayToPointerDecay>
103 // CHECK-NEXT: DeclRefExpr {{.*}} 'T[4]' lvalue ParmVar {{.*}} 'at' 'T (&)[4]'
106 // CHECK: UnaryOperator {{.*}} 'bool' prefix '!' cannot overflow
107 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool' <PointerToBoolean>
108 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'T *' <ArrayToPointerDecay>
109 // CHECK-NEXT: DeclRefExpr {{.*}} 'T[4]' lvalue ParmVar {{.*}} 'at' 'T (&)[4]'
112 // CHECK: UnaryOperator {{.*}} '<dependent type>' prefix '&' cannot overflow
113 // CHECK-NEXT: DeclRefExpr {{.*}} 'T[4]' lvalue ParmVar {{.*}} 'at' 'T (&)[4]'
117 template<typename T
, typename U
>
118 void Binary(T
* pt
, U
* pu
) {
119 // CHECK: BinaryOperator {{.*}} '<dependent type>' '+'
120 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
121 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 3
124 // CHECK: BinaryOperator {{.*}} '<dependent type>' '-'
125 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
126 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
129 // CHECK: BinaryOperator {{.*}} '<dependent type>' '-'
130 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
131 // CHECK-NEXT: DeclRefExpr {{.*}} 'U *' lvalue ParmVar {{.*}} 'pu' 'U *'
134 // CHECK: BinaryOperator {{.*}} '<dependent type>' '=='
135 // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
136 // CHECK-NEXT: DeclRefExpr {{.*}} 'U *' lvalue ParmVar {{.*}} 'pu' 'U *'