HomePhabricator

[c++20] P1143R2: Add support for the C++20 'constinit' keyword.

Authored by Richard Smith <richard-llvm@metafoo.co.uk> on Sep 4 2019, 1:30 PM.

Description

[c++20] P1143R2: Add support for the C++20 'constinit' keyword.

This is mostly the same as the
[[clang::require_constant_initialization]] attribute, but has a couple
of additional syntactic and semantic restrictions.

In passing, I added a warning for the attribute form being added after
we have already seen the initialization of the variable (but before we
see the definition); that case previously slipped between the cracks and
the attribute was silently ignored.

llvm-svn: 370972

Event Timeline

Richard Smith <richard-llvm@metafoo.co.uk> committed rGa6e8b685e134: [c++20] P1143R2: Add support for the C++20 'constinit' keyword. (authored by Richard Smith <richard-llvm@metafoo.co.uk>).Sep 4 2019, 1:30 PM

@rsmith: gcc allows you to use constinit in pre C++20 mode with "__constinit" keyword. Clang does not.

https://godbolt.org/z/T199nsPda