From 7302de844661b6bf22a486cf9d1ffa0ba64defc2 Mon Sep 17 00:00:00 2001 From: epetrich Date: Fri, 22 Oct 2004 17:20:11 +0000 Subject: [PATCH] * src/SDCCast.c (reverseParms): fixed bug #1040577 (part 2) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3555 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 6 +++++- src/SDCCast.c | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c3cd1e87..3b805b57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-10-22 Erik Petrich + + * src/SDCCast.c (reverseParms): fixed bug #1040577 (part 2) + 2004-10-22 Frieder Ferlemann * device/lib/ser_ir_cts_rts.c: integer promotion caused a call to the @@ -11,7 +15,7 @@ 2004-10-22 Erik Petrich * src/SDCCast.h (struct ast), - * src/SDCCast.c (reverseParms, copyAst): fixed bug #1040577 + * src/SDCCast.c (reverseParms, copyAst): fixed bug #1040577 (part 1) 2004-10-20 Borut Razem diff --git a/src/SDCCast.c b/src/SDCCast.c index f8bb4fc1..1339b3ba 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -633,6 +633,19 @@ reverseParms (ast * ptree) /* top down if we find a nonParm tree then quit */ if (ptree->type == EX_OP && ptree->opval.op == PARAM && !ptree->reversed) { + /* The various functions expect the parameter tree to be right heavy. */ + /* Rotate the tree to be left heavy so that after reversal it is */ + /* right heavy again. */ + while ((ttree = ptree->right) && ttree->type == EX_OP && + ttree->opval.op == PARAM) + { + ptree->right = ttree->right; + ttree->right = ttree->left; + ttree->left = ptree->left; + ptree->left = ttree; + } + + /* Now reverse */ ttree = ptree->left; ptree->left = ptree->right; ptree->right = ttree; -- 2.39.5