* src/pic/pcode.c (addpCode2pBlock,LinkFlow,pBlockRemoveUnusedLabels):
[fw/sdcc] / src / SDCCsymt.c
index 8d16e7f7f07fc29ca525a6d6ed7db00ca7772542..618b092f13beec29e85c1d372fa28d6a45c1f6be 100644 (file)
@@ -293,11 +293,11 @@ newSymbol (char *name, int scope)
 
   sym = Safe_alloc ( sizeof (symbol));
 
-  strncpyz (sym->name, name, sizeof(sym->name));        /* copy the name */
-  sym->level = scope;           /* set the level    */
+  strncpyz (sym->name, name, sizeof(sym->name)); /* copy the name */
+  sym->level = scope;           /* set the level */
   sym->block = currBlockno;
-  sym->lineDef = lineno;        /* set the line number */
-  sym->fileDef = filename;
+  sym->lineDef = lexLineno;    /* set the line number */
+  sym->fileDef = lexFilename;
   return sym;
 }
 
@@ -655,6 +655,7 @@ mergeSpec (sym_link * dest, sym_link * src, char *name)
   dest->select.s.b_signed|=src->select.s.b_signed;
   SPEC_STAT (dest) |= SPEC_STAT (src);
   SPEC_EXTR (dest) |= SPEC_EXTR (src);
+  SPEC_INLINE (dest) |= SPEC_INLINE (src);
   SPEC_CONST(dest) |= SPEC_CONST (src);
   SPEC_ABSA (dest) |= SPEC_ABSA (src);
   SPEC_VOLATILE (dest) |= SPEC_VOLATILE (src);
@@ -684,6 +685,7 @@ mergeSpec (sym_link * dest, sym_link * src, char *name)
   FUNC_ISOVERLAY(dest) |= FUNC_ISOVERLAY(src);
   FUNC_INTNO(dest) |= FUNC_INTNO(src);
   FUNC_REGBANK(dest) |= FUNC_REGBANK(src);
+  FUNC_ISINLINE (dest) |= FUNC_ISINLINE (src);
 
   return dest;
 }
@@ -1072,11 +1074,19 @@ addSymChain (symbol ** symHead)
 
       if (!sym->level && !(IS_SPEC(sym->etype) && IS_TYPEDEF(sym->etype)))
         checkDecl (sym, 0);
+      else
+        {
+          /* if this is an array without any dimension
+             then update the dimension from the initial value */
+          if (IS_ARRAY (sym->type) && !DCL_ELEM (sym->type))
+            DCL_ELEM (sym->type) = getNelements (sym->type, sym->ival);
+        }
 
       /* if already exists in the symbol table then check if
-         one of them is an extern definition if yes then
-         then check if the type match, if the types match then
-         delete the current entry and add the new entry      */
+           one of them is an extern definition;
+         if yes then then check if the type match;
+         if the types match then delete the current entry and
+           add the new entry */
       if ((csym = findSymWithLevel (SymbolTab, sym)) &&
           csym->level == sym->level)
         {
@@ -2416,7 +2426,14 @@ checkFunction (symbol * sym, symbol *csym)
       werror(E_SYNTAX_ERROR, sym->name);
       return 0;
     }
-    
+  
+  /* move inline specifier from return type to function attributes */
+  if (IS_INLINE (sym->etype))
+    {
+      SPEC_INLINE (sym->etype) = 0;
+      FUNC_ISINLINE (sym->type) = 1;
+    }
+
   /* make sure the type is complete and sane */
   checkTypeSanity(((symbol *)sym)->etype, ((symbol *)sym)->name);
 
@@ -2874,6 +2891,9 @@ dbuf_printTypeChain (sym_link * start, struct dbuf_s *dbuf)
             if (DCL_PTR_CONST (type)) {
               dbuf_append_str (dbuf, "const-");
             }
+            if (DCL_PTR_RESTRICT (type)) {
+              dbuf_append_str (dbuf, "restrict-");
+            }
           }
           switch (DCL_TYPE (type))
             {
@@ -3025,10 +3045,16 @@ printTypeChainRaw (sym_link * start, FILE * of)
             if (DCL_PTR_CONST (type)) {
               fprintf (of, "const-");
             }
+            if (DCL_PTR_RESTRICT (type)) {
+              fprintf (of, "restrict-");
+            }
           }
           switch (DCL_TYPE (type))
             {
             case FUNCTION:
+              if (IFFUNC_ISINLINE(type)) {
+                fprintf (of, "inline-");
+              }
               fprintf (of, "function %s %s", 
                        (IFFUNC_ISBUILTIN(type) ? "__builtin__" : " "),
                        (IFFUNC_ISJAVANATIVE(type) ? "_JavaNative" : " "));