Issue an error if "uniform" or "varying" qualifiers are applied to void types.
Issue #179.
This commit is contained in:
19
decl.cpp
19
decl.cpp
@@ -69,12 +69,21 @@ lApplyTypeQualifiers(int typeQualifiers, const Type *type, SourcePos pos) {
|
|||||||
if ((typeQualifiers & TYPEQUAL_CONST) != 0)
|
if ((typeQualifiers & TYPEQUAL_CONST) != 0)
|
||||||
type = type->GetAsConstType();
|
type = type->GetAsConstType();
|
||||||
|
|
||||||
if ((typeQualifiers & TYPEQUAL_UNIFORM) != 0)
|
if ((typeQualifiers & TYPEQUAL_UNIFORM) != 0) {
|
||||||
type = type->GetAsUniformType();
|
if (type == AtomicType::Void)
|
||||||
else if ((typeQualifiers & TYPEQUAL_VARYING) != 0)
|
Error(pos, "\"uniform\" qualifier is illegal with \"void\" type.");
|
||||||
type = type->GetAsVaryingType();
|
else
|
||||||
|
type = type->GetAsUniformType();
|
||||||
|
}
|
||||||
|
else if ((typeQualifiers & TYPEQUAL_VARYING) != 0) {
|
||||||
|
if (type == AtomicType::Void)
|
||||||
|
Error(pos, "\"varying\" qualifier is illegal with \"void\" type.");
|
||||||
|
else
|
||||||
|
type = type->GetAsVaryingType();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
type = type->GetAsUnboundVariabilityType();
|
if (type != AtomicType::Void)
|
||||||
|
type = type->GetAsUnboundVariabilityType();
|
||||||
|
|
||||||
if ((typeQualifiers & TYPEQUAL_UNSIGNED) != 0) {
|
if ((typeQualifiers & TYPEQUAL_UNSIGNED) != 0) {
|
||||||
if ((typeQualifiers & TYPEQUAL_SIGNED) != 0)
|
if ((typeQualifiers & TYPEQUAL_SIGNED) != 0)
|
||||||
|
|||||||
44
parse.yy
44
parse.yy
@@ -473,8 +473,28 @@ rate_qualified_new
|
|||||||
|
|
||||||
rate_qualified_new_type
|
rate_qualified_new_type
|
||||||
: type_specifier { $$ = $1; }
|
: type_specifier { $$ = $1; }
|
||||||
| TOKEN_UNIFORM type_specifier { $$ = $2 ? $2->GetAsUniformType() : NULL; }
|
| TOKEN_UNIFORM type_specifier
|
||||||
| TOKEN_VARYING type_specifier { $$ = $2 ? $2->GetAsVaryingType() : NULL; }
|
{
|
||||||
|
if ($2 == NULL)
|
||||||
|
$$ = NULL;
|
||||||
|
else if ($2 == AtomicType::Void) {
|
||||||
|
Error(@1, "\"uniform\" qualifier is illegal with \"void\" type.");
|
||||||
|
$$ = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$$ = $2->GetAsUniformType();
|
||||||
|
}
|
||||||
|
| TOKEN_VARYING type_specifier
|
||||||
|
{
|
||||||
|
if ($2 == NULL)
|
||||||
|
$$ = NULL;
|
||||||
|
else if ($2 == AtomicType::Void) {
|
||||||
|
Error(@1, "\"varying\" qualifier is illegal with \"void\" type.");
|
||||||
|
$$ = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$$ = $2->GetAsVaryingType();
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
new_expression
|
new_expression
|
||||||
@@ -803,10 +823,22 @@ specifier_qualifier_list
|
|||||||
| type_qualifier specifier_qualifier_list
|
| type_qualifier specifier_qualifier_list
|
||||||
{
|
{
|
||||||
if ($2 != NULL) {
|
if ($2 != NULL) {
|
||||||
if ($1 == TYPEQUAL_UNIFORM)
|
if ($1 == TYPEQUAL_UNIFORM) {
|
||||||
$$ = $2->GetAsUniformType();
|
if ($2 == AtomicType::Void) {
|
||||||
else if ($1 == TYPEQUAL_VARYING)
|
Error(@1, "\"uniform\" qualifier is illegal with \"void\" type.");
|
||||||
$$ = $2->GetAsVaryingType();
|
$$ = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$$ = $2->GetAsUniformType();
|
||||||
|
}
|
||||||
|
else if ($1 == TYPEQUAL_VARYING) {
|
||||||
|
if ($2 == AtomicType::Void) {
|
||||||
|
Error(@1, "\"varying\" qualifier is illegal with \"void\" type.");
|
||||||
|
$$ = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$$ = $2->GetAsVaryingType();
|
||||||
|
}
|
||||||
else if ($1 == TYPEQUAL_CONST)
|
else if ($1 == TYPEQUAL_CONST)
|
||||||
$$ = $2->GetAsConstType();
|
$$ = $2->GetAsConstType();
|
||||||
else if ($1 == TYPEQUAL_SIGNED) {
|
else if ($1 == TYPEQUAL_SIGNED) {
|
||||||
|
|||||||
3
tests_errors/void-qualifiers-1.ispc
Normal file
3
tests_errors/void-qualifiers-1.ispc
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// "varying" qualifier is illegal with "void" type
|
||||||
|
|
||||||
|
varying void *foo;
|
||||||
5
tests_errors/void-qualifiers-2.ispc
Normal file
5
tests_errors/void-qualifiers-2.ispc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// "uniform" qualifier is illegal with "void" type
|
||||||
|
|
||||||
|
struct FFF {
|
||||||
|
uniform void *x;
|
||||||
|
};
|
||||||
3
tests_errors/void-qualifiers-3.ispc
Normal file
3
tests_errors/void-qualifiers-3.ispc
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// "varying" qualifier is illegal with "void" type
|
||||||
|
|
||||||
|
varying void *foo() { }
|
||||||
3
tests_errors/void-qualifiers-4.ispc
Normal file
3
tests_errors/void-qualifiers-4.ispc
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// "varying" qualifier is illegal with "void" type
|
||||||
|
|
||||||
|
void foo(varying void *x) { }
|
||||||
9
type.cpp
9
type.cpp
@@ -382,24 +382,21 @@ AtomicType::GetBaseType() const {
|
|||||||
|
|
||||||
const AtomicType *
|
const AtomicType *
|
||||||
AtomicType::GetAsVaryingType() const {
|
AtomicType::GetAsVaryingType() const {
|
||||||
if (this == AtomicType::Void)
|
Assert(this != AtomicType::Void);
|
||||||
return this;
|
|
||||||
return typeTable[basicType][Varying][isConst ? 1 : 0];
|
return typeTable[basicType][Varying][isConst ? 1 : 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const AtomicType *
|
const AtomicType *
|
||||||
AtomicType::GetAsUniformType() const {
|
AtomicType::GetAsUniformType() const {
|
||||||
if (this == AtomicType::Void)
|
Assert(this != AtomicType::Void);
|
||||||
return this;
|
|
||||||
return typeTable[basicType][Uniform][isConst ? 1 : 0];
|
return typeTable[basicType][Uniform][isConst ? 1 : 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const AtomicType *
|
const AtomicType *
|
||||||
AtomicType::GetAsUnboundVariabilityType() const {
|
AtomicType::GetAsUnboundVariabilityType() const {
|
||||||
if (this == AtomicType::Void)
|
Assert(this != AtomicType::Void);
|
||||||
return this;
|
|
||||||
return typeTable[basicType][Unbound][isConst ? 1 : 0];
|
return typeTable[basicType][Unbound][isConst ? 1 : 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user