mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Add function pointer conversion tests
This commit is contained in:
@@ -35,5 +35,18 @@ public class FnPointer
|
||||
{
|
||||
int j = f(new T());
|
||||
}
|
||||
|
||||
static void M5(delegate*<B, A> f, delegate*<A, B> ff)
|
||||
{
|
||||
M5(ff, ff); // implicit conversion due to implicit reference conversion
|
||||
}
|
||||
|
||||
static void M6(delegate*<int*, void*> f, delegate*<void*, int*> ff)
|
||||
{
|
||||
M6(ff, ff); // implicit conversion due to implicit pointer conversion
|
||||
}
|
||||
|
||||
class A { }
|
||||
class B : A { }
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,25 @@
|
||||
type
|
||||
| file://:0:0:0:0 | delegate* default<A,B> | B | 0 |
|
||||
| file://:0:0:0:0 | delegate* default<B,A> | A | 0 |
|
||||
| file://:0:0:0:0 | delegate* default<Int32 ref,Object out,Int32 in,Int32 ref> | Int32 | 0 |
|
||||
| file://:0:0:0:0 | delegate* default<Int32 ref,Object out,Int32> | Int32 | 0 |
|
||||
| file://:0:0:0:0 | delegate* default<Int32*,Void*> | Void* | 0 |
|
||||
| file://:0:0:0:0 | delegate* default<Int32> | Int32 | 0 |
|
||||
| file://:0:0:0:0 | delegate* default<T,Int32> | Int32 | 0 |
|
||||
| file://:0:0:0:0 | delegate* default<Void*,Int32*> | Int32* | 0 |
|
||||
| file://:0:0:0:0 | delegate* stdcall<Int32 ref,Object out,T,Void> | Void | 2 |
|
||||
unmanagedCallingConvention
|
||||
parameter
|
||||
| file://:0:0:0:0 | delegate* default<A,B> | 0 | file://:0:0:0:0 | | A |
|
||||
| file://:0:0:0:0 | delegate* default<B,A> | 0 | file://:0:0:0:0 | | B |
|
||||
| file://:0:0:0:0 | delegate* default<Int32 ref,Object out,Int32 in,Int32 ref> | 0 | file://:0:0:0:0 | | Int32 |
|
||||
| file://:0:0:0:0 | delegate* default<Int32 ref,Object out,Int32 in,Int32 ref> | 1 | file://:0:0:0:0 | `1 | Object |
|
||||
| file://:0:0:0:0 | delegate* default<Int32 ref,Object out,Int32 in,Int32 ref> | 2 | file://:0:0:0:0 | `2 | Int32 |
|
||||
| file://:0:0:0:0 | delegate* default<Int32 ref,Object out,Int32> | 0 | file://:0:0:0:0 | | Int32 |
|
||||
| file://:0:0:0:0 | delegate* default<Int32 ref,Object out,Int32> | 1 | file://:0:0:0:0 | `1 | Object |
|
||||
| file://:0:0:0:0 | delegate* default<Int32*,Void*> | 0 | file://:0:0:0:0 | | Int32* |
|
||||
| file://:0:0:0:0 | delegate* default<T,Int32> | 0 | file://:0:0:0:0 | | T |
|
||||
| file://:0:0:0:0 | delegate* default<Void*,Int32*> | 0 | file://:0:0:0:0 | | Void* |
|
||||
| file://:0:0:0:0 | delegate* stdcall<Int32 ref,Object out,T,Void> | 0 | file://:0:0:0:0 | | Int32 |
|
||||
| file://:0:0:0:0 | delegate* stdcall<Int32 ref,Object out,T,Void> | 1 | file://:0:0:0:0 | `1 | Object |
|
||||
| file://:0:0:0:0 | delegate* stdcall<Int32 ref,Object out,T,Void> | 2 | file://:0:0:0:0 | `2 | T |
|
||||
@@ -20,3 +28,6 @@ invocation
|
||||
| FunctionPointer.cs:25:13:25:44 | function pointer call |
|
||||
| FunctionPointer.cs:31:29:31:57 | function pointer call |
|
||||
| FunctionPointer.cs:36:21:36:30 | function pointer call |
|
||||
casts
|
||||
| FunctionPointer.cs:41:16:41:17 | (...) ... | file://:0:0:0:0 | delegate* default<A,B> | file://:0:0:0:0 | delegate* default<B,A> |
|
||||
| FunctionPointer.cs:46:16:46:17 | (...) ... | file://:0:0:0:0 | delegate* default<Void*,Int32*> | file://:0:0:0:0 | delegate* default<Int32*,Void*> |
|
||||
|
||||
@@ -14,3 +14,7 @@ query predicate parameter(FunctionPointerType fpt, int i, Parameter p, string t)
|
||||
}
|
||||
|
||||
query predicate invocation(FunctionPointerCall fpc) { any() }
|
||||
|
||||
query predicate casts(ImplicitCast cast, FunctionPointerType fromType, FunctionPointerType toType) {
|
||||
cast.getSourceType() = fromType and cast.getTargetType() = toType
|
||||
}
|
||||
|
||||
@@ -193,6 +193,37 @@ FunctionPointer.cs:
|
||||
# 36| -1: [ParameterAccess] access to parameter f
|
||||
# 36| 0: [ObjectCreation] object creation of type T
|
||||
# 36| 0: [TypeMention] T
|
||||
# 39| 11: [Method] M5
|
||||
# 39| -1: [TypeMention] Void
|
||||
#-----| 2: (Parameters)
|
||||
# 39| 0: [Parameter] f
|
||||
# 39| -1: [TypeMention] delegate* default<B,A>
|
||||
# 39| 1: [Parameter] ff
|
||||
# 39| -1: [TypeMention] delegate* default<A,B>
|
||||
# 40| 4: [BlockStmt] {...}
|
||||
# 41| 0: [ExprStmt] ...;
|
||||
# 41| 0: [MethodCall] call to method M5
|
||||
# 41| 0: [CastExpr] (...) ...
|
||||
# 41| 1: [ParameterAccess] access to parameter ff
|
||||
# 41| 1: [ParameterAccess] access to parameter ff
|
||||
# 44| 12: [Method] M6
|
||||
# 44| -1: [TypeMention] Void
|
||||
#-----| 2: (Parameters)
|
||||
# 44| 0: [Parameter] f
|
||||
# 44| -1: [TypeMention] delegate* default<Int32*,Void*>
|
||||
# 44| 1: [Parameter] ff
|
||||
# 44| -1: [TypeMention] delegate* default<Void*,Int32*>
|
||||
# 45| 4: [BlockStmt] {...}
|
||||
# 46| 0: [ExprStmt] ...;
|
||||
# 46| 0: [MethodCall] call to method M6
|
||||
# 46| 0: [CastExpr] (...) ...
|
||||
# 46| 1: [ParameterAccess] access to parameter ff
|
||||
# 46| 1: [ParameterAccess] access to parameter ff
|
||||
# 49| 13: [Class] A
|
||||
# 50| 14: [Class] B
|
||||
#-----| 3: (Base types)
|
||||
# 50| 0: [TypeMention] A
|
||||
# 50| 0: [TypeMention] A
|
||||
InitOnlyProperty.cs:
|
||||
# 3| [NamespaceDeclaration] namespace ... { ... }
|
||||
# 5| 1: [Class] IsExternalInit
|
||||
|
||||
Reference in New Issue
Block a user