[PATCH] D46304: [MC] Add llvm_unreachable to toString to fix compile time warning.

Gabor Buella via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 23:49:59 PDT 2018


GBuella added a comment.



> The wording says `the values of the enumeration are the values of the underlying type`.   I think perhaps that wording is a little wrong.  Perhaps the final `the` should be removed?   Surly what it trying to say is that is that the valid enum values are themselves values of the underlying type, not that *all* possible value of the underlying type are also valid enum values.

@sbc100, just read after that sentence:
"Otherwise, for an enumeration where emin is the smallest enumerator and emax is the largest, the values of the enumeration are the values in the range bmin to bmax, ..."

So, for one without a fixed type, the way I would interpret it, the following type has 7 valid values (0, 1, 2, 3, 4, 5, 6, 7):

  enum x {
    a = 2
    b = 6
  };

A bit later on it is explicitly stated, that:
"It is possible to define an enumeration that has values not defined by any of its enumerators"
Therefore, even for such simple enum without a fixed type, a default case can be useful sometimes.

And I believe in the case of those with fixed types, the range of the "values of the enumeration" is just extended to *all* possible values of that underlying type -- well, that would make sense to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D46304





More information about the llvm-commits mailing list