erichkeane added inline comments.
================
Comment at: clang/lib/AST/Decl.cpp:4609
+
+ if (NumNegativeBits) {
+ unsigned NumBits = std::max(NumNegativeBits, NumPositiveBits + 1);
----------------
How does this work if both NumNegativeBits and NumPositiveBits are 0? Based on
my reading of the standard, an empty enum should have the valid values 0 and 1,
so a 'bitwidth' of 1.
================
Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2409
+// Empty but as-if it had a single enumerator with value 0
+enum EEmpty {};
+
----------------
Would also like to see `enum E4 {e41=0};`, which should have the values 0 and 1.
================
Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2429
+ constexpr EEmpty x7 = static_cast<EEmpty>(1); // expected-error {{must be
initialized by a constant expression}}
+ // expected-note@-1 {{store of value outside of the range of unscoped enum,
valid values 0 to 0}}
+
----------------
Ok, so I think '1' should be valid here based on my reading.
An empty should be the exact same case as the proposed `E4` above, and I
believe we can never allow 'zero' bits.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130058/new/
https://reviews.llvm.org/D130058
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits