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:
Matt Pharr
2012-04-16 08:00:13 -07:00
parent b9d6ba2aa0
commit 55d5c07d00
7 changed files with 84 additions and 3 deletions

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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);
}