From d1847d40bee6867f1705a32a8070f8f71094cd08 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Thu, 22 Feb 2024 21:41:53 -0600 Subject: [PATCH] Set numString properly for numeric tokens generated by ##. Previously, it was not necessarily set correctly for the newly-generated token. This would result in incorrect behavior if that token was an operand to another ## operator, as in the following example: #define x(a,b,c) a##b##c x(1,2,3) --- Scanner.pas | 4 ++++ cc.notes | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Scanner.pas b/Scanner.pas index 90fe9a5..c38f6e8 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -1311,6 +1311,7 @@ var class1,class2: tokenClass; {token classes} i: integer; {loop variable} kind1,kind2: tokenEnum; {token kinds} + lsaveNumber: boolean; {local copy of saveNumber} lt: tokenType; {local copy of token} str1,str2: stringPtr; {identifier strings} @@ -1379,7 +1380,10 @@ else if class1 in numericConstants then begin end; {else} workString := concat(tk1.numString^, str2^); lt := token; + lsaveNumber := saveNumber; + saveNumber := true; DoNumber(true); + saveNumber := lsaveNumber; tk1 := token; token := lt; goto 1; diff --git a/cc.notes b/cc.notes index f8446ee..eb0700e 100644 --- a/cc.notes +++ b/cc.notes @@ -1612,6 +1612,8 @@ If you use #pragma debug 0x0010 to enable stack check debug code, the compiler w 11. If fclose() was called on a file created by tmpfile() at a time when there was very little free memory available, it could corrupt memory and cause a crash. (This will no longer happen, but the file still may not be deleted if there is insufficient memory available when fclose() is called.) +12. If a numeric token formed using a ## preprocessor operator was an operand for another ## preprocessor operator, the resulting token would be incorrect. + -- Bugs from C 2.1.1 B3 that have been fixed in C 2.2.0 --------------------- 1. There were various bugs that could cause incorrect code to be generated in certain cases. Some of these were specific to certain optimization passes, alone or in combination.