murphi2c: give enum constants the correct type in generated code
The type used to back an enum seems to be implementation defined (either that or
-- more likely -- the warnings related to -Wsign-compare differ between Clang
and GCC. This meant that code like the following:
type
t: enum { A, B, C };
var
x: t;
const
N: A;
...
if x = N then
...
which would generate C code like:
typedef enum { A, B, C } t;
t x;
const int N = A;
...
if (x == N) {
...
would cause a -Wsign-compare warning if the compiler used an unsigned type to
back the enum. To avoid this, we now emit the type of a constant as the same as
the type of the right hand side (using __typeof__), knowing that the right hand
side will be strongly typed as either the enum or boolean or value_type.
parent
0072e644
Please register or sign in to comment