* src/pic/pcode.c (register_reassign): do not crash on recursive code
[fw/sdcc] / src / pic / pcode.c
index 100a5f76f036b310cd3081ec8bbd5c17efb9f2f1..fa1d6eefa50d9c1467d16ec491a5846f34d5240a 100644 (file)
@@ -5272,6 +5272,17 @@ static unsigned register_reassign(pBlock *pb, unsigned idx)
        pc = setFirstItem(pb->function_entries);
        if(!pc)
                return idx;
+
+       if (pb->visited) {
+           static int output = 0;
+           if (output < 3) {
+               pc = findNextpCode(pb->pcHead, PC_FUNCTION);
+               fprintf(stderr, "WARNING: Recursive code (%s) probably won't work, check the .asm file.\n",
+                       pc ? PCF(pc)->fname : "unknown function");
+               output++;
+           }
+           return idx;
+       }
        
        pb->visited = 1;