+2006-06-19 Raphael Neider <rneider AT web.de>
+
+ * src/pic/glue.h,src/pic16/glue.h: added prototypes
+ * src/pic/glue.c,src/pic16/glue.c (pic1x_stringInSet,
+ pic1x_emitSymbolIfNew): NEW, check for a string in a set,
+ (pic14printExterns,pic14printPublics,pic16printPublics,
+ pic16_printExterns): use new functions to emit symbols
+ (picglue,pic16glue): emit publics before emitting externs
+ * src/pic/gen.c,src/pic16/gen.c (genFunction): remember the names of
+ locally defined functions to avoid bug #1443651
+ * support/regression/tests/bug-716242.c: removed pic16 workaround
+ * support/regression/ports/pic16/spec.mk: ignore errors during build
+
2006-06-19 Raphael Neider <rneider AT web.de>
* src/pic/glue.h: added pic14aopLiteral prototype
pic14_emitcode(";"," function %s",(sym = OP_SYMBOL(IC_LEFT(ic)))->name);
pic14_emitcode(";","-----------------------------------------");
+ /* prevent this symbol from being emitted as 'extern' */
+ pic14_stringInSet(sym->rname, &pic14_localFunctions, 1);
+
pic14_emitcode("","%s:",sym->rname);
addpCode2pBlock(pb,newpCodeFunction(NULL,sym->rname,!IS_STATIC (sym->etype)));
extern char *iComments1;
extern char *iComments2;
//extern void emitStaticSeg (memmap * map);
+set *pic14_localFunctions = NULL;
extern DEFSETFUNC (closeTmpFiles);
extern DEFSETFUNC (rmTmpFiles);
}
+int
+pic14_stringInSet(const char *str, set **world, int autoAdd)
+{
+ char *s;
+
+ if (!str) return 1;
+ assert(world);
+
+ for (s = setFirstItem(*world); s; s = setNextItem(*world))
+ {
+ /* found in set */
+ if (0 == strcmp(s, str)) return 1;
+ }
+
+ /* not found */
+ if (autoAdd) addSet(world, Safe_strdup(str));
+ return 0;
+}
+
+static int
+pic14_emitSymbolIfNew(FILE *file, const char *fmt, const char *sym, int checkLocals)
+{
+ static set *emitted = NULL;
+
+ if (!pic14_stringInSet(sym, &emitted, 1)) {
+ /* sym was not in emittedSymbols */
+ if (!checkLocals || !pic14_stringInSet(sym, &pic14_localFunctions, 0)) {
+ /* sym is not a locally defined function---avoid bug #1443651 */
+ fprintf( file, fmt, sym );
+ return 0;
+ }
+ }
+ return 1;
+}
+
/*-----------------------------------------------------------------*/
/* printExterns - generates extern for external variables */
/*-----------------------------------------------------------------*/
fprintf (afile, "; extern variables in this module\n");
fprintf (afile, "%s", iComments2);
- for (sym = setFirstItem (externs); sym;
- sym = setNextItem (externs))
- fprintf (afile, "\textern %s\n", sym->rname);
+ for (sym = setFirstItem (externs); sym; sym = setNextItem (externs))
+ pic14_emitSymbolIfNew(afile, "\textern %s\n", sym->rname, 1);
}
/*-----------------------------------------------------------------*/
static void
pic14printPublics (FILE * afile)
{
- symbol *sym;
-
- fprintf (afile, "%s", iComments2);
- fprintf (afile, "; publics variables in this module\n");
- fprintf (afile, "%s", iComments2);
-
- for (sym = setFirstItem (publics); sym;
- sym = setNextItem (publics)) {
-
- if(!IS_BITFIELD(sym->type) && ((IS_FUNC(sym->type) || sym->allocreq))) {
- if (!IS_BITVAR(sym->type))
- fprintf (afile, "\tglobal %s\n", sym->rname);
- } else {
- /* Absolute variables are defines in the asm file as equates and thus can not be made global. */
- /* Not any longer! */
- //if (!SPEC_ABSA (sym->etype))
- fprintf (afile, "\tglobal %s\n", sym->rname);
- }
- }
+ symbol *sym;
+
+ fprintf (afile, "%s", iComments2);
+ fprintf (afile, "; publics variables in this module\n");
+ fprintf (afile, "%s", iComments2);
+
+ for (sym = setFirstItem (publics); sym;
+ sym = setNextItem (publics)) {
+
+ if(!IS_BITFIELD(sym->type) && ((IS_FUNC(sym->type) || sym->allocreq))) {
+ if (!IS_BITVAR(sym->type))
+ pic14_emitSymbolIfNew(afile, "\tglobal %s\n", sym->rname, 0);
+ } else {
+ /* Absolute variables are defines in the asm file as equates and thus can not be made global. */
+ /* Not any longer! */
+ //if (!SPEC_ABSA (sym->etype))
+ pic14_emitSymbolIfNew(afile, "\tglobal %s\n", sym->rname, 0);
+ }
+ }
}
/*-----------------------------------------------------------------*/
/* Emit the __config directive */
pic14_emitConfigWord (asmFile);
- /* print the extern variables in this module */
- pic14printExterns (asmFile);
-
/* print the global variables in this module */
pic14printPublics (asmFile);
+ /* print the extern variables in this module */
+ pic14printExterns (asmFile);
+
/* copy the sfr segment */
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; special function registers\n");
#ifndef PIC_GLUE_H
#define PIC_GLUE_H
+#include "../SDCCset.h"
+
+extern set *pic14_localFunctions;
+
void picglue (void);
unsigned int pic14aopLiteral (value *val, int offset);
+int pic14_stringInSet(const char *str, set **world, int autoAdd);
#endif
pic16_emitcode(";"," function %s",sym->name);
pic16_emitcode(";","-----------------------------------------");
+ /* prevent this symbol from being emitted as 'extern' */
+ pic16_stringInSet(sym->rname, &pic16_localFunctions, 1);
+
pic16_emitcode("","%s:",sym->rname);
pic16_addpCode2pBlock(pb,pic16_newpCodeFunction(moduleName,sym->rname));
extern unsigned long pFile_isize;
extern unsigned long pic16_countInstructions();
+set *pic16_localFunctions = NULL;
set *rel_idataSymSet=NULL;
set *fix_idataSymSet=NULL;
}
}
+int
+pic16_stringInSet(const char *str, set **world, int autoAdd)
+{
+ char *s;
+
+ if (!str) return 1;
+ assert(world);
+
+ for (s = setFirstItem(*world); s; s = setNextItem(*world))
+ {
+ /* found in set */
+ if (0 == strcmp(s, str)) return 1;
+ }
+
+ /* not found */
+ if (autoAdd) addSet(world, Safe_strdup(str));
+ return 0;
+}
+
+static int
+pic16_emitSymbolIfNew(FILE *file, const char *fmt, const char *sym, int checkLocals)
+{
+ static set *emitted = NULL;
+
+ if (!pic16_stringInSet(sym, &emitted, 1)) {
+ /* sym was not in emittedSymbols */
+ if (!checkLocals || !pic16_stringInSet(sym, &pic16_localFunctions, 0)) {
+ /* sym is not a locally defined function---avoid bug #1443651 */
+ fprintf( file, fmt, sym );
+ return 0;
+ }
+ }
+ return 1;
+}
+
/*-----------------------------------------------------------------*/
/* printPublics - generates global declarations for publics */
/*-----------------------------------------------------------------*/
for(sym = setFirstItem (publics); sym; sym = setNextItem (publics))
/* sanity check */
if(!IS_STATIC(sym->etype))
- fprintf(afile, "\tglobal %s\n", sym->rname);
+ pic16_emitSymbolIfNew(afile, "\tglobal %s\n", sym->rname, 0);
}
/*-----------------------------------------------------------------*/
fprintf(afile, "%s", iComments2);
for(sym = setFirstItem(externs); sym; sym = setNextItem(externs))
- fprintf(afile, "\textern %s\n", sym->rname);
+ pic16_emitSymbolIfNew(afile, "\textern %s\n", sym->rname, 1);
for(sym = setFirstItem(pic16_builtin_functions); sym; sym = setNextItem(pic16_builtin_functions))
- fprintf(afile, "\textern _%s\n", sym->name);
+ pic16_emitSymbolIfNew(afile, "\textern _%s\n", sym->name, 1);
}
/*-----------------------------------------------------------------*/
pic16_OptimizeJumps();
}
- /* print the extern variables to this module */
- pic16_printExterns(asmFile);
-
/* print the global variables in this module */
pic16printPublics (asmFile);
+ /* print the extern variables to this module */
+ pic16_printExterns(asmFile);
+
pic16_writeUsedRegs(asmFile);
#if 0
#ifndef PIC16_GLUE_H
#define PIC16_GLUE_H
+#include "SDCCset.h"
+
+extern set *pic16_localFunctions;
+
void pic16glue (void);
unsigned int pic16aopLiteral (value *val, int offset);
+int pic16_stringInSet(const char *str, set **world, int autoAdd);
#endif
# Rule to link into .ihx
%$(EXEEXT): %$(OBJEXT) $(EXTRAS)
- $(SDCC) $(SDCCFLAGS) $(LINKFLAGS) -L $(LIBDIR) $(EXTRAS) $< -o $@
+ -$(SDCC) $(SDCCFLAGS) $(LINKFLAGS) -L $(LIBDIR) $(EXTRAS) $< -o $@
%$(OBJEXT): %.c
- $(SDCC) $(SDCCFLAGS) -c $< -o $@
+ -$(SDCC) $(SDCCFLAGS) -c $< -o $@
$(PORT_CASES_DIR)/%$(OBJEXT): $(PORTS_DIR)/$(PORT)/%.c
- $(SDCC) $(SDCCFLAGS) -c $< -o $@
+ -$(SDCC) $(SDCCFLAGS) -c $< -o $@
.PRECIOUS: gen/pic16/testfwk.o gen/pic16/support.o
/****************************/
-#ifndef SDCC_pic16
-// Ifdefed out for PIC16 port since it generates the error:
-// Duplicate label or redefinin g symbol that cannot be redefined. (_g)
-// Submitted to the bug tracker:
-// [ 1443651 ] pic 16: redefining symbol that cannot be redefined. (_g)
-
void g (int (*h) (int));
-#endif
void f2()
{
/****************************/
-#ifndef SDCC_pic16
-// Ifdefed out for PIC16 port since it generates the error:
-// Duplicate label or redefinin g symbol that cannot be redefined. (_g)
-// Submitted to the bug tracker:
-// [ 1443651 ] pic 16: redefining symbol that cannot be redefined. (_g)
-
void g (int (*h) (int));
-#endif
void f3()
{