scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 27af3a9ca569496bd041c227fdfff599bf656a57
parent 93e74dd57e1c6b799ff2b72a36d6feef51c2bf9c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun,  1 Mar 2015 16:40:25 +0000

Add type struct for functions

This is needed because we assign the content of
the type to the node, so if function has no struct
then we will get a segmentation fault.

Diffstat:
Mcc2/parser.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -25,6 +25,10 @@ static Node *listexp[NR_EXPRESSIONS], **listp; static Node nodepool[NR_NODEPOOL], *newp; +Type Funct = { + .letter = L_FUNCTION, +}; + Type l_int8 = { .letter = L_INT8, .size = 1, @@ -194,8 +198,8 @@ gettype(char *type) return &l_uint32; case L_UINT64: return &l_uint64; - case 'F': - return NULL; + case L_FUNCTION: + return &Funct;; default: error(ETYPERR); } @@ -460,7 +464,7 @@ globdcl(char *token) break; } - if (sym->u.v.type.size == 0) + if (sym->u.v.type.letter != L_FUNCTION) return; if (curfun)