diff --git a/man/rgbasm.5 b/man/rgbasm.5 index b11293f82..90a4ac965 100644 --- a/man/rgbasm.5 +++ b/man/rgbasm.5 @@ -1346,8 +1346,6 @@ The following symbols are defined by the assembler: .It Dv @ Ta Ic EQU Ta PC value (essentially, the current memory address) .It Dv _RS Ta Ic = Ta _RS Counter .It Dv _NARG Ta Ic EQU Ta Number of arguments passed to macro, updated by Ic SHIFT -.It Dv __LINE__ Ta Ic EQU Ta The current line number -.It Dv __FILE__ Ta Ic EQUS Ta The current filename .It Dv __DATE__ Ta Ic EQUS Ta Today's date .It Dv __TIME__ Ta Ic EQUS Ta The current time .It Dv __ISO_8601_LOCAL__ Ta Ic EQUS Ta ISO 8601 timestamp (local) diff --git a/src/asm/symbol.c b/src/asm/symbol.c index e3d032a2f..515c4c419 100644 --- a/src/asm/symbol.c +++ b/src/asm/symbol.c @@ -78,12 +78,15 @@ static int32_t Callback_NARG(void) static int32_t Callback__LINE__(void) { + warning(WARNING_OBSOLETE, "`__LINE__` is deprecated\n"); + return lexer_GetLineNo(); } static char const *Callback__FILE__(void) { - // FIXME: this is dangerous, and here's why this is CURRENTLY okay. It's still bad, fix it. + warning(WARNING_OBSOLETE, "`__FILE__` is deprecated\n"); + // There are only two call sites for this; one copies the contents directly, the other is // EQUS expansions, which cannot straddle file boundaries. So this should be fine. static char *buf = NULL; @@ -680,7 +683,9 @@ void sym_Init(time_t now) { PCSymbol = createBuiltinSymbol("@"); struct Symbol *_NARGSymbol = createBuiltinSymbol("_NARG"); + // __LINE__ is deprecated struct Symbol *__LINE__Symbol = createBuiltinSymbol("__LINE__"); + // __FILE__ is deprecated struct Symbol *__FILE__Symbol = createBuiltinSymbol("__FILE__"); PCSymbol->type = SYM_LABEL; diff --git a/test/asm/builtin-overwrite.asm b/test/asm/builtin-overwrite.asm index a1ff93020..cea61ac8c 100644 --- a/test/asm/builtin-overwrite.asm +++ b/test/asm/builtin-overwrite.asm @@ -39,5 +39,6 @@ PRINTLN \1 endm ; Representative numeric and string builtins - tickle __LINE__, 1 - tickle __FILE__, 0 + ; (SOURCE_DATE_EPOCH in test.sh makes this reproducible) + tickle __UTC_YEAR__, 1 + tickle __ISO_8601_UTC__, 0 diff --git a/test/asm/builtin-overwrite.err b/test/asm/builtin-overwrite.err index e74a3bc38..2b5dc1909 100644 --- a/test/asm/builtin-overwrite.err +++ b/test/asm/builtin-overwrite.err @@ -1,57 +1,57 @@ -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(7): - '__LINE__' already defined as constant at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(8): - '__LINE__' already defined as constant at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(11): - '__LINE__' already defined at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(12): - '__LINE__' already defined at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(16): - Built-in symbol '__LINE__' cannot be purged -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(17): - Built-in symbol '__LINE__' cannot be purged -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(20): - '__LINE__' already defined at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(21): - '__LINE__' already defined at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(24): - '__LINE__' already defined as constant at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(25): - '__LINE__' already defined as constant at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(28): - '__LINE__' already defined at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(29): - '__LINE__' already defined at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(32): - '__LINE__' already defined as constant at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(33): - '__LINE__' already defined as constant at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(36): - '__LINE__' already defined as non-EQUS at -error: builtin-overwrite.asm(42) -> builtin-overwrite.asm::tickle(37): - '__LINE__' already defined as non-EQUS at +error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(7): + '__UTC_YEAR__' already defined as constant at +error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(8): + '__UTC_YEAR__' already defined as constant at +error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(11): + '__UTC_YEAR__' already defined at +error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(12): + '__UTC_YEAR__' already defined at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(16): - Built-in symbol '__FILE__' cannot be purged + Built-in symbol '__UTC_YEAR__' cannot be purged error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(17): - Built-in symbol '__FILE__' cannot be purged + Built-in symbol '__UTC_YEAR__' cannot be purged error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(20): - '__FILE__' already defined at + '__UTC_YEAR__' already defined at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(21): - '__FILE__' already defined at + '__UTC_YEAR__' already defined at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(24): - '__FILE__' already defined as constant at + '__UTC_YEAR__' already defined as constant at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(25): - '__FILE__' already defined as constant at + '__UTC_YEAR__' already defined as constant at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(28): - '__FILE__' already defined at + '__UTC_YEAR__' already defined at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(29): - '__FILE__' already defined at + '__UTC_YEAR__' already defined at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(32): - '__FILE__' already defined as constant at + '__UTC_YEAR__' already defined as constant at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(33): - '__FILE__' already defined as constant at + '__UTC_YEAR__' already defined as constant at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(36): - Built-in symbol '__FILE__' cannot be redefined + '__UTC_YEAR__' already defined as non-EQUS at error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(37): - Built-in symbol '__FILE__' cannot be redefined + '__UTC_YEAR__' already defined as non-EQUS at +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(16): + Built-in symbol '__ISO_8601_UTC__' cannot be purged +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(17): + Built-in symbol '__ISO_8601_UTC__' cannot be purged +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(20): + '__ISO_8601_UTC__' already defined at +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(21): + '__ISO_8601_UTC__' already defined at +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(24): + '__ISO_8601_UTC__' already defined as constant at +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(25): + '__ISO_8601_UTC__' already defined as constant at +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(28): + '__ISO_8601_UTC__' already defined at +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(29): + '__ISO_8601_UTC__' already defined at +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(32): + '__ISO_8601_UTC__' already defined as constant at +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(33): + '__ISO_8601_UTC__' already defined as constant at +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(36): + Built-in symbol '__ISO_8601_UTC__' cannot be redefined +error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(37): + Built-in symbol '__ISO_8601_UTC__' cannot be redefined error: Assembly aborted (28 errors)! diff --git a/test/asm/builtin-overwrite.out b/test/asm/builtin-overwrite.out index cc905ad92..d7fcfda7b 100644 --- a/test/asm/builtin-overwrite.out +++ b/test/asm/builtin-overwrite.out @@ -1,14 +1,14 @@ -$9 -$D -$12 -$16 -$1A -$1E -$22 -$26 -builtin-overwrite.asm -builtin-overwrite.asm -builtin-overwrite.asm -builtin-overwrite.asm -builtin-overwrite.asm -builtin-overwrite.asm +$7C5 +$7C5 +$7C5 +$7C5 +$7C5 +$7C5 +$7C5 +$7C5 +1989-04-21T12:34:56Z +1989-04-21T12:34:56Z +1989-04-21T12:34:56Z +1989-04-21T12:34:56Z +1989-04-21T12:34:56Z +1989-04-21T12:34:56Z diff --git a/test/asm/compound-assignment.asm b/test/asm/compound-assignment.asm index 4654c26de..b11379577 100644 --- a/test/asm/compound-assignment.asm +++ b/test/asm/compound-assignment.asm @@ -33,8 +33,5 @@ endm _RS += 100 println _RS -__LINE__ *= 200 -println __LINE__ - UnDeFiNeD ^= 300 println UnDeFiNeD diff --git a/test/asm/compound-assignment.err b/test/asm/compound-assignment.err index a606ecc06..867deae20 100644 --- a/test/asm/compound-assignment.err +++ b/test/asm/compound-assignment.err @@ -1,5 +1,3 @@ error: compound-assignment.asm(36): - '__LINE__' already defined as constant at -error: compound-assignment.asm(39): Expected constant expression: 'UnDeFiNeD' is not constant at assembly time -error: Assembly aborted (2 errors)! +error: Assembly aborted (1 error)! diff --git a/test/asm/compound-assignment.out b/test/asm/compound-assignment.out index 805d29880..621566b72 100644 --- a/test/asm/compound-assignment.out +++ b/test/asm/compound-assignment.out @@ -35,5 +35,4 @@ $5 $14 $A $64 -$25 $0 diff --git a/test/asm/file-sym.err b/test/asm/file-sym.err index e69de29bb..bb02ea722 100644 --- a/test/asm/file-sym.err +++ b/test/asm/file-sym.err @@ -0,0 +1,2 @@ +warning: file-sym.asm(1): [-Wobsolete] + `__FILE__` is deprecated diff --git a/test/asm/preinclude.asm b/test/asm/preinclude.asm index 41fc8032f..57d69cca5 100644 --- a/test/asm/preinclude.asm +++ b/test/asm/preinclude.asm @@ -1,3 +1,3 @@ -warn "main {__FILE__}" +warn "main file" def v3 = v1 + v2 println "{d:v1} + {d:v2} = {d:v3}" diff --git a/test/asm/preinclude.err b/test/asm/preinclude.err index 9b62e52f8..dc9d24040 100644 --- a/test/asm/preinclude.err +++ b/test/asm/preinclude.err @@ -1,4 +1,4 @@ warning: preinclude.asm(0) -> preinclude.inc(1): [-Wuser] - pre-include "preinclude.inc" + pre-included file warning: preinclude.asm(1): [-Wuser] - main "preinclude.asm" + main file diff --git a/test/asm/preinclude.inc b/test/asm/preinclude.inc index e38a0a4ab..415fe9666 100644 --- a/test/asm/preinclude.inc +++ b/test/asm/preinclude.inc @@ -1,4 +1,4 @@ -warn "pre-include {__FILE__}" +warn "pre-included file" def v1 = 12 rept 3 diff --git a/test/asm/test.sh b/test/asm/test.sh index 2c6a41233..8b1db2b87 100755 --- a/test/asm/test.sh +++ b/test/asm/test.sh @@ -2,6 +2,9 @@ export LC_ALL=C +# Game Boy release date, 1989-04-21T12:34:56Z (for reproducible test results) +export SOURCE_DATE_EPOCH=609165296 + o="$(mktemp)" gb="$(mktemp)" input="$(mktemp)" @@ -52,20 +55,6 @@ else rm -f version.asm fi -# Add the quote test, except on Windows -if uname | grep -viq mingw; then - cat > quote\"file.asm < quote\"file.out < quote\"file.err < $output 2> $errput