Give an appropriate error for an illegal operator in a constant expression.

This was being reported as an "illegal type cast".
This commit is contained in:
Stephen Heumann 2021-08-22 20:33:34 -05:00
parent e4515e580a
commit 2b9d332580
3 changed files with 4 additions and 1 deletions

View File

@ -2163,7 +2163,7 @@ if token.kind in startExpression then begin
and (token.kind = sizeofsy))
or ((kind <> initializerExpression)
and (token.kind = uand)) then begin
Error(40);
Error(161);
errorFound := true;
end; {if}
if token.kind in {make sure we get what we want}

View File

@ -714,6 +714,7 @@ if list or (numErr <> 0) then begin
158: msg := @'_Generic expression includes two compatible types';
159: msg := @'_Generic expression includes multiple default cases';
160: msg := @'no matching association in _Generic expression';
161: msg := @'illegal operator in a constant expression';
otherwise: Error(57);
end; {case}
writeln(msg^);

View File

@ -1196,6 +1196,8 @@ int foo(int[42]);
157. An error was not reported if code tried to define an enumeration constant with a value in the range 0xFFFF8000 to 0xFFFFFFFF. (Enumeration constants are limited to values representable as an int.)
158. An "illegal type cast" error would be reported when an illegal operator was used in a constant expression. An appropriate error message is now produced.
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
1. In some situations, fread() reread the first 1K or so of the file.