X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCClabel.c;h=ba78d47900ceb109c9715d9eada48410e88a2440;hb=51eefdbe8b7ec82630a97151845a8eae2325c899;hp=0b6f7c0ea1b1f56ad8585e1820c10869579f178c;hpb=24b38610695ad1df39fb34e5e63be583035e2e21;p=fw%2Fsdcc diff --git a/src/SDCClabel.c b/src/SDCClabel.c index 0b6f7c0e..ba78d479 100644 --- a/src/SDCClabel.c +++ b/src/SDCClabel.c @@ -35,8 +35,8 @@ buildLabelRefTable (iCode * ic) { iCode *lic; - setToNull ((void **) &labelRef); - setToNull ((void **) &labelDef); + setToNull ((void *) &labelRef); + setToNull ((void *) &labelDef); labelRef = newHashTable (labelKey + 1); labelDef = newHashTable (labelKey + 1); @@ -95,6 +95,36 @@ labelGotoNext (iCode * ic) return change; } +/*-------------------------------------------------------------------*/ +/* deleteIfx - delete an IFX iCode or convert to DUMMY_READ_VOLATILE */ +/*-------------------------------------------------------------------*/ +static void +deleteIfx (iCode * loop, int key) +{ + if (!options.lessPedantic) + { + werrorfl (loop->filename, loop->lineno, W_CONTROL_FLOW); + } + hTabDeleteItem (&labelRef, key, loop, DELETE_ITEM, NULL); + + /* If the condition was volatile, convert IFX to */ + /* DUMMY_READ_VOLATILE. Otherwise just delete the */ + /* IFX iCode */ + if (IS_OP_VOLATILE (IC_COND (loop))) + { + IC_RIGHT (loop) = IC_COND (loop); + IC_LEFT (loop) = NULL; + IC_RESULT (loop) = NULL; + loop->op = DUMMY_READ_VOLATILE; + } + else + { + loop->prev->next = loop->next; + loop->next->prev = loop->prev; + } +} + + /*-----------------------------------------------------------------*/ /* labelIfx - special case Ifx elimination */ /*-----------------------------------------------------------------*/ @@ -119,33 +149,16 @@ labelIfx (iCode * ic) if (IC_TRUE (loop) && IC_TRUE (loop)->key == IC_LABEL (loop->next)->key) { - - /* get rid of this if */ - if (!options.lessPedantic) { - werror (W_CONTROL_FLOW, loop->filename, loop->lineno); - } - loop->prev->next = loop->next; - loop->next->prev = loop->prev; - hTabDeleteItem (&labelRef, - (IC_TRUE (loop))->key, - loop, DELETE_ITEM, NULL); + deleteIfx (loop, IC_TRUE (loop)->key); change++; - continue; + continue; } else { if (IC_FALSE (loop) && IC_FALSE (loop)->key == IC_LABEL (loop->next)->key) { - /* get rid of this if */ - if (!options.lessPedantic) { - werror (W_CONTROL_FLOW, loop->filename, loop->lineno); - } - loop->prev->next = loop->next; - loop->next->prev = loop->prev; - hTabDeleteItem (&labelRef, - (IC_FALSE (loop))->key, - loop, DELETE_ITEM, NULL); + deleteIfx (loop, IC_FALSE (loop)->key); change++; continue; } @@ -160,14 +173,7 @@ labelIfx (iCode * ic) ((IC_TRUE (loop) && IC_TRUE (loop)->key == IC_LABEL (loop->next)->key) || (IC_FALSE (loop) && IC_FALSE (loop)->key == IC_LABEL (loop->next)->key))) { - if (!options.lessPedantic) { - werror (W_CONTROL_FLOW, loop->filename, loop->lineno); - } - loop->prev->next = loop->next; - loop->next->prev = loop->prev; - hTabDeleteItem (&labelRef, - IC_LABEL (loop->next)->key, - loop, DELETE_ITEM, NULL); + deleteIfx (loop, IC_LABEL (loop->next)->key); change++; continue; } @@ -378,7 +384,6 @@ labelUnreach (iCode * ic) /* statement is not a label */ if (loop->op == GOTO || loop->op == RETURN) { - if (loop->next && (loop->next->op == LABEL || loop->next->op == ENDFUNCTION)) @@ -399,12 +404,14 @@ labelUnreach (iCode * ic) hTabDeleteItem (&labelRef, IC_LABEL (tic)->key, tic, DELETE_ITEM, NULL); break; case IFX: + werrorfl (tic->filename, tic->lineno, W_CODE_UNREACH); if (IC_TRUE (tic)) hTabDeleteItem (&labelRef, IC_TRUE (tic)->key, tic, DELETE_ITEM, NULL); else hTabDeleteItem (&labelRef, IC_FALSE (tic)->key, tic, DELETE_ITEM, NULL); break; - + default: + werrorfl (tic->filename, tic->lineno, W_CODE_UNREACH); } }