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..2c2721d95 --- /dev/null +++ b/test/asm/val/ccomments.s @@ -0,0 +1,14 @@ +.export _main + +; both expressions are valid with c_comments disabled +.feature c_comments - + +.org $0002 +.assert 8 / * = 4, error, "8 / * should evaluate to 4" +.assert 8/* = 4, error, "8/* should evaluate to 4" +.reloc + +_main: + lda #0 + tax + rts