[hackers] [scc] Only add to localtypes if curfun is set || Michael Forney

From: <git_AT_suckless.org>
Date: Mon, 20 Feb 2017 21:36:09 +0100 (CET)

commit 046982d523fdd935c5b30924de2e143f4fbbf6df
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Mon Feb 20 10:52:49 2017 -0800
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Feb 20 21:35:01 2017 +0100

    Only add to localtypes if curfun is set
    Otherwise, a function declaration in the parameters of another function
    will by added to localtypes. If the outermost function is just a
    declaration with no definition, the type will remain in localtypes after
    the declaration. After the next function is defined, flushtypes will
    try to remove the function parameter type and assume that it is at the
    front of the type table, but other types may have been declared in the
    global context since then.
    This fixes an assertion failure when HASH(t) is defined as a constant
      void f(void (*g)(void));
      int main() { return 0; }

diff --git a/cc1/types.c b/cc1/types.c
index 7abb58e..4ea5dea 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -265,7 +265,7 @@ newtype(Type *base)
         *tp = *base;
         tp->id = newid();
- if (curctx > GLOBALCTX+1) {
+ if (curfun) {
                 /* it is a type defined in the body of a function */
                 tp->next = localtypes;
                 localtypes = tp;
Received on Mon Feb 20 2017 - 21:36:09 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2017 - 21:48:15 CET