Closed lhearachel closed 2 months ago
I looked at this issue thinking it was a quick fix. But it seems we will be running into more issues w.r.t. not correctly parsing C. This was pointed out in the original PR which I and some others agreed with, but deemed the ability to have support for enum
at all more important.
The issue is as follows:
enum Bar {
BAR_0 = 0,
BAR_1 = 1,
};
enum {
VALUE_0 = 0,
VALUE_1, // 1
VALUE_2, // 2
VALUE_2a = BAR_1,
VALUE_3
};
is correct C, and would yield VALUE_2a = 1
and VALUE_3 = 2
. While you could have .equiv VALUE_2a, BAR_1
as the output you'd also need to take care of the enum
counter. (Here VALUE_3 = 2
)
I think we could just retain a collection of enum variables in the current preproc
TU in order to support this, but that's a little more work than I initially anticipated.
Use Case
Expectation
preproc
should parse thisenum
definition appropriately and create a.set
directive that assigns eitherVALUE_2
or2
toVALUE_2a
.Reality
preproc
fatals when it reachesVALUE_2a = VALUE_2
: