Added a warning for void() functionname() {} functions.

Fixed the ent.field.field += bug; by swapping the order of statements.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2495 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2007-04-15 17:35:58 +00:00
parent 834ed1c3dc
commit 3671902d06
3 changed files with 27 additions and 6 deletions

View File

@ -530,7 +530,7 @@ void QCC_PR_Lex (void);
// reads the next token into pr_token and classifies its type
QCC_type_t *QCC_PR_NewType (char *name, int basictype);
QCC_type_t *QCC_PR_ParseType (int newtype);
QCC_type_t *QCC_PR_ParseType (int newtype); extern pbool type_inlinefunction;
QCC_type_t *QCC_TypeForName(char *name);
QCC_type_t *QCC_PR_ParseFunctionType (int newtype, QCC_type_t *returntype);
QCC_type_t *QCC_PR_ParseFunctionTypeReacc (int newtype, QCC_type_t *returntype);
@ -607,6 +607,7 @@ enum {
WARN_UNDESIRABLECONVENTION,
WARN_SAMENAMEASGLOBAL,
WARN_CONSTANTCOMPARISON,
WARN_UNSAFEFUNCTIONRETURNTYPE,
ERR_PARSEERRORS, //caused by qcc_pr_parseerror being called.

View File

@ -1583,17 +1583,23 @@ QCC_def_t *QCC_PR_Statement ( QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t *var
break;
if (statements[st].c == var_b->ofs)
QCC_PR_ParseWarning(0, "Temp-reuse may have broken your %s\n", pr_opcodes);
QCC_PR_ParseWarning(0, "Temp-reuse may have broken your %s", op->name);
}
if (st < 0)
QCC_PR_ParseError(ERR_INTERNAL, "XSTOREP_F couldn't find pointer generation");
QCC_PR_ParseError(ERR_INTERNAL, "XSTOREP_F: pointer was not generated from previous statement");
var_c = QCC_GetTemp(*op->type_c);
statement_linenums[statement-statements] = pr_source_line;
statement->op = OP_LOAD_F;
statement_linenums[statement-statements] = statement_linenums[st];
statement->op = OP_ADDRESS;
statement->a = statements[st].a;
statement->b = statements[st].b;
statement->c = var_c->ofs;
statement->c = statements[st].c;
statement_linenums[st] = pr_source_line;
statements[st].op = OP_LOAD_F;
statements[st].a = statements[st].a;
statements[st].b = statements[st].b;
statements[st].c = var_c->ofs;
}
statement = &statements[numstatements];
@ -7388,6 +7394,7 @@ void QCC_PR_ParseDefs (char *classname)
pbool noref = false;
pbool nosave = false;
pbool allocatenew = true;
pbool inlinefunction = false;
int ispointer;
gofs_t oldglobals;
int arraysize;
@ -7669,6 +7676,8 @@ void QCC_PR_ParseDefs (char *classname)
if (type == NULL) //ignore
return;
inlinefunction = type_inlinefunction;
if (externfnc && type->type != ev_function)
{
printf ("Only functions may be defined as external (yet)\n");
@ -7866,7 +7875,12 @@ void QCC_PR_ParseDefs (char *classname)
arraysize = 1;
if (QCC_PR_CheckToken("("))
{
if (inlinefunction)
QCC_PR_ParseWarning(WARN_UNSAFEFUNCTIONRETURNTYPE, "Function returning function. Is this what you meant? (suggestion: use typedefs)");
inlinefunction = false;
type = QCC_PR_ParseFunctionType(false, type);
}
if (classname)
{

View File

@ -2988,6 +2988,7 @@ QCC_type_t *QCC_PR_FieldType (QCC_type_t *pointsto)
return QCC_PR_FindType (ptype);
}
pbool type_inlinefunction;
QCC_type_t *QCC_PR_ParseType (int newtype)
{
QCC_type_t *newparm;
@ -2996,6 +2997,8 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
char *name;
int i;
type_inlinefunction = false; //doesn't really matter so long as its not from an inline function type
// int ofs;
if (QCC_PR_CheckToken ("..")) //so we don't end up with the user specifying '. .vector blah' (hexen2 added the .. token for array ranges)
@ -3259,7 +3262,10 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
QCC_PR_Lex ();
if (QCC_PR_CheckToken ("(")) //this is followed by parameters. Must be a function.
{
type_inlinefunction = true;
return QCC_PR_ParseFunctionType(newtype, type);
}
else
{
if (newtype)