ref: 9e2ce8d610b9eacac34979540ed8f6dea47b0ed2
parent: a69c703bb4665df150774ffc1e4cce19db92f9a7
author: Michael Forney <mforney@mforney.org>
date: Mon Feb 20 05:52:49 EST 2017
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 for void f(void (*g)(void)); int main() { return 0; }
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -265,7 +265,7 @@
*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;