Further improvements to error reporting with function types.

Issue #219.
This commit is contained in:
Matt Pharr
2012-04-03 05:55:50 -07:00
parent 920cf63201
commit eb85da81e1
3 changed files with 14 additions and 15 deletions

View File

@@ -328,8 +328,8 @@ lDoTypeConv(const Type *fromType, const Type *toType, Expr **expr,
!Type::Equal(fromPointerType->GetBaseType()->GetAsConstType(), !Type::Equal(fromPointerType->GetBaseType()->GetAsConstType(),
toPointerType->GetBaseType())) { toPointerType->GetBaseType())) {
if (!failureOk) if (!failureOk)
Error(pos, "Can't convert between incompatible pointer types " Error(pos, "Can't convert from pointer type \"%s\" to "
"\"%s\" and \"%s\" for %s.", "incompatible pointer type \"%s\" for %s.",
fromPointerType->GetString().c_str(), fromPointerType->GetString().c_str(),
toPointerType->GetString().c_str(), errorMsgBase); toPointerType->GetString().c_str(), errorMsgBase);
return false; return false;

View File

@@ -1,4 +1,4 @@
// Can't convert between incompatible pointer types // Can't convert from pointer type "void * varying" to incompatible pointer type "uniform int32 * varying" for return statement
int *foo(void *p) { int *foo(void *p) {
return p; return p;

View File

@@ -2466,18 +2466,7 @@ FunctionType::GetAsNonConstType() const {
std::string std::string
FunctionType::GetString() const { FunctionType::GetString() const {
std::string ret; std::string ret = GetReturnTypeString();
if (isTask) ret += "task ";
if (isSafe) ret += "/*safe*/ ";
if (costOverride > 0) {
char buf[32];
sprintf(buf, "/*cost=%d*/ ", costOverride);
ret += buf;
}
if (returnType != NULL)
ret += returnType->GetString();
else
ret += "/* ERROR */";
ret += "("; ret += "(";
for (unsigned int i = 0; i < paramTypes.size(); ++i) { for (unsigned int i = 0; i < paramTypes.size(); ++i) {
if (paramTypes[i] == NULL) if (paramTypes[i] == NULL)
@@ -2554,6 +2543,9 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const {
const std::string const std::string
FunctionType::GetReturnTypeString() const { FunctionType::GetReturnTypeString() const {
if (returnType == NULL)
return "/* ERROR */";
std::string ret; std::string ret;
if (isTask) if (isTask)
ret += "task "; ret += "task ";
@@ -2561,6 +2553,13 @@ FunctionType::GetReturnTypeString() const {
ret += "export "; ret += "export ";
if (isExternC) if (isExternC)
ret += "extern \"C\" "; ret += "extern \"C\" ";
if (isSafe)
ret += "/*safe*/ ";
if (costOverride > 0) {
char buf[32];
sprintf(buf, "/*cost=%d*/ ", costOverride);
ret += buf;
}
return ret + returnType->GetString(); return ret + returnType->GetString();
} }