Multiple small fixes for better C conformance.
Allow atomic types to be initialized with single-element expression lists:
int x = { 5 };
Issue an error if a storage class is provided with a function parameter.
Issue an error if two members of a struct have the same name.
Issue an error on trying to assign to a struct with a const member, even if
the struct itself isn't const.
Issue an error if a function is redefined.
Issue an error if a function overload is declared that differs only in return
type from a previously-declared function.
Issue an error if "inline" or "task" qualifiers are used outside of function
declarations.
Allow trailing ',' at the end of enumerator lists.
Multiple tests for all of the above.
This commit is contained in:
6
tests_errors/array-plus-equals.ispc
Normal file
6
tests_errors/array-plus-equals.ispc
Normal file
@@ -0,0 +1,6 @@
|
||||
// Illegal to assign to array type "float[5]"
|
||||
|
||||
void foo(float *x) {
|
||||
float a[5] = { 1,2,3,4,5};
|
||||
a += 3;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// ffofoof
|
||||
// Illegal to assign to array type "float[5]"
|
||||
|
||||
void foo(float *x) {
|
||||
float a[5] = { 1,2,3,4,5};
|
||||
|
||||
14
tests_errors/assign-struct-with-const-member-2.ispc
Normal file
14
tests_errors/assign-struct-with-const-member-2.ispc
Normal file
@@ -0,0 +1,14 @@
|
||||
// Illegal to assign to type "uniform struct Bar" in type "uniform struct Foo" due to element "a" with type "const int32"
|
||||
|
||||
struct Bar {
|
||||
const int a;
|
||||
};
|
||||
|
||||
struct Foo {
|
||||
struct Bar b;
|
||||
};
|
||||
|
||||
void foo(Foo f) {
|
||||
Foo g;
|
||||
g = f;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// ffofoof
|
||||
// Illegal to assign to type "uniform struct Foo" due to element "a" with type "const int32"
|
||||
|
||||
struct Foo {
|
||||
const int a;
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// Expression list initializers can't be used
|
||||
|
||||
int func() {
|
||||
int a = { 1 };
|
||||
}
|
||||
16
tests_errors/func-overload-by-return-type.ispc
Normal file
16
tests_errors/func-overload-by-return-type.ispc
Normal file
@@ -0,0 +1,16 @@
|
||||
// Illegal to overload function by return type only
|
||||
|
||||
float foo() {
|
||||
int x = { 2 };
|
||||
}
|
||||
|
||||
int y = { 2 };
|
||||
|
||||
void foo() {
|
||||
//CO while (true)
|
||||
//CO ;
|
||||
//CO for (;;)
|
||||
//CO ;
|
||||
do ; while(1);
|
||||
}
|
||||
|
||||
6
tests_errors/func-param-static.ispc
Normal file
6
tests_errors/func-param-static.ispc
Normal file
@@ -0,0 +1,6 @@
|
||||
// Storage class "static" is illegal in function parameter declaration for parameter "x"
|
||||
|
||||
void foo(static int x) {
|
||||
}
|
||||
|
||||
|
||||
16
tests_errors/function-redefinition.ispc
Normal file
16
tests_errors/function-redefinition.ispc
Normal file
@@ -0,0 +1,16 @@
|
||||
// Ignoring redefinition of function "foo".
|
||||
|
||||
float foo() {
|
||||
int x = { 2 };
|
||||
}
|
||||
|
||||
int y = { 2 };
|
||||
|
||||
float foo() {
|
||||
//CO while (true)
|
||||
//CO ;
|
||||
//CO for (;;)
|
||||
//CO ;
|
||||
do ; while(1);
|
||||
}
|
||||
|
||||
5
tests_errors/struct-bad-qualifiers.ispc
Normal file
5
tests_errors/struct-bad-qualifiers.ispc
Normal file
@@ -0,0 +1,5 @@
|
||||
// "task" qualifier is illegal outside of function declarations
|
||||
|
||||
struct Foo {
|
||||
task float x;
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
// ffofoof
|
||||
// Struct member "a" has same name as a previously-declared member
|
||||
|
||||
struct Foo {
|
||||
int a, a;
|
||||
|
||||
3
tests_errors/unsigned-float.ispc
Normal file
3
tests_errors/unsigned-float.ispc
Normal file
@@ -0,0 +1,3 @@
|
||||
// "unsigned" qualifier is illegal with "float" type
|
||||
|
||||
unsigned float foo = 1;
|
||||
Reference in New Issue
Block a user