Actually typecheck the arguments to functions called through function pointers.
(Somehow this wasn't being done before.) Errors are now issued if too few arguments are used when calling through a function pointer, too many arguments are used, or if any of them can't be type converted to the parameter type.
This commit is contained in:
9
tests_errors/fptr-typecheck-1.ispc
Normal file
9
tests_errors/fptr-typecheck-1.ispc
Normal file
@@ -0,0 +1,9 @@
|
||||
// Too many parameter values provided in function call
|
||||
|
||||
float bar(float a, float b);
|
||||
|
||||
export uniform int foo(uniform int x[], uniform int i[]) {
|
||||
float (*fptr)(float, float) = bar;
|
||||
//CO bar(0,1,2);
|
||||
fptr(0., 1, 2);
|
||||
}
|
||||
9
tests_errors/fptr-typecheck-2.ispc
Normal file
9
tests_errors/fptr-typecheck-2.ispc
Normal file
@@ -0,0 +1,9 @@
|
||||
// Can't convert argument of type "void * const uniform" to type "float" for funcion call argument.
|
||||
|
||||
float bar(float a, float b);
|
||||
|
||||
export uniform int foo(uniform int x[], uniform int i[]) {
|
||||
float (*fptr)(float, float) = bar;
|
||||
//CO bar(0,1,2);
|
||||
fptr(NULL, 1);
|
||||
}
|
||||
8
tests_errors/fptr-typecheck-3.ispc
Normal file
8
tests_errors/fptr-typecheck-3.ispc
Normal file
@@ -0,0 +1,8 @@
|
||||
// Too few parameter values provided in function call (1 provided, 2 expected).
|
||||
|
||||
float bar(float a, float b);
|
||||
|
||||
export uniform int foo(uniform int x[], uniform int i[]) {
|
||||
float (*fptr)(float, float) = bar;
|
||||
fptr(1.);
|
||||
}
|
||||
Reference in New Issue
Block a user