if (bp->level && bp->level == sym->level && bp->block == sym->block)
return (bp->sym);
/* if levels don't match then we are okay */
- if (bp->level && bp->level != sym->level)
+ if (bp->level && bp->level != sym->level && bp->block <= sym->block)
return (bp->sym);
/* if this is a global variable then we are ok too */
if (bp->level == 0)
if (SPEC_NOUN (dest) != SPEC_NOUN (src) && !SPEC_NOUN (dest))
SPEC_NOUN (dest) = SPEC_NOUN (src);
- if (!SPEC_SCLS (dest)) /* if destination has no storage class */
+ /* if destination has no storage class */
+ if (!SPEC_SCLS (dest) ||
+ ((SPEC_SCLS(dest) == S_CONSTANT || SPEC_SCLS(dest) == S_REGISTER) &&
+ SPEC_SCLS (src)))
SPEC_SCLS (dest) = SPEC_SCLS (src);
-
+ /* special case for const */
/* copy all the specifications */
SPEC_LONG (dest) |= SPEC_LONG (src);
SPEC_SHORT (dest) |= SPEC_SHORT (src);
for (; sym != NULL; sym = sym->next)
{
-
+ changePointer(sym);
/* if already exists in the symbol table then check if
the previous was an extern definition if yes then
then check if the type match, if the types match then
int
compStructSize (int su, structdef * sdef)
{
- int sum = 0, usum = 0;
- int bitOffset = 0;
- symbol *loop;
-
- /* for the identifiers */
- loop = sdef->fields;
- while (loop)
- {
-
- /* create the internal name for this variable */
- sprintf (loop->rname, "_%s", loop->name);
- loop->offset = (su == UNION ? sum = 0 : sum);
- SPEC_VOLATILE (loop->etype) |= (su == UNION ? 1 : 0);
-
- /* if this is a bit field */
- if (loop->bitVar)
- {
-
- /* change it to a unsigned bit */
- SPEC_NOUN (loop->etype) = V_BIT;
- SPEC_USIGN (loop->etype) = 1;
- /* check if this fit into the remaining */
- /* bits of this byte else align it to the */
- /* next byte boundary */
- if ((SPEC_BLEN (loop->etype) = loop->bitVar) <= (8 - bitOffset))
- {
- SPEC_BSTR (loop->etype) = bitOffset;
- if ((bitOffset += (loop->bitVar % 8)) == 8)
- sum++;
+ int sum = 0, usum = 0;
+ int bitOffset = 0;
+ symbol *loop;
+
+ /* for the identifiers */
+ loop = sdef->fields;
+ while (loop) {
+
+ /* create the internal name for this variable */
+ sprintf (loop->rname, "_%s", loop->name);
+ loop->offset = (su == UNION ? sum = 0 : sum);
+ SPEC_VOLATILE (loop->etype) |= (su == UNION ? 1 : 0);
+
+ /* if this is a bit field */
+ if (loop->bitVar) {
+
+ /* change it to a unsigned bit */
+ SPEC_NOUN (loop->etype) = V_BIT;
+ SPEC_USIGN (loop->etype) = 1;
+ /* check if this fit into the remaining */
+ /* bits of this byte else align it to the */
+ /* next byte boundary */
+ if ((SPEC_BLEN (loop->etype) = loop->bitVar) <= (8 - bitOffset)) {
+ SPEC_BSTR (loop->etype) = bitOffset;
+ if ((bitOffset += (loop->bitVar % 8)) == 8)
+ sum++;
}
- else
- /* does not fit */
- {
- bitOffset = 0;
- SPEC_BSTR (loop->etype) = bitOffset;
- sum += (loop->bitVar / 8);
- bitOffset += (loop->bitVar % 8);
+ else /* does not fit */ {
+ bitOffset = 0;
+ SPEC_BSTR (loop->etype) = bitOffset;
+ sum += (loop->bitVar / 8);
+ bitOffset += (loop->bitVar % 8);
}
- /* if this is the last field then pad */
- if (!loop->next && bitOffset && bitOffset != 8)
- {
- bitOffset = 0;
- sum++;
+ /* if this is the last field then pad */
+ if (!loop->next && bitOffset && bitOffset != 8) {
+ bitOffset = 0;
+ sum++;
}
}
- else
- {
- checkDecl (loop);
- sum += getSize (loop->type);
+ else {
+ checkDecl (loop);
+ sum += getSize (loop->type);
}
- /* if function then do the arguments for it */
- if (funcInChain (loop->type))
- {
- processFuncArgs (loop, 1);
+ /* if function then do the arguments for it */
+ if (funcInChain (loop->type)) {
+ processFuncArgs (loop, 1);
}
- loop = loop->next;
+ loop = loop->next;
- /* if this is not a bitfield but the */
- /* previous one was and did not take */
- /* the whole byte then pad the rest */
- if ((loop && !loop->bitVar) && bitOffset)
- {
- bitOffset = 0;
- sum++;
+ /* if this is not a bitfield but the */
+ /* previous one was and did not take */
+ /* the whole byte then pad the rest */
+ if ((loop && !loop->bitVar) && bitOffset) {
+ bitOffset = 0;
+ sum++;
}
- /* if union then size = sizeof larget field */
- if (su == UNION)
- usum = max (usum, sum);
+ /* if union then size = sizeof larget field */
+ if (su == UNION)
+ usum = max (usum, sum);
}
- return (su == UNION ? usum : sum);
+ return (su == UNION ? usum : sum);
}
/*------------------------------------------------------------------*/
* control this allcoation, but the code was originally that way, and
* changing it for non-390 ports breaks the compiler badly.
*/
- bool useXdata = IS_DS390_PORT ? options.model : options.useXstack;
+ bool useXdata = TARGET_IS_DS390 ? 1 : options.useXstack;
SPEC_SCLS (sym->etype) = (useXdata ?
S_XDATA : S_FIXED);
}
DCL_TYPE (val->type) = PPOINTER;
break;
case S_FIXED:
- if (IS_DS390_PORT)
+ if (TARGET_IS_DS390)
{
/* The AUTO and REGISTER classes should probably
* also become generic pointers, but I haven't yet
value *val;
int pNum = 1;
-
/* if this function has variable argument list */
/* then make the function a reentrant one */
if (func->hasVargs)
and as port dictates
not inhibited by command line option or #pragma */
if (!func->hasVargs &&
- !options.noregparms &&
- !IS_RENT (func->etype) &&
(*port->reg_parm) (val->type))
{
SPEC_REGPARM (val->etype) = 1;
pNum++;
}
- /* if this function is reentrant or */
- /* automatics r 2b stacked then nothing */
- if (IS_RENT (func->etype) || options.stackAuto)
- return;
+ /* if this is an internal generated function call */
+ if (func->cdef) {
+ /* ignore --stack-auto for this one, we don't know how it is compiled */
+ /* simply trust on --int-long-reent or --float-reent */
+ if (IS_RENT(func->etype)) {
+ return;
+ }
+ } else {
+ /* if this function is reentrant or */
+ /* automatics r 2b stacked then nothing */
+ if (IS_RENT (func->etype) || options.stackAuto)
+ return;
+ }
val = func->args;
pNum = 1;
return (!strcmp (dest->name, src->name));
}
+void PT(sym_link *type)
+{
+ printTypeChain(type,0);
+}
/*-----------------------------------------------------------------*/
/* printTypeChain - prints the type chain in human readable form */
/*-----------------------------------------------------------------*/
{
if (IS_DECL (type))
{
+ if (DCL_PTR_VOLATILE(type)) {
+ fprintf (of, "volatile ");
+ }
switch (DCL_TYPE (type))
{
case FUNCTION:
if (DCL_PTR_CONST (type))
fprintf (of, "const ");
break;
-
case ARRAY:
fprintf (of, "array of ");
break;
fprintf (of, "volatile ");
if (SPEC_USIGN (type))
fprintf (of, "unsigned ");
+ if (SPEC_CONST (type))
+ fprintf (of, "const ");
switch (SPEC_NOUN (type))
{
while (val)
{
SPEC_REGPARM (val->etype) = 1;
- sym->argStack -= getSize (val->type);
val = val->next;
}
}