Make fteqcc handle dupe typedefs better (primarily to fix autoproto).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6253 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-05-28 18:00:09 +00:00
parent bfdc0b59bd
commit 5743de1167
2 changed files with 35 additions and 6 deletions

View file

@ -2021,7 +2021,7 @@ static QCC_sref_t QCC_SupplyConversion(QCC_sref_t var, etype_t wanted, pbool fa
{
if (flag_laxcasts)
{
QCC_PR_ParseWarning(WARN_LAXCAST, "Implicit type mismatch. Needed %s, got %s.", basictypenames[wanted], basictypenames[var.cast->type]);
QCC_PR_ParseWarning(WARN_LAXCAST, "Implicit type mismatch. Needed %s%s%s, got %s%s%s.", col_type,basictypenames[wanted],col_none, col_type,basictypenames[var.cast->type],col_none);
QCC_PR_ParsePrintSRef(WARN_LAXCAST, var);
}
else
@ -17754,6 +17754,7 @@ QCC_type_t *QCC_PR_ParseEnum(pbool flags)
void QCC_PR_ParseTypedef(void)
{
QCC_type_t *old;
QCC_type_t *type = QCC_PR_ParseType(false, false);
if (!type)
{
@ -17800,10 +17801,25 @@ void QCC_PR_ParseTypedef(void)
}
else
{
type = QCC_PR_DuplicateType(type, false);
type->name = name;
type->typedefed = true;
pHash_Add(&typedeftable, name, type, qccHunkAlloc(sizeof(bucket_t)));
old = QCC_TypeForName(name);
if (old)
{
if (typecmp(old, type))
{
char obuf[1024];
char nbuf[1024];
old->typedefed = false;
QCC_PR_ParseWarning(ERR_NOTATYPE, "Cannot redeclare typedef %s%s%s from %s%s%s to %s%s%s", col_type,name,col_none, col_type,TypeName(old, obuf, sizeof(obuf)),col_none, col_type,TypeName(type, nbuf, sizeof(nbuf)),col_none);
old->typedefed = true;
}
}
else
{
type = QCC_PR_DuplicateType(type, false);
type->name = name;
type->typedefed = true;
pHash_Add(&typedeftable, name, type, qccHunkAlloc(sizeof(bucket_t)));
}
}
} while(QCC_PR_CheckToken(","));
QCC_PR_Expect(";");

View file

@ -4726,6 +4726,14 @@ static void Q_strlcat(char *dest, const char *src, int sizeofdest)
char *TypeName(QCC_type_t *type, char *buffer, int buffersize)
{
char *ret;
/*if (type->typedefed)
{
if (buffersize < 0)
return buffer;
*buffer = 0;
Q_strlcat(buffer, type->name, buffersize);
return buffer;
}*/
if (type->type == ev_void)
{
@ -5599,7 +5607,12 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail)
QCC_PR_ParseError(ERR_NOTANAME, "Accessor %s cannot be based upon %s", accessorname, parentname);
}
else if (type != newt->parentclass)
QCC_PR_ParseError(ERR_NOTANAME, "Accessor %s basic type mismatch", accessorname);
{
char bufe[256];
char bufn[256];
QCC_PR_ParseError(ERR_NOTANAME, "Accessor %s basic type mismatch (%s, expected %s)", accessorname,
TypeName(type, bufn, sizeof(bufn)), TypeName(newt->parentclass, bufe, sizeof(bufe)));
}
if (QCC_PR_CheckToken("{"))
{