Issue errors when doing illegal things with incomplete struct types.
Issue an error, rather than crashing, if the user has declared a struct type but not defined it and subsequently tries to: - dynamically allocate an instance of the struct type - do pointer math with a pointer to the struct type - compute the size of the struct type
This commit is contained in:
7
tests_errors/undef-struct-new.ispc
Normal file
7
tests_errors/undef-struct-new.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Can't dynamically allocate storage for declared but not defined type
|
||||
|
||||
struct Foo;
|
||||
|
||||
Foo * uniform bar() {
|
||||
return uniform new Foo;
|
||||
}
|
||||
7
tests_errors/undef-struct-ptrmath-1.ispc
Normal file
7
tests_errors/undef-struct-ptrmath-1.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Illegal to perform pointer arithmetic on undefined struct type
|
||||
|
||||
struct Foo;
|
||||
|
||||
Foo * uniform bar(Foo * uniform f) {
|
||||
return f + 1;
|
||||
}
|
||||
7
tests_errors/undef-struct-ptrmath-2.ispc
Normal file
7
tests_errors/undef-struct-ptrmath-2.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Illegal to perform pointer arithmetic on undefined struct type
|
||||
|
||||
struct Foo;
|
||||
|
||||
Foo * uniform bar(Foo * uniform f) {
|
||||
return 1 + f;
|
||||
}
|
||||
7
tests_errors/undef-struct-ptrmath-3.ispc
Normal file
7
tests_errors/undef-struct-ptrmath-3.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Illegal to perform pointer arithmetic on undefined struct type
|
||||
|
||||
struct Foo;
|
||||
|
||||
Foo * uniform bar(Foo * uniform f) {
|
||||
return f-1;
|
||||
}
|
||||
7
tests_errors/undef-struct-ptrmath.ispc
Normal file
7
tests_errors/undef-struct-ptrmath.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Illegal to pre/post increment pointer to undefined struct type
|
||||
|
||||
struct Foo;
|
||||
|
||||
Foo * uniform bar(Foo * uniform f) {
|
||||
return ++f;
|
||||
}
|
||||
7
tests_errors/undef-struct-sizeof.ispc
Normal file
7
tests_errors/undef-struct-sizeof.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Can't compute the size of declared but not defined struct type
|
||||
|
||||
struct Foo;
|
||||
|
||||
uniform int bar() {
|
||||
return sizeof(Foo);
|
||||
}
|
||||
Reference in New Issue
Block a user