From f531f38463940a8c7b2fbb3a9c4cc9781ab67c2a Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 1 Mar 2022 19:46:14 -0600 Subject: [PATCH] Use suffixes on numeric constants in #pragma expand output. A suffix will now be printed on any integer constant with a type other than int, or any floating constant with a type other than double. This ensures that all constants have the correct types, and also serves as documentation of the types. --- Scanner.pas | 24 ++++++++++++++---------- cc.notes | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Scanner.pas b/Scanner.pas index 144bc70..3e86b1f 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -829,29 +829,33 @@ case token.kind of charconst, scharconst, ucharconst, - intconst, - uintconst, - ushortconst: write(token.ival:1); + intconst: write(token.ival:1); - longConst, - ulongConst: write(token.lval:1); + ushortconst, + uintconst: write(token.ival:1,'U'); + + longConst: write(token.lval:1,'L'); + + ulongConst: write(token.lval:1,'UL'); longlongConst: begin str := cnvds(CnvLLX(token.qval),1,1); str[0] := chr(ord(str[0]) - 2); - write(str); + write(str,'LL'); end; ulonglongConst: begin str := cnvds(CnvULLX(token.qval),1,1); str[0] := chr(ord(str[0]) - 2); - write(str); + write(str,'ULL'); end; compConst, - floatConst, - doubleConst, - extendedConst: write(token.rval:1); + doubleConst: write(token.rval:1); + + floatConst: write(token.rval:1,'F'); + + extendedConst: write(token.rval:1,'L'); stringConst: begin if token.prefix = prefix_u16 then begin diff --git a/cc.notes b/cc.notes index c697ae6..abd6421 100644 --- a/cc.notes +++ b/cc.notes @@ -183,7 +183,7 @@ The #pragma debug directive supports a new bit. If bit 15 is set, ORCA/C generat p. 257 -The #pragma expand directive has been changed to use three-digit octal escape sequences (rather than hexadecimal ones) in strings it outputs. (This ensures that subsequent characters in the string cannot be interpreted as part of the escape sequence.) +The #pragma expand directive has been changed to use three-digit octal escape sequences (rather than hexadecimal ones) in strings it outputs. (This ensures that subsequent characters in the string cannot be interpreted as part of the escape sequence.) Also, #pragma expand will now print an appropriate suffix on numeric constants with types other than int or double. If precompiled headers are being used, #pragma expand will not print the tokens for the portion of the code that has been precompiled and represented in the .sym file. It will still print the tokens for the remainder of the code (including all functions). If you want to see the tokens for all of the code, you can use the -I flag to make ORCA/C ignore the .sym file.