Merge branch 'master' into sane_makefile_output

This commit is contained in:
Gorilla Sapiens
2025-06-18 06:26:58 +00:00
102 changed files with 3395 additions and 265 deletions

View File

@@ -8,6 +8,10 @@
lda #$ea
.endif
.ifp02x
lax #$ea
.endif
.ifpsc02
jmp ($1234,x)
.endif
@@ -72,3 +76,13 @@
.byte 0,"CPU_ISET_6502DTV"
.endif
; step 3: switch through all supported cpus to verify the pseudo-op is there
.p02
.p02X
.psc02
.pc02
.p816
.p4510
.pdtv

162
test/standard/null.c Normal file
View File

@@ -0,0 +1,162 @@
/* test headers which should define NULL */
#include <locale.h>
#ifndef NULL
#error "NULL should be defined in locale.h"
#endif
#undef NULL
#include <stdlib.h>
#ifndef NULL
#error "NULL should be defined in stdlib.h"
#endif
#undef NULL
#include <string.h>
#ifndef NULL
#error "NULL should be defined in string.h"
#endif
#undef NULL
#include <stddef.h>
#ifndef NULL
#error "NULL should be defined in stddef.h"
#endif
#undef NULL
#include <stdio.h>
#ifndef NULL
#error "NULL should be defined in stdio.h"
#endif
#undef NULL
#include <time.h>
#ifndef NULL
#error "NULL should be defined in time.h"
#endif
#undef NULL
/* does not exist in cc65 (yet)
#include <wchar.h>
#ifndef NULL
#error "NULL should be defined in wchar.h"
#endif */
#undef NULL
/* test headers which should NOT define NULL */
#include <assert.h>
#ifdef NULL
#error "NULL should NOT be defined in assert.h"
#undef NULL
#endif
/* does not exist in cc65 (yet)
#include <complex.h>
#ifdef NULL
#error "NULL should NOT be defined in complex.h"
#undef NULL
#endif */
#include <ctype.h>
#ifdef NULL
#error "NULL should NOT be defined in ctype.h"
#undef NULL
#endif
#include <errno.h>
#ifdef NULL
#error "NULL should NOT be defined in errno.h"
#undef NULL
#endif
/* does not exist in cc65 (yet)
#include <fenv.h>
#ifdef NULL
#error "NULL should NOT be defined in fenv.h"
#undef NULL
#endif */
/* does not exist in cc65 (yet)
#include <float.h>
#ifdef NULL
#error "NULL should NOT be defined in float.h"
#undef NULL
#endif */
#include <inttypes.h>
#ifdef NULL
#error "NULL should NOT be defined in inttypes.h"
#undef NULL
#endif
#include <iso646.h>
#ifdef NULL
#error "NULL should NOT be defined in iso646.h"
#undef NULL
#endif
#include <limits.h>
#ifdef NULL
#error "NULL should NOT be defined in limits.h"
#undef NULL
#endif
/* does not exist in cc65 (yet)
#include <math.h>
#ifdef NULL
#error "NULL should NOT be defined in math.h"
#undef NULL
#endif */
#include <setjmp.h>
#ifdef NULL
#error "NULL should NOT be defined in setjmp.h"
#undef NULL
#endif
#include <signal.h>
#ifdef NULL
#error "NULL should NOT be defined in signal.h"
#undef NULL
#endif
#include <stdarg.h>
#ifdef NULL
#error "NULL should NOT be defined in stdarg.h"
#undef NULL
#endif
#include <stdbool.h>
#ifdef NULL
#error "NULL should NOT be defined in stdbool.h"
#undef NULL
#endif
#include <stdint.h>
#ifdef NULL
#error "NULL should NOT be defined in stdint.h"
#undef NULL
#endif
/* does not exist in cc65 (yet)
#include <tgmath.h>
#ifdef NULL
#error "NULL should NOT be defined in tgmath.h"
#undef NULL
#endif */
/* does not exist in cc65 (yet)
#include <wctype.h>
#ifdef NULL
#error "NULL should NOT be defined in wctype.h"
#undef NULL
#endif */
int main(void)
{
return 0;
}

