[PATCH] D131307: [Clang] Allow downgrading to a warning the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values
Stephan Bergmann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 12 01:13:57 PDT 2022
sberg added a comment.
In D131307#3714629 <https://reviews.llvm.org/D131307#3714629>, @shafik wrote:
> In D131307#3713011 <https://reviews.llvm.org/D131307#3713011>, @sberg wrote:
>
>> With this commit,
>>
>> $ cat test.cc
>> #include "boost/numeric/conversion/cast.hpp"
>> int main() { return boost::numeric_cast<int>(0L); }
>>
>> $ clang++ test.cc
>>
>> succeeds without any diagnostic, while with its parent commit https://github.com/llvm/llvm-project/commit/b3645353041818f61e2580635409ddb81ff5a272 " [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values" it had started to fail with
>
> Yes, that is intended. When modifying the change to allow it to be turned into a warning it started applying outside of constant expression contexts and that broke a lot more stuff.
I think we might be talking past each other here. There are three commits:
1. D130058 <https://reviews.llvm.org/D130058> "[Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values"
2. D131307 <https://reviews.llvm.org/D131307> "[Clang] Allow downgrading to a warning the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values"
3. D131528 <https://reviews.llvm.org/D131528> "[Clang] Restrict non fixed enum to a value outside the range of the enumeration values warning to context requiring a constant expression"
(1) had started to diagnose my reproducer as an error (and I assume it did rightly so). But then (2) stopped diagnosing it at all, letting the reproducer compile successfully without any diagnostic (and I assume wrongly so). (3) didn't make any further change regarding that behavior.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131307/new/
https://reviews.llvm.org/D131307
More information about the cfe-commits
mailing list