[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)

Max Winkler via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 26 09:35:42 PDT 2024


MaxEW707 wrote:

> This should be controllable via -fms-extensions/-fno-ms-extensions; having its own dialect flag is a bit novel but I'm not strongly opposed. CC @MaskRay @jansvoboda11 for driver/options opinions

For this feedback I intentionally didn't do this because this ms extension isn't one intended to be always enabled.
-fms-extensions enables extensions that are always valid to use with msvc such as the `__try` and `__finally` keywords for SEH.

MSVC allows controlling this option independently here, [/Zc:ReferenceBinding](https://learn.microsoft.com/en-us/cpp/build/reference/zc-referencebinding-enforce-reference-binding-rules?view=msvc-170).
MSVC `/permissive-` disables this reference binding extension, however `__try` and friends are still available as they are vital for operating within a Win32 environment. Newer C++ modes like C++20 also implicitly disable this reference binding extension in MSVC as they move towards proper C++ conformance by default.

This is a one off extension similar to -fms-volatile or -fms-define-stdc. I would like to keep it a separate option that can be individually controlled instead of grouping it with -fms-extensions.

https://github.com/llvm/llvm-project/pull/99833


More information about the cfe-commits mailing list