projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Discovered pointer type for & operation could be incorrect for variables on
[fw/sdcc]
/
src
/
SDCCsymt.c
diff --git
a/src/SDCCsymt.c
b/src/SDCCsymt.c
index 35b18b0131f7d8a35df4d3045feb119b6aa7b597..8074d2224fde75eb0120f2915b3db3ebc3e7ff98 100644
(file)
--- a/
src/SDCCsymt.c
+++ b/
src/SDCCsymt.c
@@
-115,11
+115,13
@@
addSym (bucket ** stab,
bucket *bp; /* temp bucket * */
if (checkType) {
bucket *bp; /* temp bucket * */
if (checkType) {
+ symbol *csym = (symbol *)sym;
+
if (getenv("DEBUG_SANITY")) {
fprintf (stderr, "addSym: %s ", sname);
}
/* make sure the type is complete and sane */
if (getenv("DEBUG_SANITY")) {
fprintf (stderr, "addSym: %s ", sname);
}
/* make sure the type is complete and sane */
- checkTypeSanity(
((symbol *)sym)->etype, ((symbol *)sym)
->name);
+ checkTypeSanity(
csym->etype, csym
->name);
}
/* prevent overflow of the (r)name buffers */
}
/* prevent overflow of the (r)name buffers */
@@
-408,6
+410,9
@@
addDecl (symbol * sym, int type, sym_link * p)
sym_link *tail;
sym_link *t;
sym_link *tail;
sym_link *t;
+ if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+ fprintf (stderr, "SDCCsymt.c:addDecl(%s,%d,%p)\n", sym->name, type, p);
+
/* if we are passed a link then set head & tail */
if (p)
{
/* if we are passed a link then set head & tail */
if (p)
{
@@
-470,6
+475,12
@@
addDecl (symbol * sym, int type, sym_link * p)
SPEC_VOLATILE (sym->etype) = SPEC_VOLATILE (DCL_TSPEC (p));
DCL_TSPEC (p) = NULL;
}
SPEC_VOLATILE (sym->etype) = SPEC_VOLATILE (DCL_TSPEC (p));
DCL_TSPEC (p) = NULL;
}
+
+ // if there is a function in this type chain
+ if (p && funcInChain(sym->type)) {
+ processFuncArgs (sym);
+ }
+
return;
}
return;
}
@@
-771,8
+782,6
@@
getSize (sym_link * p)
/* this is a specifier */
switch (DCL_TYPE (p))
{
/* this is a specifier */
switch (DCL_TYPE (p))
{
- case FUNCTION:
- return 2;
case ARRAY:
return DCL_ELEM (p) * getSize (p->next);
case IPOINTER:
case ARRAY:
return DCL_ELEM (p) * getSize (p->next);
case IPOINTER:
@@
-782,6
+791,7
@@
getSize (sym_link * p)
case EEPPOINTER:
case FPOINTER:
case CPOINTER:
case EEPPOINTER:
case FPOINTER:
case CPOINTER:
+ case FUNCTION:
return (FPTRSIZE);
case GPOINTER:
return (GPTRSIZE);
return (FPTRSIZE);
case GPOINTER:
return (GPTRSIZE);
@@
-830,8
+840,6
@@
bitsForType (sym_link * p)
/* this is a specifier */
switch (DCL_TYPE (p))
{
/* this is a specifier */
switch (DCL_TYPE (p))
{
- case FUNCTION:
- return 2;
case ARRAY:
return DCL_ELEM (p) * getSize (p->next) * 8;
case IPOINTER:
case ARRAY:
return DCL_ELEM (p) * getSize (p->next) * 8;
case IPOINTER:
@@
-841,6
+849,7
@@
bitsForType (sym_link * p)
case EEPPOINTER:
case FPOINTER:
case CPOINTER:
case EEPPOINTER:
case FPOINTER:
case CPOINTER:
+ case FUNCTION:
return (FPTRSIZE * 8);
case GPOINTER:
return (GPTRSIZE * 8);
return (FPTRSIZE * 8);
case GPOINTER:
return (GPTRSIZE * 8);
@@
-1097,10
+1106,12
@@
compStructSize (int su, structdef * sdef)
sum += getSize (loop->type);
}
sum += getSize (loop->type);
}
+#if 0 // jwk: this is done now in addDecl()
/* if function then do the arguments for it */
if (funcInChain (loop->type)) {
/* if function then do the arguments for it */
if (funcInChain (loop->type)) {
- processFuncArgs (loop
, 1
);
+ processFuncArgs (loop);
}
}
+#endif
loop = loop->next;
loop = loop->next;
@@
-1571,11
+1582,10
@@
aggregateToPointer (value * val)
case S_FIXED:
if (SPEC_OCLS(val->etype)) {
DCL_TYPE(val->type)=PTR_TYPE(SPEC_OCLS(val->etype));
case S_FIXED:
if (SPEC_OCLS(val->etype)) {
DCL_TYPE(val->type)=PTR_TYPE(SPEC_OCLS(val->etype));
- break;
- }
-
- if (TARGET_IS_DS390)
- {
+ } else {
+ // this should not happen
+ fprintf (stderr, "wild guess about storage type\n");
+ if (TARGET_IS_DS390) {
/* The AUTO and REGISTER classes should probably
* also become generic pointers, but I haven't yet
* devised a test case for that.
/* The AUTO and REGISTER classes should probably
* also become generic pointers, but I haven't yet
* devised a test case for that.
@@
-1583,11
+1593,12
@@
aggregateToPointer (value * val)
DCL_TYPE (val->type) = GPOINTER;
break;
}
DCL_TYPE (val->type) = GPOINTER;
break;
}
- if (options.model==MODEL_LARGE) {
- DCL_TYPE (val->type) = FPOINTER;
- break;
+ if (options.model==MODEL_LARGE) {
+ DCL_TYPE (val->type) = FPOINTER;
+ break;
+ }
}
}
- /* fall through! */
+ break;
case S_AUTO:
case S_DATA:
case S_REGISTER:
case S_AUTO:
case S_DATA:
case S_REGISTER:
@@
-1760,14
+1771,17
@@
checkFunction (symbol * sym, symbol *csym)
/* processFuncArgs - does some processing with function args */
/*-----------------------------------------------------------------*/
void
/* processFuncArgs - does some processing with function args */
/*-----------------------------------------------------------------*/
void
-processFuncArgs (symbol * func
, int ignoreName
)
+processFuncArgs (symbol * func)
{
value *val;
int pNum = 1;
sym_link *funcType=func->type;
{
value *val;
int pNum = 1;
sym_link *funcType=func->type;
+ if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+ fprintf (stderr, "SDCCsymt.c:processFuncArgs(%s)\n", func->name);
+
// if this is a pointer to a function
// if this is a pointer to a function
- if (
DCL_TYPE(funcType)==CPOINTER
) {
+ if (
IS_PTR(funcType)
) {
funcType=funcType->next;
}
funcType=funcType->next;
}
@@
-1810,11
+1824,6
@@
processFuncArgs (symbol * func, int ignoreName)
aggregateToPointer (val);
}
aggregateToPointer (val);
}
- // jwk: this should not be here
- if (IS_CODEPTR(val->type) && IS_FUNC(val->type->next)) {
- processFuncArgs (val->sym, ignoreName);
- }
-
val = val->next;
pNum++;
}
val = val->next;
pNum++;
}