Parse and then mostly ignore "signed" qualifier.

Just issue errors if both "signed" and "unsigned" are specified,
or if "signed" is applied to a non-int type.
This commit is contained in:
Matt Pharr
2011-11-29 21:41:04 -08:00
parent a3641d7691
commit 6b9b7437ed
10 changed files with 59 additions and 5 deletions

View File

@@ -55,14 +55,23 @@ lApplyTypeQualifiers(int typeQualifiers, const Type *type, SourcePos pos) {
return NULL;
if ((typeQualifiers & TYPEQUAL_UNSIGNED) != 0) {
if ((typeQualifiers & TYPEQUAL_SIGNED) != 0)
Error(pos, "Illegal to apply both \"signed\" and \"unsigned\" "
"qualifiers.");
const Type *unsignedType = type->GetAsUnsignedType();
if (unsignedType != NULL)
type = unsignedType;
else
Error(pos, "\"unsigned\" qualifier is illegal with \"%s\" type.",
type->GetString().c_str());
}
if ((typeQualifiers & TYPEQUAL_SIGNED) != 0 && type->IsIntType() == false)
Error(pos, "\"signed\" qualifier is illegal with non-integer type "
"\"%s\".", type->GetString().c_str());
if ((typeQualifiers & TYPEQUAL_CONST) != 0)
type = type->GetAsConstType();
@@ -138,6 +147,7 @@ DeclSpecs::Print() const {
if (typeQualifiers & TYPEQUAL_UNIFORM) printf("uniform ");
if (typeQualifiers & TYPEQUAL_VARYING) printf("varying ");
if (typeQualifiers & TYPEQUAL_TASK) printf("task ");
if (typeQualifiers & TYPEQUAL_SIGNED) printf("signed ");
if (typeQualifiers & TYPEQUAL_UNSIGNED) printf("unsigned ");
printf("%s", baseType->GetString().c_str());