From 89aee58b26819db71a6e52289ce4791b02620792 Mon Sep 17 00:00:00 2001 From: Cole Campbell Date: Fri, 17 Jul 2026 17:45:16 -0400 Subject: [PATCH 1/2] Fix scanning of /* when CComments is disabled --- src/ca65/scanner.c | 8 ++++---- test/asm/val/ccomments.s | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 test/asm/val/ccomments.s diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index ce90388d4..9a3ca4cfd 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1389,15 +1389,13 @@ CharAgain: case '/': NextChar (); - if (C != '*') { - CurTok.Tok = TOK_DIV; - } else if (CComments) { + if (C == '*' && CComments) { /* Remember the position, then skip the '*' */ Collection LineInfos = STATIC_COLLECTION_INITIALIZER; GetFullLineInfo (&LineInfos); NextChar (); do { - while (C != '*') { + while (C != '*') { if (C == EOF) { LIError (&LineInfos, "Unterminated comment"); ReleaseFullLineInfo (&LineInfos); @@ -1412,6 +1410,8 @@ CharAgain: ReleaseFullLineInfo (&LineInfos); DoneCollection (&LineInfos); goto Again; + } else { + CurTok.Tok = TOK_DIV; } return; diff --git a/test/asm/val/ccomments.s b/test/asm/val/ccomments.s new file mode 100644 index 000000000..d93e0e528 --- /dev/null +++ b/test/asm/val/ccomments.s @@ -0,0 +1,11 @@ +.export _main + +; both expressions are valid with c_comments disabled +.feature c_comments - +.word 8 / * +.word 8/* + +_main: + lda #0 + tax + rts From f3dc8a511b31808ae8fd1541bd5329962c6c47c5 Mon Sep 17 00:00:00 2001 From: Cole Campbell Date: Sat, 18 Jul 2026 08:49:11 -0400 Subject: [PATCH 2/2] Assert value returned by PC division --- test/asm/val/ccomments.s | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/asm/val/ccomments.s b/test/asm/val/ccomments.s index d93e0e528..2c2721d95 100644 --- a/test/asm/val/ccomments.s +++ b/test/asm/val/ccomments.s @@ -2,8 +2,11 @@ ; both expressions are valid with c_comments disabled .feature c_comments - -.word 8 / * -.word 8/* + +.org $0002 +.assert 8 / * = 4, error, "8 / * should evaluate to 4" +.assert 8/* = 4, error, "8/* should evaluate to 4" +.reloc _main: lda #0