Revamp handling of function types, conversion to function ptr types.
Implicit conversion to function types is now a more standard part of the type conversion infrastructure, rather than special cases of things like FunctionSymbolExpr immediately returning a pointer type, etc. Improved AddressOfExpr::TypeCheck() to actually issue errors in cases where it's illegal to take the address of an expression. Added AddressOfExpr::GetConstant() implementation that handles taking the address of functions. Issue #223.
This commit is contained in:
11
type.cpp
11
type.cpp
@@ -2695,6 +2695,17 @@ Type::MoreGeneralType(const Type *t0, const Type *t1, SourcePos pos, const char
|
||||
bool forceVarying, int vecSize) {
|
||||
Assert(reason != NULL);
|
||||
|
||||
// First, if one or both types are function types, convert them to
|
||||
// pointer to function types and then try again.
|
||||
if (dynamic_cast<const FunctionType *>(t0) ||
|
||||
dynamic_cast<const FunctionType *>(t1)) {
|
||||
if (dynamic_cast<const FunctionType *>(t0))
|
||||
t0 = PointerType::GetUniform(t0);
|
||||
if (dynamic_cast<const FunctionType *>(t1))
|
||||
t1 = PointerType::GetUniform(t1);
|
||||
return MoreGeneralType(t0, t1, pos, reason, forceVarying, vecSize);
|
||||
}
|
||||
|
||||
// First, if we need to go varying, promote both of the types to be
|
||||
// varying.
|
||||
if (t0->IsVaryingType() || t1->IsVaryingType() || forceVarying) {
|
||||
|
||||
Reference in New Issue
Block a user