ref: 35433cdb45a12bbbfab1e960a51cf9089b338c05
parent: 53165c498bed133f20a3c33b86a3989e79122f0b
author: Michael Forney <[email protected]>
date: Thu Feb 16 05:07:16 EST 2017
[cc1] Fix eqtype for structs and unions with the same number of fields
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -351,6 +351,7 @@
{
TINT n;
Type **p1, **p2;
+ Symbol **s1, **s2;
if (tp1 == tp2)
return 1;
@@ -362,6 +363,20 @@
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;