diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -340,6 +340,9 @@ can be controlled using ``-fcaret-diagnostics-max-lines=``. - Clang no longer emits ``-Wunused-variable`` warnings for variables declared with ``__attribute__((cleanup(...)))`` to match GCC's behavior. +- When diagnosing a constant expression where an enum without a fixed underlying + type is set to a value outside the range of the enum's values, clang will now + print the name of the enum in question. Bug Fixes in This Version ------------------------- diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -2476,6 +2476,16 @@ const NumberType neg_one = (NumberType) ((NumberType) 0 - (NumberType) 1); // ok, not a constant expression context } +template struct Bitfield { + static constexpr T max = static_cast((1 << size) - 1); +}; + +void testValueInRangeOfEnumerationValuesViaTemplate() { + Bitfield good; + Bitfield bad; + // cxx11-error@-6 {{integer value 15 is outside the valid range of values [0, 7] for the enumeration type 'E2'}} +} + enum SortOrder { AscendingOrder, DescendingOrder