From 4668c0a80e2ffff3b7764c6fd3f35bd610f2cdc8 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Wed, 27 May 2009 05:59:44 +0000 Subject: [PATCH] Fixed a bug which caused a hang when a comma was omitted in a parameter list, followed by an identifier. git-svn-id: http://picoc.googlecode.com/svn/trunk@297 21eae674-98b7-11dd-bd71-f92a316d2d60 --- Makefile | 2 +- expression.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b764713..f30441e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC=gcc -CFLAGS=-Wall -g -DUNIX_HOST #-DDEBUG_LEXER +CFLAGS=-Wall -g -DUNIX_HOST #-DDEBUG_EXPRESSIONS #-DDEBUG_LEXER LIBS=-lm TARGET = picoc diff --git a/expression.c b/expression.c index 7227e6f..7e8a1ec 100644 --- a/expression.c +++ b/expression.c @@ -796,6 +796,8 @@ void ExpressionStackCollapse(struct ParseState *Parser, struct ExpressionStack * break; case OrderNone: + /* this should never happen */ + assert(TopOperatorNode->Order != OrderNone); break; } } @@ -969,6 +971,9 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result) else if (Token == TokenIdentifier) { /* it's a variable, function or a macro */ + if (!PrefixState) + ProgramFail(Parser, "identifier not expected here"); + if (LexGetToken(Parser, NULL, FALSE) == TokenOpenBracket) ExpressionParseFunctionCall(Parser, &StackTop, LexValue->Val->Identifier); else