From c3d083fe334d59ae18b874c626881477551d0c5d Mon Sep 17 00:00:00 2001 From: JT Date: Mon, 20 Jul 2015 18:55:25 -0400 Subject: [PATCH 01/17] Fix bug #182 --- src/ca65/scanner.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 20053e7e6..9df28a8af 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1417,13 +1417,17 @@ CharAgain: case '\\': /* Line continuation? */ if (LineCont) { - NextChar (); + NextChar(); + /* Next char should be a LF, if not, will result in an error later */ if (C == '\n') { - /* Handle as white space */ - NextChar (); - C = ' '; + /* Ignore the '\n' */ + NextChar(); goto Again; } + else { + /* Make it clear what the problem is: */ + Error("EOL expected."); + } } break; From 10579d04213be5d3360d1f713aab22272f287175 Mon Sep 17 00:00:00 2001 From: JT Date: Mon, 20 Jul 2015 19:12:30 -0400 Subject: [PATCH 02/17] Fix style --- src/ca65/scanner.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 9df28a8af..16e67ee8a 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1417,16 +1417,16 @@ CharAgain: case '\\': /* Line continuation? */ if (LineCont) { - NextChar(); + NextChar (); /* Next char should be a LF, if not, will result in an error later */ if (C == '\n') { /* Ignore the '\n' */ - NextChar(); + NextChar (); goto Again; } else { /* Make it clear what the problem is: */ - Error("EOL expected."); + Error ("EOL expected."); } } break; From cacc5e2acee7672932aeb98092f5e2942e13aeb8 Mon Sep 17 00:00:00 2001 From: JT Date: Mon, 20 Jul 2015 19:16:48 -0400 Subject: [PATCH 03/17] Style again --- src/ca65/scanner.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 16e67ee8a..aaba56764 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1423,8 +1423,7 @@ CharAgain: /* Ignore the '\n' */ NextChar (); goto Again; - } - else { + } else { /* Make it clear what the problem is: */ Error ("EOL expected."); } From 673b27cc1b8fa0d7a7004ab715f03c229826cbd9 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Wed, 22 Jul 2015 11:36:39 +0200 Subject: [PATCH 04/17] Added empty IRQ backend. The driver kernels all require IRQ handling even if the actual drivers don't make use of it. So in order to successfully link a NES program using the joystick and/or TGI driver there has to be at least a "dummy" IRQ backend. --- libsrc/nes/irq.s | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 libsrc/nes/irq.s diff --git a/libsrc/nes/irq.s b/libsrc/nes/irq.s new file mode 100644 index 000000000..9c026f0ed --- /dev/null +++ b/libsrc/nes/irq.s @@ -0,0 +1,19 @@ +; +; IRQ handling (NES version) +; + + .export initirq, doneirq + +; ------------------------------------------------------------------------ + +.segment "INIT" + +initirq: + rts + +; ------------------------------------------------------------------------ + +.code + +doneirq: + rts From 52eec1f23666ee336203d18a0d6d1165393222d7 Mon Sep 17 00:00:00 2001 From: Greg King Date: Wed, 22 Jul 2015 12:56:34 -0400 Subject: [PATCH 05/17] Updated the fastcall information in a document and two Assembly files. --- doc/funcref.sgml | 34 ++++++++++++++++++++++++++++------ libsrc/conio/vcprintf.s | 13 +++---------- libsrc/conio/vcscanf.s | 3 +-- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index ebe63be45..a2ccf6c73 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -3,7 +3,7 @@
cc65 function reference <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>2014-05-26 +<date>2015-07-21 <abstract> cc65 is a C compiler for 6502 based systems. This function reference describes @@ -840,6 +840,8 @@ the CBM systems are classified as being "regular" files, for example. <tag/Notes/<itemize> <item>The minimum blocksize that can be added is 6 bytes; the function will ignore smaller blocks. +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. </itemize> <tag/Availability/cc65 <tag/See also/ @@ -868,6 +870,8 @@ id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/. <tag/Notes/<itemize> <item>Passing a pointer to a block that was is not the result of one of the allocation functions, or that has been free'd will give unpredicable results. +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. </itemize> <tag/Availability/cc65 <tag/See also/ @@ -912,7 +916,7 @@ be allocated from the heap using <tt/<ref id="malloc" name="malloc">/. <descrip> <tag/Function/Return the total available space on the heap. <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/ -<tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/ +<tag/Declaration/<tt/size_t _heapmemavail (void);/ <tag/Description/The function returns the total number of bytes available on the heap. <tag/Notes/<itemize> @@ -1323,6 +1327,10 @@ used in presence of a prototype. <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/ <tag/Declaration/<tt/void __fastcall__ atmos_load(const char* name);/ <tag/Description/<tt/atmos_load/ reads a memory block from tape. +<tag/Notes/<itemize> +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. +</itemize> <tag/Availability/cc65 <tag/See also/ <ref id="atmos_save" name="atmos_save"> @@ -1339,6 +1347,10 @@ used in presence of a prototype. <tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/ <tag/Declaration/<tt/void __fastcall__ atmos_save(const char* name, const void* start, const void* end);/ <tag/Description/<tt/atmos_save/ writes a memory block to tape. +<tag/Notes/<itemize> +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. +</itemize> <tag/Availability/cc65 <tag/See also/ <ref id="atmos_load" name="atmos_load"> @@ -1460,7 +1472,7 @@ be used in presence of a prototype. <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/ <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key, const void* base, size_t n, size_t size, -int (*cmp) (const void*, const void*));/ +int __fastcall__ (* cmp) (const void*, const void*));/ <tag/Description/<tt/bsearch/ searches a sorted array for a member that matches the one pointed to by <tt/key/. <tt/base/ is the address of the array, <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/ @@ -1473,6 +1485,8 @@ the compare function given. return one of the members. <item>The function is only available as fastcall function, so it may only be used in presence of a prototype. +<item>The function to which <tt/cmp/ points must have the <tt/fastcall/ calling +convention. </itemize> <tag/Availability/ISO 9899 <tag/See also/ @@ -4132,6 +4146,8 @@ the <tt/<ref id="mod_load" name="mod_load">/ function. <tag/Notes/<itemize> <item>The pointer passed as parameter is the pointer to the module memory, not the pointer to the control structure. +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. </itemize> <tag/Availability/cc65 <tag/See also/ @@ -4147,7 +4163,7 @@ not the pointer to the control structure. <descrip> <tag/Function/Load a relocatable module. <tag/Header/<tt/<ref id="modload.h" name="modload.h">/ -<tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/ +<tag/Declaration/<tt/unsigned char __fastcall__ mod_load (struct mod_ctrl* ctrl);/ <tag/Description/The function will load a code module into memory and relocate it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the outgoing fields in the passed <tt/mod_ctrl/ struct contain information about @@ -4163,6 +4179,8 @@ the module just loaded. Possible error codes are: <tag/Notes/<itemize> <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create relocatable o65 modules for use with this function. +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. </itemize> <tag/Availability/cc65 <tag/See also/ @@ -4501,7 +4519,7 @@ from memory. <descrip> <tag/Function/Unload a mouse driver. <tag/Header/<tt/<ref id="mouse.h" name="mouse.h">/ -<tag/Declaration/<tt/unsigned char __fastcall__ mouse_unload (void);/ +<tag/Declaration/<tt/unsigned char mouse_unload (void);/ <tag/Description/The function unloads a loaded mouse driver and frees all memory allocated for the driver. <tag/Notes/<itemize> @@ -4726,7 +4744,7 @@ be used in presence of a prototype. <tag/Function/Sort an array. <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/ <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count, -size_t size, int (*compare) (const void*, const void*));/ +size_t size, int __fastcall__ (* compare) (const void*, const void*));/ <tag/Description/<tt/qsort/ sorts an array according to a given compare function <tt/compare/. <tt/base/ is the address of the array, <tt/count/ is the number of elements, <tt/size/ the size of an element and <tt/compare/ @@ -4736,6 +4754,8 @@ the function used to compare the members. the function is undefined. <item>The function is only available as fastcall function, so it may only be used in presence of a prototype. +<item>The function to which <tt/compare/ points must have the <tt/fastcall/ +calling convention. </itemize> <tag/Availability/ISO 9899 <tag/See also/ @@ -6919,6 +6939,8 @@ ratio for a loaded driver. The value is not reset by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to an application, switching into and out of graphics mode will not restore the original aspect ratio. +<item>The function is available only as a fastcall function; so, it may be used +only in the presence of a prototype. </itemize> <tag/Availability/cc65 <tag/See also/ diff --git a/libsrc/conio/vcprintf.s b/libsrc/conio/vcprintf.s index 5dbbc051d..06eab4421 100644 --- a/libsrc/conio/vcprintf.s +++ b/libsrc/conio/vcprintf.s @@ -1,5 +1,5 @@ ; -; int vcprintf (const char* Format, va_list ap); +; int __fastcall__ vcprintf (const char* Format, va_list ap); ; ; Ullrich von Bassewitz, 2.12.2000 ; @@ -30,7 +30,7 @@ outdesc: ; Static outdesc structure ; ---------------------------------------------------------------------------- ; Callback routine used for the actual output. ; -; static void out (struct outdesc* d, const char* buf, unsigned count) +; static void __cdecl__ out (struct outdesc* d, const char* buf, unsigned count) ; /* Routine used for writing */ ; { ; /* Fast screen output */ @@ -94,7 +94,7 @@ out: jsr popax ; count ; ---------------------------------------------------------------------------- ; vcprintf - formatted console i/o ; -; int vcprintf (const char* format, va_list ap) +; int __fastcall__ vcprintf (const char* format, va_list ap) ; { ; struct outdesc d; ; @@ -107,10 +107,6 @@ out: jsr popax ; count ; /* Return bytes written */ ; return d.ccount; ; } -; -; It is intentional that this function does not have __fastcall__ calling -; conventions - we need the space on the stack anyway, so there's nothing -; gained by using __fastcall__. _vcprintf: sta ptr1 ; Save ap @@ -153,6 +149,3 @@ _vcprintf: lda outdesc ; ccount ldx outdesc+1 rts - - - diff --git a/libsrc/conio/vcscanf.s b/libsrc/conio/vcscanf.s index 67d5f664f..6893da4ef 100644 --- a/libsrc/conio/vcscanf.s +++ b/libsrc/conio/vcscanf.s @@ -63,7 +63,7 @@ L1: jsr _cgetc ; ---------------------------------------------------------------------------- -; static int unget(int c) { +; static int cdecl unget(int c) { ; pushed = true; ; return back = c; ; } @@ -127,4 +127,3 @@ d: .addr get ; SCANFDATA::GET pla jmp __scanf .endproc - From a55b6ef3db4457e8e3b7754d5680b254dedc7213 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 29 Jul 2015 06:55:50 -0400 Subject: [PATCH 06/17] Removed obsolete lines from a list of 65816 mnemonic aliases. Described what the macroes in macro package "generic" do. --- doc/ca65.sgml | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 4beb4e913..7e9d27b7c 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -3,10 +3,10 @@ <article> <title>ca65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>2014-04-24 +<date>2015-07-29 <abstract> -ca65 is a powerful macro assembler for the 6502, 65C02 and 65816 CPUs. It is +ca65 is a powerful macro assembler for the 6502, 65C02, and 65816 CPUs. It is used as a companion assembler for the cc65 crosscompiler, but it may also be used as a standalone product. </abstract> @@ -430,24 +430,21 @@ The assembler accepts <sect1>65816 mode<p> -In 65816 mode several aliases are accepted in addition to the official +In 65816 mode, several aliases are accepted, in addition to the official mnemonics: <tscreen><verb> - BGE is an alias for BCS - BLT is an alias for BCC - CPA is an alias for CMP - DEA is an alias for DEC A - INA is an alias for INC A - SWA is an alias for XBA - TAD is an alias for TCD - TAS is an alias for TCS - TDA is an alias for TDC - TSA is an alias for TSC +CPA is an alias for CMP +DEA is an alias for DEC A +INA is an alias for INC A +SWA is an alias for XBA +TAD is an alias for TCD +TAS is an alias for TCS +TDA is an alias for TDC +TSA is an alias for TSC </verb></tscreen> - <sect1>6502X mode<label id="6502X-mode"><p> 6502X mode is an extension to the normal 6502 mode. In this mode, several @@ -3330,8 +3327,8 @@ Here's a list of all control commands and a description, what they do: atari Defines the scrcode macro. cbm Defines the scrcode macro. cpu Defines constants for the .CPU variable. - generic Defines generic macros like add and sub. - longbranch Defines conditional long jump macros. + generic Defines generic macroes like add, sub, and blt. + longbranch Defines conditional long-jump macroes. </verb></tscreen> Including a macro package twice, or including a macro package that @@ -4317,48 +4314,47 @@ are: <sect1><tt>.MACPACK generic</tt><p> -This macro package defines macros that are useful in almost any program. -Currently defined macros are: +This macro package defines macroes that are useful in almost any program. +Currently defined macroes are: <tscreen><verb> - .macro add Arg + .macro add Arg ; add without carry clc adc Arg .endmacro - .macro sub Arg + .macro sub Arg ; subtract without borrow sec sbc Arg .endmacro - .macro bge Arg + .macro bge Arg ; branch on greater-than or equal bcs Arg .endmacro - .macro blt Arg + .macro blt Arg ; branch on less-than bcc Arg .endmacro - .macro bgt Arg + .macro bgt Arg ; branch on greater-than .local L beq L bcs Arg L: .endmacro - .macro ble Arg + .macro ble Arg ; branch on less-than or equal beq Arg bcc Arg .endmacro - .macro bnz Arg + .macro bnz Arg ; branch on not zero bne Arg .endmacro - .macro bze Arg + .macro bze Arg ; branch on zero beq Arg .endmacro - </verb></tscreen> From 05df90711469a14e311a9517c2e13e0c01ad6bf0 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sat, 1 Aug 2015 05:50:13 -0400 Subject: [PATCH 07/17] Fixed the syntax in the shortcut expansion of ".ZEROPAGE". Added a reference from ".SEGMENT" to ".ZEROPAGE". --- doc/ca65.sgml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 7e9d27b7c..19c09b85d 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -3,7 +3,7 @@ <article> <title>ca65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>2015-07-29 +<date>2015-08-01 <abstract> ca65 is a powerful macro assembler for the 6502, 65C02, and 65816 CPUs. It is @@ -3667,7 +3667,7 @@ Here's a list of all control commands and a description, what they do: segment, that is, a named section of data. The default segment is "CODE". There may be up to 254 different segments per object file (and up to 65534 per executable). There are shortcut commands for - the most common segments ("CODE", "DATA" and "BSS"). + the most common segments ("ZEROPAGE", "CODE", "RODATA", "DATA", and "BSS"). The command is followed by a string containing the segment name (there are some constraints for the name - as a rule of thumb use only those segment @@ -3701,8 +3701,9 @@ Here's a list of all control commands and a description, what they do: </verb></tscreen> See: <tt><ref id=".BSS" name=".BSS"></tt>, <tt><ref id=".CODE" - name=".CODE"></tt>, <tt><ref id=".DATA" name=".DATA"></tt> and <tt><ref - id=".RODATA" name=".RODATA"></tt> + name=".CODE"></tt>, <tt><ref id=".DATA" name=".DATA"></tt>, <tt><ref + id=".RODATA" name=".RODATA"></tt>, and <tt><ref id=".ZEROPAGE" + name=".ZEROPAGE"></tt> <sect1><tt>.SET</tt><label id=".SET"><p> @@ -3863,7 +3864,7 @@ Here's a list of all control commands and a description, what they do: shortcut for <tscreen><verb> - .segment "ZEROPAGE", zeropage + .segment "ZEROPAGE": zeropage </verb></tscreen> Because of the "zeropage" attribute, labels declared in this segment are From d36f31dcff21f84c5f1f65ae8b0e07e989a6cee3 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sat, 8 Aug 2015 22:04:38 -0400 Subject: [PATCH 08/17] Improved the format of the global symbols' lists of flags, in cc65's debugging output. --- src/cc65/symentry.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc65/symentry.c b/src/cc65/symentry.c index aa5949f97..980ee27f2 100644 --- a/src/cc65/symentry.c +++ b/src/cc65/symentry.c @@ -126,19 +126,19 @@ void DumpSymEntry (FILE* F, const SymEntry* E) /* Print the assembler name if we have one */ if (E->AsmName) { fprintf (F, " AsmName: %s\n", E->AsmName); - } + } /* Print the flags */ SymFlags = E->Flags; - fprintf (F, " Flags: "); + fprintf (F, " Flags:"); for (I = 0; I < sizeof (Flags) / sizeof (Flags[0]) && SymFlags != 0; ++I) { if ((SymFlags & Flags[I].Val) == Flags[I].Val) { SymFlags &= ~Flags[I].Val; - fprintf (F, "%s ", Flags[I].Name); + fprintf (F, " %s", Flags[I].Name); } } if (SymFlags != 0) { - fprintf (F, "%04X", SymFlags); + fprintf (F, " 0x%05X", SymFlags); } fprintf (F, "\n"); From 4e9842ef33789dae702302509d6c6b8d0acccb13 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 9 Aug 2015 06:27:05 -0400 Subject: [PATCH 09/17] Stopped extern declarations from changing previous static, but otherwise identical, declarations. --- src/cc65/symtab.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 1f63e9430..0e4de4ea2 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -813,6 +813,11 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) } } + /* An extern declaration must not change the current linkage. */ + if (IsFunc || (Flags & (SC_EXTERN | SC_DEF)) == SC_EXTERN) { + Flags &= ~SC_EXTERN; + } + /* Add the new flags */ Entry->Flags |= Flags; From 6032849e60dfa51ab1f39f99845d75a07c6e4e10 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Mon, 10 Aug 2015 13:39:17 -0400 Subject: [PATCH 10/17] Added warning diagnostics for conflicts between extern/public and static declarations. --- src/cc65/symtab.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 0e4de4ea2..fdf459873 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -813,11 +813,25 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) } } + /* If a static declaration follows a non-static declaration, then + ** warn about the conflict. (It will compile a public declaration.) + */ + if ((Flags & SC_EXTERN) == 0 && (Entry->Flags & SC_EXTERN) != 0) { + Warning ("static declaration follows non-static declaration of `%s'.", Name); + } + /* An extern declaration must not change the current linkage. */ if (IsFunc || (Flags & (SC_EXTERN | SC_DEF)) == SC_EXTERN) { Flags &= ~SC_EXTERN; } + /* If a public declaration follows a static declaration, then + ** warn about the conflict. (It will compile a public declaration.) + */ + if ((Flags & SC_EXTERN) != 0 && (Entry->Flags & SC_EXTERN) == 0) { + Warning ("public declaration follows static declaration of `%s'.", Name); + } + /* Add the new flags */ Entry->Flags |= Flags; From 1baecf4a155842defd64d406de5b56f19a99859b Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Thu, 13 Aug 2015 03:39:35 -0400 Subject: [PATCH 11/17] Added regression tests of diagnostics for conflicts between extern/public and static declarations. --- test/err/static-2.c | 20 ++++++++++++++++++++ test/err/static-3.c | 20 ++++++++++++++++++++ test/err/static-4.c | 20 ++++++++++++++++++++ test/val/static-1.c | 20 ++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 test/err/static-2.c create mode 100644 test/err/static-3.c create mode 100644 test/err/static-4.c create mode 100644 test/val/static-1.c diff --git a/test/err/static-2.c b/test/err/static-2.c new file mode 100644 index 000000000..c89097825 --- /dev/null +++ b/test/err/static-2.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! global non-static and static conflicts + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +#pragma warn(error, on) + +int n; +static int n; /* should give an error */ + +int main(void) +{ + return n; +} diff --git a/test/err/static-3.c b/test/err/static-3.c new file mode 100644 index 000000000..5b6839a6a --- /dev/null +++ b/test/err/static-3.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! global non-static and static conflicts + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +#pragma warn(error, on) + +extern int n; +static int n; /* should give an error */ + +int main(void) +{ + return n; +} diff --git a/test/err/static-4.c b/test/err/static-4.c new file mode 100644 index 000000000..a2cdeb78a --- /dev/null +++ b/test/err/static-4.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! global non-static and static conflicts + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +#pragma warn(error, on) + +static int n; +int n; /* should give an error */ + +int main(void) +{ + return n; +} diff --git a/test/val/static-1.c b/test/val/static-1.c new file mode 100644 index 000000000..ae2ba6289 --- /dev/null +++ b/test/val/static-1.c @@ -0,0 +1,20 @@ +/* + !!DESCRIPTION!! global non-static and static conflicts + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +/* + see: https://github.com/cc65/cc65/issues/191 +*/ + +#pragma warn(error, on) + +static int n = 0; +extern int n; /* should not give an error */ + +int main(void) +{ + return n; +} From 6ed3d055cb3a5e79e02b8817f8f606155e82930c Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Thu, 13 Aug 2015 17:25:52 -0400 Subject: [PATCH 12/17] Removed redundant attempts to build uncompilable files. --- test/err/Makefile | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/test/err/Makefile b/test/err/Makefile index 454a560ce..bc4226acb 100644 --- a/test/err/Makefile +++ b/test/err/Makefile @@ -1,4 +1,3 @@ - # makefile for the tests that MUST NOT compile ifneq ($(shell echo),) @@ -13,36 +12,18 @@ else DEL = $(RM) $1 endif -CC65FLAGS := -t sim6502 - -CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +CC65 := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65) WORKDIR := ../../testwrk .PHONY: all clean -SOURCES := $(wildcard *.c) -TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg)) +TESTS := $(patsubst %.c,$(WORKDIR)/%.s,$(wildcard *.c)) all: $(TESTS) -$(WORKDIR)/%.prg: %.c - $(NOT) $(CL65) $(CC65FLAGS) $< -o $@ -$(WORKDIR)/%.o.prg: %.c - $(NOT) $(CL65) -O $(CC65FLAGS) $< -o $@ -$(WORKDIR)/%.os.prg: %.c - $(NOT) $(CL65) -Os $(CC65FLAGS) $< -o $@ -$(WORKDIR)/%.osi.prg: %.c - $(NOT) $(CL65) -Osi $(CC65FLAGS) $< -o $@ -$(WORKDIR)/%.osir.prg: %.c - $(NOT) $(CL65) -Osir $(CC65FLAGS) $< -o $@ -$(WORKDIR)/%.oi.prg: %.c - $(NOT) $(CL65) -Oi $(CC65FLAGS) $< -o $@ -$(WORKDIR)/%.oir.prg: %.c - $(NOT) $(CL65) -Oir $(CC65FLAGS) $< -o $@ -$(WORKDIR)/%.or.prg: %.c - $(NOT) $(CL65) -Or $(CC65FLAGS) $< -o $@ +$(WORKDIR)/%.s: %.c + $(NOT) $(CC65) -o $@ $< clean: @$(call DEL,$(TESTS)) - @$(call DEL,$(SOURCES:.c=.o)) From dd75d3f8841b5828e173de5fe7f4a7fc8dfe7c47 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt <ol.sc@web.de> Date: Tue, 25 Aug 2015 13:57:21 +0200 Subject: [PATCH 13/17] Don't show (potentially failing) pull request builds. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 660798128..31eb1c0ef 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [wiki](http://github.com/cc65/wiki/wiki) -[![build status](http://travis-ci.org/cc65/cc65.png)](http://travis-ci.org/cc65/cc65/builds) +[![build status](https://api.travis-ci.org/cc65/cc65.svg?branch=master)](https://travis-ci.org/cc65/cc65/builds) cc65 is a complete cross development package for 65(C)02 systems, including a powerful macro assembler, a C compiler, linker, librarian and several From 9c55bd1c96e1910d0d46e66abd4fa2fe7fdadf4a Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Wed, 26 Aug 2015 19:29:39 -0400 Subject: [PATCH 14/17] Fixed bugs in the interface for C-level interrupt handlers. * Added an important ".code" directive. * Import a linker-created zero-page symbol as an absolute address; then, convert it to zero-page when it is used. Fixes bug report #198. --- libsrc/common/interrupt.s | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libsrc/common/interrupt.s b/libsrc/common/interrupt.s index e1d53d6dc..950d3d787 100644 --- a/libsrc/common/interrupt.s +++ b/libsrc/common/interrupt.s @@ -1,5 +1,6 @@ ; -; Oliver Schmidt, 2012-01-18 +; 2012-01-18, Oliver Schmidt +; 2015-08-22, Greg King ; ; void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size); ; void reset_irq (void); @@ -7,8 +8,7 @@ .export _set_irq, _reset_irq .interruptor clevel_irq, 1 ; Export as low priority IRQ handler - .import popax - .importzp __ZP_START__ + .import popax, __ZP_START__ .include "zeropage.inc" @@ -31,6 +31,8 @@ zpsave: .res zpsavespace ; --------------------------------------------------------------------------- +.code + .proc _set_irq ; Keep clevel_irq from being called right now @@ -77,7 +79,7 @@ zpsave: .res zpsavespace ; Save our zero page locations @L1: ldx #.sizeof(::zpsave)-1 -@L2: lda __ZP_START__,x +@L2: lda <__ZP_START__,x sta zpsave,x dex bpl @L2 @@ -94,7 +96,7 @@ zpsave: .res zpsavespace ; Copy back our zero page content ldx #.sizeof(::zpsave)-1 @L3: ldy zpsave,x - sty __ZP_START__,x + sty <__ZP_START__,x dex bpl @L3 @@ -103,4 +105,3 @@ zpsave: .res zpsavespace rts .endproc - From a132bc4b28cc3ed3474586735dd2d8ad53a2caeb Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 30 Aug 2015 05:16:38 -0400 Subject: [PATCH 15/17] Fixed a comparison operator; so that the NULL at the end of argv[] is copied by InitCmdLine(). Most POSIX function libraries hid that long-time bug by putting zeroes in their dynamic RAM; but, MinGW's library doesn't do it. Therefore, a command like cl65 foo.c -l would crash with a "Segmentation fault" -- it should give a nice error message about "-l"; and, quit neatly. --- src/common/cmdline.c | 6 +++--- src/common/cmdline.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/cmdline.c b/src/common/cmdline.c index 716df1efb..ce2962780 100644 --- a/src/common/cmdline.c +++ b/src/common/cmdline.c @@ -161,7 +161,7 @@ static void ExpandFile (CmdLine* L, const char* Name) -void InitCmdLine (int* aArgCount, char** aArgVec[], const char* aProgName) +void InitCmdLine (int* aArgCount, char*** aArgVec, const char* aProgName) /* Initialize command line parsing. aArgVec is the argument array terminated by ** a NULL pointer (as usual), ArgCount is the number of valid arguments in the ** array. Both arguments are remembered in static storage. @@ -171,7 +171,7 @@ void InitCmdLine (int* aArgCount, char** aArgVec[], const char* aProgName) int I; /* Get the program name from argv[0] but strip a path */ - if (*(aArgVec)[0] == 0) { + if ((*aArgVec)[0] == 0) { /* Use the default name given */ ProgName = aProgName; } else { @@ -190,7 +190,7 @@ void InitCmdLine (int* aArgCount, char** aArgVec[], const char* aProgName) ** special handling for arguments preceeded by the '@' sign - these are ** actually files containing arguments. */ - for (I = 0; I < *aArgCount; ++I) { + for (I = 0; I <= *aArgCount; ++I) { /* Get the next argument */ char* Arg = (*aArgVec)[I]; diff --git a/src/common/cmdline.h b/src/common/cmdline.h index b18906c7a..1caf0cfb6 100644 --- a/src/common/cmdline.h +++ b/src/common/cmdline.h @@ -71,7 +71,7 @@ struct LongOpt { -void InitCmdLine (int* aArgCount, char** aArgVec[], const char* aProgName); +void InitCmdLine (int* aArgCount, char*** aArgVec, const char* aProgName); /* Initialize command line parsing. aArgVec is the argument array terminated by ** a NULL pointer (as usual), ArgCount is the number of valid arguments in the ** array. Both arguments are remembered in static storage. From d280d2610e585b884b376705f40f721c76ca97af Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 30 Aug 2015 07:55:07 -0400 Subject: [PATCH 16/17] Don't count the NULL (doh!). --- src/common/cmdline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/cmdline.c b/src/common/cmdline.c index ce2962780..0f6622934 100644 --- a/src/common/cmdline.c +++ b/src/common/cmdline.c @@ -210,11 +210,11 @@ void InitCmdLine (int* aArgCount, char*** aArgVec, const char* aProgName) } /* Store the new argument list in a safe place... */ - ArgCount = L.Count; + ArgCount = L.Count - 1; ArgVec = L.Vec; /* ...and pass back the changed data also */ - *aArgCount = L.Count; + *aArgCount = L.Count - 1; *aArgVec = L.Vec; } From 58e56ba24deb6d63d068a9655217358fbe795b26 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 30 Aug 2015 08:43:54 -0400 Subject: [PATCH 17/17] Changed multi-line C comments in files that I missed in commit 0390c34e88e9512b81ce35a9ba36d137d1c80c44. --- src/cl65/spawn-amiga.inc | 12 ++++++------ src/cl65/spawn-unix.inc | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/cl65/spawn-amiga.inc b/src/cl65/spawn-amiga.inc index 5d1b60ea3..443f42c1f 100644 --- a/src/cl65/spawn-amiga.inc +++ b/src/cl65/spawn-amiga.inc @@ -38,8 +38,8 @@ /* Mode argument for spawn. This value is ignored by the function and only - * provided for DOS/Windows compatibility. - */ +** provided for DOS/Windows compatibility. +*/ #ifndef P_WAIT #define P_WAIT 0 #endif @@ -56,10 +56,10 @@ int spawnvp (int Mode attribute ((unused)), const char* File attribute ((unused)), char* const argv []) /* Execute the given program searching and wait til it terminates. The Mode - * argument is ignored (compatibility only). The result of the function is - * the return code of the program. The function will terminate the program - * on errors. - */ +** argument is ignored (compatibility only). The result of the function is +** the return code of the program. The function will terminate the program +** on errors. +*/ { int Status; StrBuf Command = AUTO_STRBUF_INITIALIZER; diff --git a/src/cl65/spawn-unix.inc b/src/cl65/spawn-unix.inc index fc5125c34..1045f7759 100644 --- a/src/cl65/spawn-unix.inc +++ b/src/cl65/spawn-unix.inc @@ -48,8 +48,8 @@ /* Mode argument for spawn. This value is ignored by the function and only - * provided for DOS/Windows compatibility. - */ +** provided for DOS/Windows compatibility. +*/ #ifndef P_WAIT #define P_WAIT 0 #endif @@ -64,10 +64,10 @@ int spawnvp (int Mode attribute ((unused)), const char* File, char* const argv []) /* Execute the given program searching and wait til it terminates. The Mode - * argument is ignored (compatibility only). The result of the function is - * the return code of the program. The function will terminate the program - * on errors. - */ +** argument is ignored (compatibility only). The result of the function is +** the return code of the program. The function will terminate the program +** on errors. +*/ { int Status = 0; @@ -99,7 +99,7 @@ int spawnvp (int Mode attribute ((unused)), const char* File, char* const argv [ } /* Only the father goes here, we place a return here regardless of that - * to avoid compiler warnings. - */ + ** to avoid compiler warnings. + */ return WEXITSTATUS (Status); }