compliant, because struct tags were not compare, second, this lead to an
endless loop of recursive calls for a special case of wrong C code.
git-svn-id: svn://svn.cc65.org/cc65/trunk@1523
b7a2c559-68d2-44c3-8de9-
860c34a00d81
#include <stdio.h>
+#include <string.h>
+/* cc65 */
#include "anonname.h"
/*****************************************************************************/
-/* Code */
+/* Data */
+/*****************************************************************************/
+
+
+
+static const char AnonTag[] = "$anon";
+
+
+
+/*****************************************************************************/
+/* Code */
/*****************************************************************************/
*/
{
static unsigned ACount = 0;
- sprintf (Buf, "$anon-%s-%04X", Spec, ++ACount);
+ sprintf (Buf, "%s-%s-%04X", AnonTag, Spec, ++ACount);
return Buf;
}
+int IsAnonName (const char* Name)
+/* Check if the given symbol name is that of an anonymous symbol */
+{
+ return (strncmp (Name, AnonTag, sizeof (AnonTag) - 1) == 0);
+}
+
+
+
* to be IDENTSIZE characters long. A pointer to the buffer is returned.
*/
+int IsAnonName (const char* Name);
+/* Check if the given symbol name is that of an anonymous symbol */
+
/* End of anonname.h */
#include "xmalloc.h"
/* cc65 */
+#include "anonname.h"
#include "symentry.h"
void ChangeAsmName (SymEntry* Entry, const char* NewAsmName)
-/* Change the assembler name of the symbol */
+/* Change the assembler name of the symbol */
{
xfree (Entry->AsmName);
Entry->AsmName = xstrdup (NewAsmName);
+int HasAnonName (const SymEntry* Entry)
+/* Return true if the symbol entry has an anonymous name */
+{
+ return IsAnonName (Entry->Name);
+}
+
+
+
void ChangeAsmName (SymEntry* Entry, const char* NewAsmName);
/* Change the assembler name of the symbol */
+int HasAnonName (const SymEntry* Entry);
+/* Return true if the symbol entry has an anonymous name */
+
/* End of symentry.h */
+#include <string.h>
+
+/* cc65 */
#include "funcdesc.h"
#include "symtab.h"
#include "typecmp.h"
Sym2 = Sym2->NextSym;
}
- /* Check both pointers against NULL or a non parameter to compare the
- * field count
+ /* Check both pointers against NULL or a non parameter to compare the
+ * field count
*/
return (Sym1 == 0 || (Sym1->Flags & SC_PARAM) == 0) &&
(Sym2 == 0 || (Sym2->Flags & SC_PARAM) == 0);
/* Compare the fields */
while (Sym1 && Sym2) {
- /* Compare this field */
+ /* Compare the names of this field */
+ if (!HasAnonName (Sym1) || !HasAnonName (Sym2)) {
+ if (strcmp (Sym1->Name, Sym2->Name) != 0) {
+ /* Names are not identical */
+ return 0;
+ }
+ }
+
+ /* Compare the types of this field */
if (TypeCmp (Sym1->Type, Sym2->Type) < TC_EQUAL) {
/* Field types not equal */
return 0;
Sym1 = DecodePtr (lhs+1);
Sym2 = DecodePtr (rhs+1);
+ /* If one symbol has a name, the names must be identical */
+ if (!HasAnonName (Sym1) || !HasAnonName (Sym2)) {
+ if (strcmp (Sym1->Name, Sym2->Name) != 0) {
+ /* Names are not identical */
+ SetResult (Result, TC_INCOMPATIBLE);
+ return;
+ }
+ }
+
/* Get the field tables from the struct entry */
Tab1 = Sym1->V.S.SymTab;
Tab2 = Sym2->V.S.SymTab;