Commit 9dd1e514 authored by Matthew Fernandez's avatar Matthew Fernandez
Browse files

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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment