Skip to content

Commit d1ed317

Browse files
committed
C#: Add tests for qualified delegate pointer calls
1 parent c74bc68 commit d1ed317

File tree

4 files changed

+58
-22
lines changed

4 files changed

+58
-22
lines changed

csharp/ql/test/library-tests/delegates/Delegates4.expected

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
| delegates.cs:74:13:74:23 | delegate call | delegates.cs:74:13:74:15 | access to local variable cd7 |
33
| delegates.cs:79:22:79:26 | delegate call | delegates.cs:79:22:79:23 | access to local variable pi |
44
| delegates.cs:79:30:79:35 | delegate call | delegates.cs:79:30:79:31 | access to local variable ps |
5-
| delegates.cs:93:13:93:25 | delegate call | delegates.cs:93:13:93:22 | access to field Field |
6-
| delegates.cs:94:13:94:28 | delegate call | delegates.cs:94:13:94:25 | access to property Property |
7-
| delegates.cs:95:13:95:20 | delegate call | delegates.cs:95:13:95:17 | access to field Field |
8-
| delegates.cs:96:13:96:23 | delegate call | delegates.cs:96:13:96:20 | access to property Property |
5+
| delegates.cs:95:13:95:25 | delegate call | delegates.cs:95:13:95:22 | access to field Field |
6+
| delegates.cs:96:13:96:28 | delegate call | delegates.cs:96:13:96:25 | access to property Property |
7+
| delegates.cs:97:13:97:20 | delegate call | delegates.cs:97:13:97:17 | access to field Field |
8+
| delegates.cs:98:13:98:23 | delegate call | delegates.cs:98:13:98:20 | access to property Property |
9+
| delegates.cs:99:13:99:28 | function pointer call | delegates.cs:99:13:99:25 | access to field FieldPtr |
10+
| delegates.cs:100:13:100:31 | function pointer call | delegates.cs:100:13:100:28 | access to property PropertyPtr |
11+
| delegates.cs:101:13:101:23 | function pointer call | delegates.cs:101:13:101:20 | access to field FieldPtr |
12+
| delegates.cs:102:13:102:26 | function pointer call | delegates.cs:102:13:102:23 | access to property PropertyPtr |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import csharp
22

3-
from DelegateCall dc
3+
from DelegateLikeCall dc
44
select dc, dc.getExpr()

csharp/ql/test/library-tests/delegates/PrintAst.expected

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -260,24 +260,50 @@ delegates.cs:
260260
# 89| 4: [Setter] set_Property
261261
#-----| 2: (Parameters)
262262
# 89| 0: [Parameter] value
263-
# 91| 7: [Method] M
264-
# 91| -1: [TypeMention] Void
265-
# 92| 4: [BlockStmt] {...}
266-
# 93| 0: [ExprStmt] ...;
267-
# 93| 0: [DelegateCall] delegate call
268-
# 93| -1: [FieldAccess] access to field Field
269-
# 93| -1: [ThisAccess] this access
270-
# 93| 0: [IntLiteral] 0
271-
# 94| 1: [ExprStmt] ...;
272-
# 94| 0: [DelegateCall] delegate call
273-
# 94| -1: [PropertyCall] access to property Property
274-
# 94| -1: [ThisAccess] this access
275-
# 94| 0: [IntLiteral] 0
276-
# 95| 2: [ExprStmt] ...;
263+
# 90| 7: [Field] FieldPtr
264+
# 90| -1: [TypeMention] delegate* default<Int32,Void>
265+
# 91| 8: [Property] PropertyPtr
266+
# 91| -1: [TypeMention] delegate* default<Int32,Void>
267+
# 91| 3: [Getter] get_PropertyPtr
268+
# 91| 4: [Setter] set_PropertyPtr
269+
#-----| 2: (Parameters)
270+
# 91| 0: [Parameter] value
271+
# 93| 9: [Method] M
272+
# 93| -1: [TypeMention] Void
273+
# 94| 4: [BlockStmt] {...}
274+
# 95| 0: [ExprStmt] ...;
277275
# 95| 0: [DelegateCall] delegate call
278276
# 95| -1: [FieldAccess] access to field Field
277+
# 95| -1: [ThisAccess] this access
279278
# 95| 0: [IntLiteral] 0
280-
# 96| 3: [ExprStmt] ...;
279+
# 96| 1: [ExprStmt] ...;
281280
# 96| 0: [DelegateCall] delegate call
282281
# 96| -1: [PropertyCall] access to property Property
282+
# 96| -1: [ThisAccess] this access
283283
# 96| 0: [IntLiteral] 0
284+
# 97| 2: [ExprStmt] ...;
285+
# 97| 0: [DelegateCall] delegate call
286+
# 97| -1: [FieldAccess] access to field Field
287+
# 97| 0: [IntLiteral] 0
288+
# 98| 3: [ExprStmt] ...;
289+
# 98| 0: [DelegateCall] delegate call
290+
# 98| -1: [PropertyCall] access to property Property
291+
# 98| 0: [IntLiteral] 0
292+
# 99| 4: [ExprStmt] ...;
293+
# 99| 0: [FunctionPointerCall] function pointer call
294+
# 99| -1: [FieldAccess] access to field FieldPtr
295+
# 99| -1: [ThisAccess] this access
296+
# 99| 0: [IntLiteral] 0
297+
# 100| 5: [ExprStmt] ...;
298+
# 100| 0: [FunctionPointerCall] function pointer call
299+
# 100| -1: [PropertyCall] access to property PropertyPtr
300+
# 100| -1: [ThisAccess] this access
301+
# 100| 0: [IntLiteral] 0
302+
# 101| 6: [ExprStmt] ...;
303+
# 101| 0: [FunctionPointerCall] function pointer call
304+
# 101| -1: [FieldAccess] access to field FieldPtr
305+
# 101| 0: [IntLiteral] 0
306+
# 102| 7: [ExprStmt] ...;
307+
# 102| 0: [FunctionPointerCall] function pointer call
308+
# 102| -1: [PropertyCall] access to property PropertyPtr
309+
# 102| 0: [IntLiteral] 0

csharp/ql/test/library-tests/delegates/delegates.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,23 @@ static void Main()
8383

8484
}
8585

86-
class E
86+
unsafe class E
8787
{
8888
Action<int> Field;
8989
Action<int> Property { get; set; }
90+
delegate*<int, void> FieldPtr;
91+
delegate*<int, void> PropertyPtr { get; set; }
9092

91-
void M()
93+
unsafe void M()
9294
{
9395
this.Field(0);
9496
this.Property(0);
9597
Field(0);
9698
Property(0);
99+
this.FieldPtr(0);
100+
this.PropertyPtr(0);
101+
FieldPtr(0);
102+
PropertyPtr(0);
97103
}
98104
}
99105
}

0 commit comments

Comments
 (0)