[hackers] [scc] [cc1] Fix eqtype for structs and unions with the same number of fields || Michael Forney

From: <git_AT_suckless.org>
Date: Thu, 16 Feb 2017 20:51:39 +0100 (CET)

commit fbd4dc3ffdc99ec1ea9c3eb5af6340e8824ab310
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Thu Feb 16 10:07:16 2017 -0800
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Feb 16 20:51:13 2017 +0100

    [cc1] Fix eqtype for structs and unions with the same number of fields

diff --git a/cc1/types.c b/cc1/types.c
index a367d0b..ed20f23 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -351,6 +351,7 @@ eqtype(Type *tp1, Type *tp2, int equiv)
 {
         TINT n;
         Type **p1, **p2;
+ Symbol **s1, **s2;
 
         if (tp1 == tp2)
                 return 1;
_AT_@ -362,6 +363,20 @@ eqtype(Type *tp1, Type *tp2, int equiv)
         switch (tp1->op) {
         case UNION:
         case STRUCT:
+ if (tp1->letter != tp2->letter)
+ return 0;
+ if (tp1->tag->name || tp2->tag->name)
+ return tp1->tag == tp2->tag;
+ if (tp1->n.elem != tp2->n.elem)
+ return 0;
+ s1 = tp1->p.fields, s2 = tp2->p.fields;
+ for (n = tp1->n.elem; n > 0; --n, ++s1, ++s2) {
+ if (strcmp((*s1)->name, (*s2)->name))
+ return 0;
+ if (!eqtype((*s1)->type, (*s2)->type, equiv))
+ return 0;
+ }
+ return 1;
         case FTN:
                 if (tp1->n.elem != tp2->n.elem)
                         return 0;
Received on Thu Feb 16 2017 - 20:51:39 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 16 2017 - 21:00:19 CET