Merge pull request #574 from jbrodman/uniftypedef
Fix to respect uniform/varying qualifiers inside of typedefs.
This commit is contained in:
25
decl.cpp
25
decl.cpp
@@ -69,8 +69,15 @@ lApplyTypeQualifiers(int typeQualifiers, const Type *type, SourcePos pos) {
|
|||||||
if (type == NULL)
|
if (type == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((typeQualifiers & TYPEQUAL_CONST) != 0)
|
if ((typeQualifiers & TYPEQUAL_CONST) != 0) {
|
||||||
type = type->GetAsConstType();
|
type = type->GetAsConstType();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ((typeQualifiers & TYPEQUAL_UNIFORM) != 0)
|
||||||
|
&& ((typeQualifiers & TYPEQUAL_VARYING) != 0) ) {
|
||||||
|
Error(pos, "Type \"%s\" cannot be qualified with both uniform and varying.",
|
||||||
|
type->GetString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if ((typeQualifiers & TYPEQUAL_UNIFORM) != 0) {
|
if ((typeQualifiers & TYPEQUAL_UNIFORM) != 0) {
|
||||||
if (Type::Equal(type, AtomicType::Void))
|
if (Type::Equal(type, AtomicType::Void))
|
||||||
@@ -84,9 +91,10 @@ lApplyTypeQualifiers(int typeQualifiers, const Type *type, SourcePos pos) {
|
|||||||
else
|
else
|
||||||
type = type->GetAsVaryingType();
|
type = type->GetAsVaryingType();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
if (Type::Equal(type, AtomicType::Void) == false)
|
if (Type::Equal(type, AtomicType::Void) == false)
|
||||||
type = type->GetAsUnboundVariabilityType();
|
type = type->GetAsUnboundVariabilityType();
|
||||||
|
}
|
||||||
|
|
||||||
if ((typeQualifiers & TYPEQUAL_UNSIGNED) != 0) {
|
if ((typeQualifiers & TYPEQUAL_UNSIGNED) != 0) {
|
||||||
if ((typeQualifiers & TYPEQUAL_SIGNED) != 0)
|
if ((typeQualifiers & TYPEQUAL_SIGNED) != 0)
|
||||||
@@ -124,6 +132,17 @@ DeclSpecs::DeclSpecs(const Type *t, StorageClass sc, int tq) {
|
|||||||
typeQualifiers = tq;
|
typeQualifiers = tq;
|
||||||
soaWidth = 0;
|
soaWidth = 0;
|
||||||
vectorSize = 0;
|
vectorSize = 0;
|
||||||
|
if (t != NULL) {
|
||||||
|
if (m->symbolTable->ContainsType(t)) {
|
||||||
|
// Typedefs might have uniform/varying qualifiers inside.
|
||||||
|
if (t->IsVaryingType()) {
|
||||||
|
typeQualifiers |= TYPEQUAL_VARYING;
|
||||||
|
}
|
||||||
|
else if (t->IsUniformType()) {
|
||||||
|
typeQualifiers |= TYPEQUAL_UNIFORM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -229,6 +248,7 @@ Declarator::Declarator(DeclaratorKind dk, SourcePos p)
|
|||||||
void
|
void
|
||||||
Declarator::InitFromDeclSpecs(DeclSpecs *ds) {
|
Declarator::InitFromDeclSpecs(DeclSpecs *ds) {
|
||||||
const Type *baseType = ds->GetBaseType(pos);
|
const Type *baseType = ds->GetBaseType(pos);
|
||||||
|
|
||||||
InitFromType(baseType, ds);
|
InitFromType(baseType, ds);
|
||||||
|
|
||||||
if (type == NULL) {
|
if (type == NULL) {
|
||||||
@@ -591,6 +611,7 @@ Declaration::Declaration(DeclSpecs *ds, Declarator *d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<VariableDeclaration>
|
std::vector<VariableDeclaration>
|
||||||
Declaration::GetVariableDeclarations() const {
|
Declaration::GetVariableDeclarations() const {
|
||||||
Assert(declSpecs->storageClass != SC_TYPEDEF);
|
Assert(declSpecs->storageClass != SC_TYPEDEF);
|
||||||
|
|||||||
11
sym.cpp
11
sym.cpp
@@ -214,6 +214,17 @@ SymbolTable::LookupType(const char *name) const {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SymbolTable::ContainsType(const Type *type) const {
|
||||||
|
TypeMapType::const_iterator iter = types.begin();
|
||||||
|
while (iter != types.end()) {
|
||||||
|
if (iter->second == type) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
SymbolTable::ClosestVariableOrFunctionMatch(const char *str) const {
|
SymbolTable::ClosestVariableOrFunctionMatch(const char *str) const {
|
||||||
|
|||||||
6
sym.h
6
sym.h
@@ -219,6 +219,12 @@ public:
|
|||||||
@return Pointer to the Type, if found; otherwise NULL is returned.
|
@return Pointer to the Type, if found; otherwise NULL is returned.
|
||||||
*/
|
*/
|
||||||
const Type *LookupType(const char *name) const;
|
const Type *LookupType(const char *name) const;
|
||||||
|
|
||||||
|
/** Look for a type given a pointer.
|
||||||
|
|
||||||
|
@return True if found, False otherwise.
|
||||||
|
*/
|
||||||
|
bool ContainsType(const Type * type) const;
|
||||||
|
|
||||||
/** This method returns zero or more strings with the names of symbols
|
/** This method returns zero or more strings with the names of symbols
|
||||||
in the symbol table that nearly (but not exactly) match the given
|
in the symbol table that nearly (but not exactly) match the given
|
||||||
|
|||||||
Reference in New Issue
Block a user