dim updated this revision to Diff 531011. dim added a comment. Add release note and test with template instantiation.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152788/new/ https://reviews.llvm.org/D152788 Files: clang/docs/ReleaseNotes.rst clang/test/SemaCXX/constant-expression-cxx11.cpp Index: clang/test/SemaCXX/constant-expression-cxx11.cpp =================================================================== --- clang/test/SemaCXX/constant-expression-cxx11.cpp +++ 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<class T, unsigned size> struct Bitfield { + static constexpr T max = static_cast<T>((1 << size) - 1); +}; + +void testValueInRangeOfEnumerationValuesViaTemplate() { + Bitfield<E2, 3> good; + Bitfield<E2, 4> 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 Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ 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 -------------------------
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp =================================================================== --- clang/test/SemaCXX/constant-expression-cxx11.cpp +++ 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<class T, unsigned size> struct Bitfield { + static constexpr T max = static_cast<T>((1 << size) - 1); +}; + +void testValueInRangeOfEnumerationValuesViaTemplate() { + Bitfield<E2, 3> good; + Bitfield<E2, 4> 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 Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ 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 -------------------------
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits