mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-23 14:30:12 +00:00
Fix problem with using values of enum constants in integer constant expressions.
This could cause spurious errors, or in some cases bad code generation. The following example illustrates the problem: #include <stdio.h> enum {A,B,C}; /* arr was treated as having a size of 1, rather than 3 */ char arr[(int)C+1] = {1,2,3}; /* incorrectly gave an error for initializer */ int main(void) { static int i = (int)C+1; /* incorrectly gave an error */ printf("%zu\n", sizeof(arr)); printf("%i\n", (int)C+1); /* OK */ printf("%i\n", i); }
This commit is contained in:
parent
618188c6b2
commit
17de3914ad
@ -837,6 +837,7 @@ var
|
|||||||
end; {else}
|
end; {else}
|
||||||
end {if id = nill}
|
end {if id = nill}
|
||||||
else if id^.itype^.kind = enumConst then begin
|
else if id^.itype^.kind = enumConst then begin
|
||||||
|
stack^.token.class := intConstant;
|
||||||
stack^.token.kind := intconst;
|
stack^.token.kind := intconst;
|
||||||
stack^.token.ival := id^.itype^.eval;
|
stack^.token.ival := id^.itype^.eval;
|
||||||
end; {else if}
|
end; {else if}
|
||||||
|
Loading…
Reference in New Issue
Block a user