From 55da683903458a2f33cc84f1c93d8141a9e1b739 Mon Sep 17 00:00:00 2001 From: bernhardheld Date: Tue, 9 Mar 2004 21:36:07 +0000 Subject: [PATCH] * device/lib/time.c (mktime): fixed bug reported by Bert Thomas * sdcc.spec: updated and split sdcc into 3 rpms * src/SDCCast.c (decorateType): &|^ don't need addCast(); addCast() is needed for literals of LEFT_OP and '+' * src/SDCCicode.c (geniCodeLogic): I must have been braindead when I introduced RESULT_TYPE_NOPROM * src/SDCCsymt.c (computeType): op is int; added RESULT_TYPE_OTHER; limited promotion to int only for '*' * src/SDCCsymt.h (computeType): op is int, removed RESULT_TYPE_NOPROM git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3259 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 8 ++++++++ sdcc.spec | 52 +++++++++++++++++++++++++++++++++++++++++-------- src/SDCCast.c | 14 ++++++++----- src/SDCCicode.c | 2 +- src/SDCCsymt.c | 14 +++++++++++-- src/SDCCsymt.h | 3 +-- 6 files changed, 75 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c9881c8..055c1762 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,14 @@ 2004-03-09 Bernhard Held * device/lib/time.c (mktime): fixed bug reported by Bert Thomas + * sdcc.spec: updated and split sdcc into 3 rpms + * src/SDCCast.c (decorateType): &|^ don't need addCast(); addCast() is + needed for literals of LEFT_OP and '+' + * src/SDCCicode.c (geniCodeLogic): I must have been braindead when I + introduced RESULT_TYPE_NOPROM + * src/SDCCsymt.c (computeType): op is int; added RESULT_TYPE_OTHER; + limited promotion to int only for '*' + * src/SDCCsymt.h (computeType): op is int, removed RESULT_TYPE_NOPROM 2004-03-09 Hans Dorn diff --git a/sdcc.spec b/sdcc.spec index 862be2a9..9d6991ba 100644 --- a/sdcc.spec +++ b/sdcc.spec @@ -4,15 +4,15 @@ Name: sdcc Requires: /bin/sh -License: GPL, LGPL +License: GPL Group: Applications/Engineering -Provides: sdcc Summary: Small Device C Compiler -Version: 2.3.7 -Release: 4 +Requires: sdcc-common +Version: 2.4.0 +Release: 1 Source: %{name}-%{version}.tar.bz2 URL: http://sdcc.sourceforge.net/ -Packager: Bernhard Held +Packager: Bernhard Held BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -21,6 +21,29 @@ The package includes the compiler, assemblers and linkers, a device simulator and a core library. The processors supported (to a varying degree) include the 8051, ds390, z80, hc08, and PIC. +%package common +License: GPL, LGPL +Group: Application/Engineering +Summary: Libraries and Header Files for the SDCC C compiler +Requires: sdcc + +%description common +SDCC is a C compiler for 8051 class and similar microcontrollers. +The package includes the compiler, assemblers and linkers, a device +simulator and a core library. The processors supported (to a varying +degree) include the 8051, ds390, z80, hc08, and PIC. + +%package doc +License: GPL +Group: Applications/Engineering +Summary: Documentation for the SDCC C compiler + +%description doc +SDCC is a C compiler for 8051 class and similar microcontrollers. +The package includes the compiler, assemblers and linkers, a device +simulator and a core library. The processors supported (to a varying +degree) include the 8051, ds390, z80, hc08, and PIC. + %prep %setup -n sdcc @@ -32,21 +55,34 @@ make cd .. %install -rm -rf $RPM_BUILD_ROOT/usr +rm -rf $RPM_BUILD_ROOT make prefix=$RPM_BUILD_ROOT/usr install cd doc make install cd .. +%clean +rm -rf $RPM_BUILD_ROOT + %files %defattr(-,root,root) /usr/bin + +%files common +%defattr(-,root,root) /usr/share/sdcc/include /usr/share/sdcc/lib + +%files doc +%defattr(-,root,root) %doc %{_defaultdocdir} %changelog -* Sun Jan 04 2004 - bernhard@bernhardheld.de +* Tue Mar 09 2004 - bernhard AT bernhardheld.de +- split into two packages +* Wed Feb 26 2004 - bernhard AT bernhardheld.de +- version updated +* Sun Jan 04 2004 - bernhard AT bernhardheld.de - updated -* Sat Apr 27 2002 - steve@icarus.com +* Sat Apr 27 2002 - steve AT icarus.com - first version from Stephen Williams diff --git a/src/SDCCast.c b/src/SDCCast.c index 7f34fdb5..2c167ef1 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -2562,8 +2562,6 @@ decorateType (ast * tree, RESULT_TYPE resultType) return decorateType (otree, RESULT_CHECK); } - tree->left = addCast (tree->left, resultType, FALSE); - tree->right = addCast (tree->right, resultType, FALSE); TTYPE (tree) = computeType (LTYPE (tree), RTYPE (tree), resultType, @@ -2780,8 +2778,6 @@ decorateType (ast * tree, RESULT_TYPE resultType) } LRVAL (tree) = RRVAL (tree) = 1; - tree->left = addCast (tree->left, resultType, FALSE); - tree->right = addCast (tree->right, resultType, FALSE); TETYPE (tree) = getSpec (TTYPE (tree) = computeType (LTYPE (tree), RTYPE (tree), @@ -3066,6 +3062,8 @@ decorateType (ast * tree, RESULT_TYPE resultType) if (IS_LITERAL (RTYPE (tree)) && IS_LITERAL (LTYPE (tree))) { tree->type = EX_VALUE; + tree->left = addCast (tree->left, resultType, TRUE); + tree->right = addCast (tree->right, resultType, TRUE); tree->opval.val = valPlus (valFromType (LETYPE (tree)), valFromType (RETYPE (tree))); tree->right = tree->left = NULL; @@ -3207,6 +3205,8 @@ decorateType (ast * tree, RESULT_TYPE resultType) if (IS_LITERAL (RTYPE (tree)) && IS_LITERAL (LTYPE (tree))) { tree->type = EX_VALUE; + tree->left = addCast (tree->left, resultType, TRUE); + tree->right = addCast (tree->right, resultType, TRUE); tree->opval.val = valMinus (valFromType (LETYPE (tree)), valFromType (RETYPE (tree))); tree->right = tree->left = NULL; @@ -3240,6 +3240,7 @@ decorateType (ast * tree, RESULT_TYPE resultType) { tree->left = addCast (tree->left, resultType, TRUE); tree->right = addCast (tree->right, resultType, TRUE); + TETYPE (tree) = getSpec (TTYPE (tree) = computeType (LTYPE (tree), RTYPE (tree), @@ -3371,6 +3372,10 @@ decorateType (ast * tree, RESULT_TYPE resultType) goto errorTreeReturn; } + /* make smaller type only if it's a LEFT_OP */ + if (tree->opval.op == LEFT_OP) + tree->left = addCast (tree->left, resultType, TRUE); + /* if they are both literal then */ /* rewrite the tree */ if (IS_LITERAL (RTYPE (tree)) && IS_LITERAL (LTYPE (tree))) @@ -3388,7 +3393,6 @@ decorateType (ast * tree, RESULT_TYPE resultType) LRVAL (tree) = RRVAL (tree) = 1; if (tree->opval.op == LEFT_OP) { - tree->left = addCast (tree->left, resultType, TRUE); TETYPE (tree) = getSpec (TTYPE (tree) = computeType (LTYPE (tree), NULL, diff --git a/src/SDCCicode.c b/src/SDCCicode.c index b359b830..cdd103c0 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -2876,7 +2876,7 @@ geniCodeLogic (operand * left, operand * right, int op) } } - ctype = usualBinaryConversions (&left, &right, RESULT_TYPE_NOPROM, 0); + ctype = usualBinaryConversions (&left, &right, RESULT_TYPE_NONE, 0); ic = newiCode (op, left, right); IC_RESULT (ic) = newiTempOperand (newCharLink (), 1); diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 53901c34..dcce5fcc 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1661,7 +1661,7 @@ computeTypeOr (sym_link * etype1, sym_link * etype2, sym_link * reType) /*------------------------------------------------------------------*/ sym_link * computeType (sym_link * type1, sym_link * type2, - RESULT_TYPE resultType, char op) + RESULT_TYPE resultType, int op) { sym_link *rType; sym_link *reType; @@ -1733,6 +1733,7 @@ computeType (sym_link * type1, sym_link * type2, break; case RESULT_TYPE_INT: case RESULT_TYPE_NONE: + case RESULT_TYPE_OTHER: if (IS_BIT (reType)) { SPEC_NOUN (reType) = V_CHAR; @@ -1759,7 +1760,16 @@ computeType (sym_link * type1, sym_link * type2, SPEC_USIGN (reType) = 1; return rType; } - else + else if (op == '*') + { + SPEC_NOUN (reType) = V_INT; + SPEC_USIGN (reType) = 0; + return rType; + } + /* TODO: should be in SDCCast.c */ + else if ( op == '/' + && ( !SPEC_USIGN (etype1) + || !SPEC_USIGN (etype2))) { SPEC_NOUN (reType) = V_INT; SPEC_USIGN (reType) = 0; diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 82acf79b..353f41f6 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -513,7 +513,6 @@ typedef enum RESULT_TYPE_INT, RESULT_TYPE_OTHER, /* operands will be promoted to int */ RESULT_TYPE_IFX, - RESULT_TYPE_NOPROM, /* operands will be promoted to int */ } RESULT_TYPE; /* forward definitions for the symbol table related functions */ @@ -555,7 +554,7 @@ int funcInChain (sym_link *); void addSymChain (symbol *); sym_link *structElemType (sym_link *, value *); symbol *getStructElement (structdef *, symbol *); -sym_link *computeType (sym_link *, sym_link *, RESULT_TYPE, char); +sym_link *computeType (sym_link *, sym_link *, RESULT_TYPE, int); void processFuncArgs (symbol *); int isSymbolEqual (symbol *, symbol *); int powof2 (TYPE_UDWORD); -- 2.30.2