Further improvements to error reporting with function types.
Issue #219.
This commit is contained in:
4
expr.cpp
4
expr.cpp
@@ -328,8 +328,8 @@ lDoTypeConv(const Type *fromType, const Type *toType, Expr **expr,
|
||||
!Type::Equal(fromPointerType->GetBaseType()->GetAsConstType(),
|
||||
toPointerType->GetBaseType())) {
|
||||
if (!failureOk)
|
||||
Error(pos, "Can't convert between incompatible pointer types "
|
||||
"\"%s\" and \"%s\" for %s.",
|
||||
Error(pos, "Can't convert from pointer type \"%s\" to "
|
||||
"incompatible pointer type \"%s\" for %s.",
|
||||
fromPointerType->GetString().c_str(),
|
||||
toPointerType->GetString().c_str(), errorMsgBase);
|
||||
return false;
|
||||
|
||||
@@ -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) {
|
||||
return p;
|
||||
|
||||
23
type.cpp
23
type.cpp
@@ -2466,18 +2466,7 @@ FunctionType::GetAsNonConstType() const {
|
||||
|
||||
std::string
|
||||
FunctionType::GetString() const {
|
||||
std::string ret;
|
||||
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 */";
|
||||
std::string ret = GetReturnTypeString();
|
||||
ret += "(";
|
||||
for (unsigned int i = 0; i < paramTypes.size(); ++i) {
|
||||
if (paramTypes[i] == NULL)
|
||||
@@ -2554,6 +2543,9 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
|
||||
const std::string
|
||||
FunctionType::GetReturnTypeString() const {
|
||||
if (returnType == NULL)
|
||||
return "/* ERROR */";
|
||||
|
||||
std::string ret;
|
||||
if (isTask)
|
||||
ret += "task ";
|
||||
@@ -2561,6 +2553,13 @@ FunctionType::GetReturnTypeString() const {
|
||||
ret += "export ";
|
||||
if (isExternC)
|
||||
ret += "extern \"C\" ";
|
||||
if (isSafe)
|
||||
ret += "/*safe*/ ";
|
||||
if (costOverride > 0) {
|
||||
char buf[32];
|
||||
sprintf(buf, "/*cost=%d*/ ", costOverride);
|
||||
ret += buf;
|
||||
}
|
||||
return ret + returnType->GetString();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user