simple C compiler
git clone git://
Log | Files | Refs | README | LICENSE

commit 046982d523fdd935c5b30924de2e143f4fbbf6df
parent eeacd7b393061ba912ee5b07e8550a72cde1596a
Author: Michael Forney <>
Date:   Mon, 20 Feb 2017 10:52:49 -0800

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; }

Mcc1/types.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cc1/types.c b/cc1/types.c @@ -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;