View File

@@ -0,0 +1,56 @@
// bug #2172 - Invalid code generated for switch statement
#include <stdlib.h>
#include <stdio.h>
// cc65 -o bug2172.s -Cl -Oirs -T -t c64 bug2172.c
int func(int expr)
{
switch (expr) {
int i;
case 0:
i = 17;
return i;
default:
i = 16;
return i;
}
}
int err = 0;
int main(void)
{
int i = 0;
int n = 42;
for (i = -3; i < 0; i++) {
n = func(i);
if ((i < -3) || (i >= 0)) {
goto stackerr;
}
printf("i:%d expect:16 got:%d\n", i, n);
if (n != 16) {
err++;
}
}
n = func(0);
printf("i:%d expect:17 got:%d\n", 0, n);
if (n != 17) {
err++;
}
for (i = 1; i < 4; i++) {
n = func(i);
if ((i < 1) || (i >= 4)) {
goto stackerr;
}
printf("i:%d expect:16 got:%d\n", i, n);
if (n != 16) {
err++;
}
}
return err;
stackerr:
fputs("stack messed up?\n", stdout);
return -1;
}

View File

@@ -0,0 +1,51 @@
#include <stdlib.h>
#include <stdio.h>
/* Just some arbitrary code, more fun with goto */
int func(int m)
{
long x = -42; /* sp: -4 */
switch (x) {
/* return 0; // C99 only */
int i = 42; /* sp: -6 */
L0:
--i;
default:
if (i != 0) {
long j = 13; /* sp: -10 */
goto L1;
L1:
case 0x7FFF01:
m--;
case 0x7EFF0001:
case 0x7FFF0001:
i++;
} /* sp: -6 */
case 0x7FFF00:
case 0x7FFF0000:
break;
goto L0;
{
int skipped = 42; /* sp: -8 */
case 0x7EFF00:
case 0x7EFF0000:
++skipped;
} /* sp: -6 */
} /* sp: -4 */
return m;
}
int err = 0;
int main(void)
{
int n = 42;
n = func(7);
if (n != 7) {
err++;
}
printf("n:%d\n", n);
return err;
}

View File

@@ -47,10 +47,11 @@ _Pragma _Pragma (
#pragma bss-name("BSS")
{
extern int y;
#pragma bss-name("BSS2")
#pragma bss-name("BSS") // used to be BSS2, but fix for #2608 means
// that now causes ld65 to fail, so we use BSS instead
static
#pragma zpsym ("y")
int x; // TODO: currently in "BSS", but supposed to be in "BSS2"?
int x;
x = 0;
if (memcmp(str, "aBC", 3))

40
test/val/bug2608.c Normal file
View File

@@ -0,0 +1,40 @@
/* bug #2608: "zp_bss" is placed in BSS and NOT placed in ZEROPAGE as expected. */
#include <stdlib.h>
#include <stdio.h>
int err = 0;
int is_zeropage(void *p)
{
if (/*(p >= ((void*)0)) &&*/
(p <= ((void*)0xff))) {
return 1;
}
return 0;
}
void foo(void) {
#pragma bss-name(push,"ZEROPAGE")
#pragma data-name(push,"ZEROPAGE")
static int zp_data = 5;
static char zp_bss;
#pragma bss-name(pop)
#pragma data-name(pop)
printf("zp_data at 0x%04x (%szp)\n", &zp_data, is_zeropage(&zp_data) ? "" : "NOT ");
printf("zp_bss at 0x%04x (%szp)\n", &zp_bss, is_zeropage(&zp_bss) ? "" : "NOT ");
if (!is_zeropage(&zp_data)) {
err++;
}
if (!is_zeropage(&zp_bss)) {
err++;
}
}
int main(void)
{
foo();
printf("errors: %d\n", err);
return err;
}