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.
This commit is contained in:
Stephen Heumann 2022-03-01 19:46:14 -06:00
parent 182cf66754
commit f531f38463
2 changed files with 15 additions and 11 deletions

View File

@ -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

View File

@ -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.