Make clang-cl error when a function definition is missing 'noexcept',
and succeed without warnings when missing '__declspec(nothrow)' or 'throw'.
Fixes pr52860
Differential D116256
[-fms-extensions] Make some exception specification warnings/errors compatible with what cl.exe does akhuang on Dec 23 2021, 3:24 PM. Authored by
Details Make clang-cl error when a function definition is missing 'noexcept', Fixes pr52860
Diff Detail
Event TimelineComment Actions Thanks for the patch! This looks roughly right to me. Maybe the list of ESTs that are allowed to be mismatched should be opt-in instead of opt-out? (i.e. instead of checking for "not EST_BasicNoexcept / EST_DependentNoexcept", check for EST_NoThrow (I think?) Not sure which way is better. (Looks like the old code was added for https://llvm.org/PR25265) Could you check that we still emit the warning on line 5 in https://godbolt.org/z/bxfx8jsjd ? The test is mostly from https://docs.microsoft.com/en-us/cpp/build/reference/zc-noexcepttypes?view=msvc-170 -- it feels like we might want to have different behavior in c++17 (and later) and c++14 (and earlier) for some of the diags, possibly. Looks like MSVC also has an error on line 15 by default (with /std:c++17, it seems to accept it with /std:c++14), while we only warn. (I'm a bit surprised the noexcept bit doesn't make it into the mangled name in the ms abi, but we're consistent with msvc about this so that's all good.)
Comment Actions It did not still emit the warning but I've changed it now. I'm not sure why https://llvm.org/PR25265 added a new warning (ext_ms_missing_exception_specification) instead of just using ext_missing_exception_specification; I guess I'll get rid of it anyway.
|
nit: LLVM style says "no else after return", so this should become a regular if now.