* src/pic/pcode.c (addpCode2pBlock,LinkFlow,pBlockRemoveUnusedLabels):
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 27 Apr 2007 08:33:17 +0000 (08:33 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 27 Apr 2007 08:33:17 +0000 (08:33 +0000)
  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
src/pic/pcode.c
src/regression/Makefile
src/regression/empty.c [new file with mode: 0644]
support/Util/SDCCerr.c

index e8fcf8129e6b8a178481c76c324c502aeb33a99e..dee6a8f8e9fe5edcbf10e0adc4880154ab57997e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-04-27 Raphael Neider <rneider AT web.de>
+
+       * 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 <borut.razem AT siol.net>
 
        * src/SDCCast.c: fixed feature request
index 82290b9358a77bf45a4387cf2b987f98e7580583..cfbd14df942efa7e3bc4bdf1ed9c51625ae10632 100644 (file)
@@ -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; ) {
index 6066a396500d123c0ab0732bbb9698ecda9cca6e..685653cba907bd657d17866ebede8276c64c5b0f 100644 (file)
@@ -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 (file)
index 0000000..6052255
--- /dev/null
@@ -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();
+}
+
index e0aaf93031c6779e11aa9745bb632b7927c26c2e..a6b4cf6fe4e37ce0eb834739ebda183ca009d9d4 100644 (file)
@@ -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,