compiler/libec/output: Setting line numbers on all declaration
authorJerome St-Louis <jerome@ecere.com>
Fri, 30 May 2014 21:35:58 +0000 (17:35 -0400)
committerJerome St-Louis <jerome@ecere.com>
Fri, 30 May 2014 21:35:58 +0000 (17:35 -0400)
- Some GCC warnings were coming up on the generated C file

compiler/bootstrap/libec/bootstrap/output.c
compiler/libec/src/output.ec

index 6c2fa3b..4e6dce6 100644 (file)
@@ -3304,38 +3304,31 @@ OutputInitializer(decl->initializer, f);
 }
 }
 
+extern char *  strcpy(char * , const char * );
+
 static void OutputDeclaration(struct Declaration * decl, struct __ecereNameSpace__ecere__com__Instance * f)
 {
 struct Specifier * spec;
-char origName[274] = "";
-
-switch(decl->type)
-{
-case 1:
-{
-struct InitDeclarator * d;
+char origName[274];
+char name[274];
 
 if(inCompiler)
 {
-__ecereNameSpace__ecere__sys__PathCat(origName, outputFile);
+strcpy(origName, outputFile);
 __ecereNameSpace__ecere__sys__ChangeCh(origName, '\\', '/');
 }
-if(decl->declarators && (*decl->declarators).first)
-{
-for(d = (*decl->declarators).first; d; d = d->next)
-if(d->initializer)
-{
-char name[274] = "";
-
 GetSourceName(name, decl->loc.start.included ? GetIncludeFileFromID(decl->loc.start.included) : (((void *)0)));
 if(inCompiler && outputLineNumbers && decl->loc.start.line)
 {
 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "\n#line %d \"%s\"\n", decl->loc.start.line, name);
 outputLine += 2;
 }
-break;
-}
-}
+switch(decl->type)
+{
+case 1:
+{
+struct InitDeclarator * d;
+
 if(decl->specifiers)
 {
 unsigned int inTypeDef = 0x0;
@@ -3434,7 +3427,7 @@ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = f;
 __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl;
 })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Puts])(f, ";\n");
 outputLine++;
-if(inCompiler && outputLineNumbers && decl->loc.start.line && decl->type == 1)
+if(inCompiler && outputLineNumbers && decl->loc.start.line)
 {
 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "\n#line %d \"%s\"\n", outputLine + 2, origName);
 outputLine += 2;
index 291c68a..0247b7f 100644 (file)
@@ -1164,7 +1164,21 @@ static void OutputInitDeclarator(InitDeclarator decl, File f)
 static void OutputDeclaration(Declaration decl, File f)
 {
    Specifier spec;
-   char origName[MAX_FILENAME] = "";
+   char origName[MAX_FILENAME];
+   char name[MAX_FILENAME];
+
+   if(inCompiler)
+   {
+      strcpy(origName, outputFile);
+      ChangeCh(origName, '\\', '/');
+   }
+   GetSourceName(name, decl.loc.start.included ? GetIncludeFileFromID(decl.loc.start.included) : null);
+
+   if(inCompiler && outputLineNumbers && decl.loc.start.line)
+   {
+      f.Printf("\n#line %d \"%s\"\n", decl.loc.start.line, name);
+      outputLine += 2;
+   }
 
    switch(decl.type)
    {
@@ -1173,13 +1187,8 @@ static void OutputDeclaration(Declaration decl, File f)
          InitDeclarator d;
 
          //GetWorkingDir(origName, sizeof(origName));
-         if(inCompiler)
-         {
-            PathCat(origName, outputFile);
-            ChangeCh(origName, '\\', '/');
-         }
 
-         if(decl.declarators && decl.declarators->first)
+         /*if(decl.declarators && decl.declarators->first)
          {
             for(d = decl.declarators->first; d; d = d.next)
                if(d.initializer)
@@ -1190,15 +1199,12 @@ static void OutputDeclaration(Declaration decl, File f)
 
                   if(inCompiler && outputLineNumbers && decl.loc.start.line)
                   {
-                     /*if(decl.loc.start.line == 1)
-                        printf("bug");*/
-
                      f.Printf("\n#line %d \"%s\"\n", decl.loc.start.line, name);
                      outputLine += 2;
                   }
                   break;
                }
-         }
+         }*/
 
          if(decl.specifiers)
          {
@@ -1262,7 +1268,7 @@ static void OutputDeclaration(Declaration decl, File f)
    }
    f.Puts(";\n");
    outputLine ++;
-   if(inCompiler && outputLineNumbers && decl.loc.start.line && decl.type == initDeclaration)
+   if(inCompiler && outputLineNumbers && decl.loc.start.line)
    {
       f.Printf("\n#line %d \"%s\"\n", outputLine+2, origName);
       outputLine += 2;