mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-22 07:30:54 +00:00
Do not erroneously treat integer constant expressions of type unsigned int as signed in certain contexts.
Unsigned constants in the range 0x8000-0xFFFF were erroneously being treated like negative signed values in some contexts, including in array declarators and in the case labels of switch statements where the expression switched over has type long or unsigned long. This could lead to bogus compile errors for array declarations and typedefs such as the following: typedef char foo[0x8000]; It could also lead to cases in switch statements not being properly matched, as in the following program: #include <stdio.h> int main(void) { long i = 0xFF00; switch (i) { case 0xFF00: puts("good"); break; default: puts("bad"); } }
This commit is contained in:
parent
0705a337b0
commit
b83ed7b17b
@ -3682,6 +3682,7 @@ else begin {record the expression for an initialize
|
|||||||
end {else if}
|
end {else if}
|
||||||
else if tree^.token.kind = uintconst then begin
|
else if tree^.token.kind = uintconst then begin
|
||||||
expressionValue := tree^.token.ival;
|
expressionValue := tree^.token.ival;
|
||||||
|
expressionValue := expressionValue & $0000FFFF;
|
||||||
expressionType := uwordPtr;
|
expressionType := uwordPtr;
|
||||||
isConstant := true;
|
isConstant := true;
|
||||||
end {else if}
|
end {else if}
|
||||||
|
Loading…
Reference in New Issue
Block a user