some small dumptree enhancements
[fw/sdcc] / src / SDCCsymt.c
index 0a5767de762f9a27371adaf43e264adc807af809..cf62005782bb4e24cf566409bc3f815367c1fcfa 100644 (file)
@@ -549,8 +549,14 @@ mergeSpec (sym_link * dest, sym_link * src, char *name)
   sym_link *symlink=dest;
 
   if (!IS_SPEC(dest) || !IS_SPEC(src)) {
+#if 0
     werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "cannot merge declarator");
     exit (1);
+#else
+    werror (E_SYNTAX_ERROR, yytext);
+    // the show must go on
+    return newIntLink();
+#endif
   }
 
   if (SPEC_NOUN(src)) {
@@ -596,6 +602,7 @@ mergeSpec (sym_link * dest, sym_link * src, char *name)
   dest->select.s._signed|=src->select.s._signed;
   SPEC_STAT (dest) |= SPEC_STAT (src);
   SPEC_EXTR (dest) |= SPEC_EXTR (src);
+  SPEC_CONST(dest) |= SPEC_CONST (src);
   SPEC_ABSA (dest) |= SPEC_ABSA (src);
   SPEC_VOLATILE (dest) |= SPEC_VOLATILE (src);
   SPEC_ADDR (dest) |= SPEC_ADDR (src);
@@ -1757,23 +1764,29 @@ processFuncArgs (symbol * func, int ignoreName)
 {
   value *val;
   int pNum = 1;
+  sym_link *funcType=func->type;
+
+  // if this is a pointer to a function
+  if (DCL_TYPE(funcType)==CPOINTER) {
+    funcType=funcType->next;
+  }
 
   /* if this function has variable argument list */
   /* then make the function a reentrant one    */
-  if (IFFUNC_HASVARARGS(func->type))
-    FUNC_ISREENT(func->type)=1;
+  if (IFFUNC_HASVARARGS(funcType))
+    FUNC_ISREENT(funcType)=1;
 
   /* check if this function is defined as calleeSaves
      then mark it as such */
-  FUNC_CALLEESAVES(func->type) = inCalleeSaveList (func->name);
+  FUNC_CALLEESAVES(funcType) = inCalleeSaveList (func->name);
 
   /* loop thru all the arguments   */
-  val = FUNC_ARGS(func->type);
+  val = FUNC_ARGS(funcType);
 
   /* if it is void then remove parameters */
   if (val && IS_VOID (val->type))
     {
-      FUNC_ARGS(func->type) = NULL;
+      FUNC_ARGS(funcType) = NULL;
       return;
     }
 
@@ -1786,7 +1799,7 @@ processFuncArgs (symbol * func, int ignoreName)
       /* mark it as a register parameter if
          the function does not have VA_ARG
          and as port dictates */
-      if (!IFFUNC_HASVARARGS(func->type) &&
+      if (!IFFUNC_HASVARARGS(funcType) &&
          (*port->reg_parm) (val->type))
        {
          SPEC_REGPARM (val->etype) = 1;
@@ -1796,6 +1809,12 @@ processFuncArgs (symbol * func, int ignoreName)
        {
          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++;
     }
@@ -1804,17 +1823,17 @@ processFuncArgs (symbol * func, int ignoreName)
   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 (IFFUNC_ISREENT(func->type)) {
+    if (IFFUNC_ISREENT(funcType)) {
       return;
     }
   } else {
     /* if this function is reentrant or */
     /* automatics r 2b stacked then nothing */
-    if (IFFUNC_ISREENT (func->type) || options.stackAuto)
+    if (IFFUNC_ISREENT (funcType) || options.stackAuto)
       return;
   }
 
-  val = FUNC_ARGS(func->type);
+  val = FUNC_ARGS(funcType);
   pNum = 1;
   while (val)
     {
@@ -1893,7 +1912,7 @@ printTypeChain (sym_link * start, FILE * of)
     }
 
   if (start==NULL) {
-    fprintf (of, "**err**");
+    fprintf (of, "void");
     return;
   }