From 386892a5bfdf4fb876a330d474fe2a04721c8f18 Mon Sep 17 00:00:00 2001 From: johanknol Date: Mon, 11 Jun 2001 08:59:06 +0000 Subject: [PATCH] Fixed my "unsigned vs unsigned char" error git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@877 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCC.y | 2 -- src/SDCCsymt.c | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/SDCC.y b/src/SDCC.y index ec90153a..59c7b982 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -582,13 +582,11 @@ type_specifier2 | SIGNED { $$=newLink(); $$->class = SPECIFIER ; - SPEC_NOUN($$) = V_INT ; SPEC_SIGNED($$) = 1 ; } | UNSIGNED { $$=newLink(); $$->class = SPECIFIER ; - SPEC_NOUN($$) = V_INT ; SPEC_USIGN($$) = 1 ; } | VOID { diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 07b39065..6f20b982 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -103,6 +103,9 @@ addSym (bucket ** stab, int i; /* index into the hash Table */ bucket *bp; /* temp bucket * */ + if (getenv("DEBUG_SANITY")) { + fprintf (stderr, "addSym: %s\n", sname); + } /* Make sure sym is a symbol and not a structdef */ if (StructTab!=stab) checkTypeSanity(((symbol *)sym)->etype, sname); @@ -456,13 +459,17 @@ void checkTypeSanity(sym_link *dest, char *name) { char *noun; if (!dest) { - //printf ("sanity check skipped for %s\n", name); + if (getenv("DEBUG_SANITY")) { + printf ("sanity check skipped for %s\n", name); + } return; } noun=nounName(dest); - //printf ("checking sanity for %s\n", name); + if (getenv("DEBUG_SANITY")) { + printf ("checking sanity for %s\n", name); + } if ((SPEC_NOUN(dest)==V_CHAR || SPEC_NOUN(dest)==V_FLOAT || @@ -479,6 +486,13 @@ void checkTypeSanity(sym_link *dest, char *name) { // signed or unsigned for float double or void werror (E_SIGNED_OR_UNSIGNED_INVALID, noun, name); } + + if (!SPEC_NOUN(dest)) { + if (SPEC_SIGNED(dest) || SPEC_USIGN(dest)) { + SPEC_NOUN(dest)=V_INT; + } + } + if (SPEC_SIGNED(dest) && SPEC_USIGN(dest)) { // signed AND unsigned werror (E_SIGNED_AND_UNSIGNED_INVALID, noun, name); @@ -500,6 +514,9 @@ mergeSpec (sym_link * dest, sym_link * src) /* we shouldn't redeclare the type */ if ((SPEC_NOUN (dest) && SPEC_NOUN (src)) && (SPEC_NOUN(dest) != SPEC_NOUN(src))) { + if (getenv("DEBUG_SANITY")) { + fprintf (stderr, "mergeSpec: "); + } werror(E_TWO_OR_MORE_DATA_TYPES, yylval.yychar); } -- 2.30.2