From 95015f03148cbc029bfe5d1ec2f0f8082e770853 Mon Sep 17 00:00:00 2001 From: tecodev Date: Fri, 27 Apr 2007 08:33:17 +0000 Subject: [PATCH] * src/pic/pcode.c (addpCode2pBlock,LinkFlow,pBlockRemoveUnusedLabels): return early when pb or pb->pcHead is NULL (patch #1708427) * src/regression/empty.c, * src/regression/Makefile: added test with empty functions * support/Util/SDCCerr.c: fixed typo in E_INIT_STRUCT message git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4772 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 8 ++++++++ src/pic/pcode.c | 6 ++++-- src/regression/Makefile | 1 + src/regression/empty.c | 21 +++++++++++++++++++++ support/Util/SDCCerr.c | 2 +- 5 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/regression/empty.c diff --git a/ChangeLog b/ChangeLog index e8fcf812..dee6a8f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-04-27 Raphael Neider + + * src/pic/pcode.c (addpCode2pBlock,LinkFlow,pBlockRemoveUnusedLabels): + return early when pb or pb->pcHead is NULL (patch #1708427) + * src/regression/empty.c, + * src/regression/Makefile: added test with empty functions + * support/Util/SDCCerr.c: fixed typo in E_INIT_STRUCT message + 2007-04-27 Borut Razem * src/SDCCast.c: fixed feature request diff --git a/src/pic/pcode.c b/src/pic/pcode.c index 82290b93..cfbd14df 100644 --- a/src/pic/pcode.c +++ b/src/pic/pcode.c @@ -2550,7 +2550,7 @@ void pCodeReadCodeTable(void) void addpCode2pBlock(pBlock *pb, pCode *pc) { - if(!pc) + if(!pb || !pc) return; if(!pb->pcHead) { @@ -4315,6 +4315,8 @@ void LinkFlow(pBlock *pb) //fprintf(stderr,"linkflow \n"); + if (!pb) return; + for( pcflow = findNextpCode(pb->pcHead, PC_FLOW); pcflow != NULL; pcflow = findNextpCode(pcflow->next, PC_FLOW) ) { @@ -4887,7 +4889,7 @@ void pBlockRemoveUnusedLabels(pBlock *pb) { pCode *pc; pCodeLabel *pcl; - if(!pb) + if(!pb || !pb->pcHead) return; for(pc = pb->pcHead; (pc=findNextInstruction(pc->next)) != NULL; ) { diff --git a/src/regression/Makefile b/src/regression/Makefile index 6066a396..685653cb 100644 --- a/src/regression/Makefile +++ b/src/regression/Makefile @@ -90,6 +90,7 @@ SRC = add.c \ compare8.c \ compare9.c \ configword.c \ + empty.c \ for.c \ inline.c \ mult1.c \ diff --git a/src/regression/empty.c b/src/regression/empty.c new file mode 100644 index 00000000..60522559 --- /dev/null +++ b/src/regression/empty.c @@ -0,0 +1,21 @@ +#include "gpsim_assert.h" + +unsigned char failures = 0; + +void foo(void) { +} + +void bar(int arg0) { +} + +void +done() +{ + ASSERT(MANGLE(failures) == 0); + PASSED(); +} + +void main(void) { + done(); +} + diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index e0aaf930..a6b4cf6f 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -187,7 +187,7 @@ struct { E_INIT_COUNT, ERROR_LEVEL_ERROR, "too many initializers" }, { E_INIT_STRUCT, ERROR_LEVEL_ERROR, - "struct/union/array '%s' :initialization needs curly braces" }, + "struct/union/array '%s': initialization needs curly braces" }, { E_INIT_NON_ADDR, ERROR_LEVEL_ERROR, "non-address initialization expression" }, { E_INT_DEFINED, ERROR_LEVEL_ERROR, -- 2.30.2