forked from github/codeql
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
csharp/ql/test/library-tests/conversion/pointer/Pointer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
|
||
class C | ||
{ | ||
unsafe static void M1(int[] arr) | ||
{ | ||
fixed (int* i1 = arr) | ||
{ | ||
} | ||
|
||
fixed (int* i2 = &arr[0]) | ||
{ | ||
int* i3 = i2; | ||
i3 = i3 + 1; | ||
*i2 = *i2 + 1; | ||
void* v2 = i2; | ||
} | ||
|
||
int* i4 = null; | ||
|
||
int number = 1024; | ||
byte* p = (byte*)&number; | ||
|
||
var s = "some string"; | ||
fixed (char* c1 = s) | ||
{ } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
csharp/ql/test/library-tests/conversion/pointer/Pointer.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
| Pointer.cs:7:21:7:28 | Pointer.cs:7:21:7:28 | Int32* | Int32[] | access to parameter arr | | ||
| Pointer.cs:11:21:11:32 | Pointer.cs:11:21:11:32 | Int32* | Int32* | &... | | ||
| Pointer.cs:13:18:13:24 | Pointer.cs:13:18:13:24 | Int32* | Int32* | access to local variable i2 | | ||
| Pointer.cs:14:13:14:23 | Pointer.cs:14:13:14:23 | Int32* | Int32* | ... + ... | | ||
| Pointer.cs:15:13:15:25 | Pointer.cs:15:13:15:25 | Int32 | Int32 | ... + ... | | ||
| Pointer.cs:16:19:16:25 | Pointer.cs:16:19:16:25 | Void* | Void* | (...) ... | | ||
| Pointer.cs:19:14:19:22 | Pointer.cs:19:14:19:22 | Int32* | null | null | | ||
| Pointer.cs:21:13:21:25 | Pointer.cs:21:13:21:25 | Int32 | Int32 | 1024 | | ||
| Pointer.cs:22:15:22:32 | Pointer.cs:22:15:22:32 | Byte* | Byte* | (...) ... | | ||
| Pointer.cs:24:13:24:29 | Pointer.cs:24:13:24:29 | String | String | "some string" | | ||
| Pointer.cs:25:22:25:27 | Pointer.cs:25:22:25:27 | Char* | String | access to local variable s | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import csharp | ||
|
||
from Assignment a | ||
select a.getLocation(), a.getLValue().getType().toString(), a.getRValue().getType().toString(), | ||
a.getRValue().toString() |