Skip to content

Commit 2868d5b

Browse files
committed
C#: Add pointer cast test cases
1 parent d652b95 commit 2868d5b

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
3+
class C
4+
{
5+
unsafe static void M1(int[] arr)
6+
{
7+
fixed (int* i1 = arr)
8+
{
9+
}
10+
11+
fixed (int* i2 = &arr[0])
12+
{
13+
int* i3 = i2;
14+
i3 = i3 + 1;
15+
*i2 = *i2 + 1;
16+
void* v2 = i2;
17+
}
18+
19+
int* i4 = null;
20+
21+
int number = 1024;
22+
byte* p = (byte*)&number;
23+
24+
var s = "some string";
25+
fixed (char* c1 = s)
26+
{ }
27+
}
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
| Pointer.cs:7:21:7:28 | Pointer.cs:7:21:7:28 | Int32* | Int32[] | access to parameter arr |
2+
| Pointer.cs:11:21:11:32 | Pointer.cs:11:21:11:32 | Int32* | Int32* | &... |
3+
| Pointer.cs:13:18:13:24 | Pointer.cs:13:18:13:24 | Int32* | Int32* | access to local variable i2 |
4+
| Pointer.cs:14:13:14:23 | Pointer.cs:14:13:14:23 | Int32* | Int32* | ... + ... |
5+
| Pointer.cs:15:13:15:25 | Pointer.cs:15:13:15:25 | Int32 | Int32 | ... + ... |
6+
| Pointer.cs:16:19:16:25 | Pointer.cs:16:19:16:25 | Void* | Void* | (...) ... |
7+
| Pointer.cs:19:14:19:22 | Pointer.cs:19:14:19:22 | Int32* | null | null |
8+
| Pointer.cs:21:13:21:25 | Pointer.cs:21:13:21:25 | Int32 | Int32 | 1024 |
9+
| Pointer.cs:22:15:22:32 | Pointer.cs:22:15:22:32 | Byte* | Byte* | (...) ... |
10+
| Pointer.cs:24:13:24:29 | Pointer.cs:24:13:24:29 | String | String | "some string" |
11+
| Pointer.cs:25:22:25:27 | Pointer.cs:25:22:25:27 | Char* | String | access to local variable s |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import csharp
2+
3+
from Assignment a
4+
select a.getLocation(), a.getLValue().getType().toString(), a.getRValue().getType().toString(),
5+
a.getRValue().toString()

0 commit comments

Comments
 (0)