removed Clang warnings

This commit is contained in:
Justin Meza 2013-12-30 12:45:34 -05:00
parent 6fea1cfb25
commit e2c479de2e
4 changed files with 15 additions and 0 deletions

View File

@ -143,6 +143,8 @@ static const char *err_msgs[] = {
"Invalid type\n",
/* IN_FUNCTION_NAME_USED_BY_VARIABLE */
"%s:%u: function name already used by existing variable at: %s\n",
/* IN_CANNOT_CAST_VALUE_TO_ARRAY */
"%s:%u: cannot cast value to array at: %s\n",
};
static const int err_codes[] = {
@ -224,6 +226,7 @@ static const int err_codes[] = {
536, /* IN_INVALID_DECLARATION_TYPE */
537, /* IN_INVALID_TYPE */
538, /* IN_FUNCTION_NAME_USED_BY_VARIABLE */
539, /* IN_CANNOT_CAST_VALUE_TO_ARRAY */
};
int error(ErrorType e, ...)

View File

@ -102,6 +102,7 @@ typedef enum {
IN_INVALID_DECLARATION_TYPE,
IN_INVALID_TYPE,
IN_FUNCTION_NAME_USED_BY_VARIABLE,
IN_CANNOT_CAST_VALUE_TO_ARRAY,
} ErrorType;
int error(ErrorType, ...);

View File

@ -2990,6 +2990,16 @@ ReturnObject *interpretCastStmtNode(StmtNode *node,
case CT_STRING:
if (!(cast = castStringExplicit(val, scope))) return NULL;
break;
case CT_ARRAY: {
IdentifierNode *id = (IdentifierNode *)(stmt->target);
char *name = resolveIdentifierName(id, scope);
if (name) {
error(IN_CANNOT_CAST_VALUE_TO_ARRAY, id->fname, id->line, name);
free(name);
}
return NULL;
break;
}
}
if (!updateScopeValue(scope, scope, stmt->target, cast)) {
deleteValueObject(cast);

View File

@ -136,6 +136,7 @@ char *copyString(char *);
unsigned int isDecString(const char *);
unsigned int isHexString(const char *);
char *resolveIdentifierName(IdentifierNode *, ScopeObject *);
int resolveTerminalSlot(ScopeObject *, ScopeObject *, IdentifierNode *, ScopeObject **, IdentifierNode **);
/**@}*/
/**