+2006-01-18 Bernhard Held <bernhard AT bernhardheld.de>
+
+ * src/SDCCast.c (backPatchLabels): fixed bug #1408066: made it
+ inifinitely recurseable, added static
+ * support/regression/tests/bug-1408066.c: added
+
2006-01-17 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCicode.h,
ast *optimizeGetAbit (ast *, RESULT_TYPE);
ast *optimizeGetByte (ast *, RESULT_TYPE);
ast *optimizeGetWord (ast *, RESULT_TYPE);
-ast *backPatchLabels (ast *, symbol *, symbol *);
+static ast *backPatchLabels (ast *, symbol *, symbol *);
void PA(ast *t);
int inInitMode = 0;
memmap *GcurMemmap=NULL; /* points to the memmap that's currently active */
#define IS_IFX(ex) (ex->type == EX_OP && ex->opval.op == IFX )
#define IS_LT(ex) (ex->type == EX_OP && ex->opval.op == '<' )
#define IS_GT(ex) (ex->type == EX_OP && ex->opval.op == '>')
+#define IS_NULLOP(ex) (ex->type == EX_OP && ex->opval.op == NULLOP)
/*-----------------------------------------------------------------*/
/* backPatchLabels - change and or not operators to flow control */
/*-----------------------------------------------------------------*/
-ast *
+static ast *
backPatchLabels (ast * tree, symbol * trueLabel, symbol * falseLabel)
{
/* change not */
if (IS_NOT (tree))
{
- int wasnot = IS_NOT (tree->left);
+ /* call with exchanged labels */
tree->left = backPatchLabels (tree->left, falseLabel, trueLabel);
- /* if the left is already a IFX */
+ /* if left isn't already a IFX */
if (!IS_IFX (tree->left))
- tree->left = newNode (IFX, tree->left, NULL);
-
- if (wasnot)
- {
- tree->left->trueLabel = trueLabel;
- tree->left->falseLabel = falseLabel;
- }
- else
{
+ tree->left = newNode (IFX, tree->left, NULL);
tree->left->trueLabel = falseLabel;
tree->left->falseLabel = trueLabel;
}
return tree->left;
- }
+ }
if (IS_IFX (tree))
{
--- /dev/null
+/*
+ bug-136564.c0
+
+ loop induction
+*/
+
+#include <testfwk.h>
+
+
+void
+testBackPatchLabel(void)
+{
+ volatile unsigned char c0 = 0, c1 = 1;
+ unsigned char r;
+
+ if ( (c0 == 0)) r = 1; else r = 0; ASSERT(r == 1);
+ if ( !(c0 == 0)) r = 1; else r = 0; ASSERT(r == 0);
+ if ( !!(c0 == 0)) r = 1; else r = 0; ASSERT(r == 1);
+ if ( !!!(c0 == 0)) r = 1; else r = 0; ASSERT(r == 0);
+ if ( !!!!(c0 == 0)) r = 1; else r = 0; ASSERT(r == 1);
+ if (!!!!!(c0 == 0)) r = 1; else r = 0; ASSERT(r == 0);
+
+ if ( ((c0 == 0) && (c1 == 1))) r = 1; else r = 0; ASSERT(r == 1);
+ if ( !((c0 == 0) && (c1 == 1))) r = 1; else r = 0; ASSERT(r == 0);
+ if ( !!((c0 == 0) && (c1 == 1))) r = 1; else r = 0; ASSERT(r == 1);
+
+ if ( ( (c0 == 0) && (c1 == 1))) r = 1; else r = 0; ASSERT(r == 1);
+ if ( !( !(c0 == 1) && !(c1 == 0))) r = 1; else r = 0; ASSERT(r == 0);
+ if ( !!(!!(c0 == 0) && !!(c1 == 1))) r = 1; else r = 0; ASSERT(r == 1);
+}