[hackers] [scc] [cc1] Fix eqtype() for functions || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 20 May 2016 15:34:07 +0200 (CEST)

commit eb9387c7d79bb73b5481decf9aa69a00707fa26b
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri May 20 15:29:27 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri May 20 15:32:51 2016 +0200

    [cc1] Fix eqtype() for functions
    
    Eqtype() check if two types are equivalent, but it was wrong in the
    case of functions, because it was not checking that the functions
    returned the same type.

diff --git a/cc1/types.c b/cc1/types.c
index 40b176b..a9d68e1 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -312,18 +312,13 @@ eqtype(Type *tp1, Type *tp2)
         TINT n;
         Type **p1, **p2;
 
- if (!tp1 || !tp2)
- return 0;
         if (tp1 == tp2)
                 return 1;
+ if (!tp1 || !tp2)
+ return 0;
         if (tp1->op != tp2->op)
                 return 0;
         switch (tp1->op) {
- case ARY:
- if (tp1->n.elem != tp2->n.elem)
- return 0;
- case PTR:
- return eqtype(tp1->type, tp2->type);
         case UNION:
         case STRUCT:
         case FTN:
_AT_@ -334,7 +329,13 @@ eqtype(Type *tp1, Type *tp2)
                         if (!eqtype(*p1++, *p2++))
                                 return 0;
                 }
- return 1;
+ goto check_base;
+ case ARY:
+ if (tp1->n.elem != tp2->n.elem)
+ return 0;
+ case PTR:
+ check_base:
+ return eqtype(tp1->type, tp2->type);
         case VOID:
         case ENUM:
                 return 0;
Received on Fri May 20 2016 - 15:34:07 CEST

This archive was generated by hypermail 2.3.0 : Fri May 20 2016 - 15:36:18 CEST