C++20 isn't final quite yet, but all that remains is formalities, so let's go ahead and change all the references. I think for the next C++ standard we can just call it C++23 rather than C++2b, since the committee has been consistent about time-based releases rather than feature-based. gcc/c-family/ChangeLog 2020-05-13 Jason Merrill <jason@redhat.com> * c.opt (std=c++20): Make c++2a the alias. (std=gnu++20): Likewise. * c-common.h (cxx_dialect): Change cxx2a to cxx20. * c-opts.c: Adjust. * c-cppbuiltin.c: Adjust. * c-ubsan.c: Adjust. * c-warn.c: Adjust. gcc/cp/ChangeLog 2020-05-13 Jason Merrill <jason@redhat.com> * call.c, class.c, constexpr.c, constraint.cc, decl.c, init.c, lambda.c, lex.c, method.c, name-lookup.c, parser.c, pt.c, tree.c, typeck2.c: Change cxx2a to cxx20. libcpp/ChangeLog 2020-05-13 Jason Merrill <jason@redhat.com> * include/cpplib.h (enum c_lang): Change CXX2A to CXX20. * init.c, lex.c: Adjust.
59 lines
2.0 KiB
C
59 lines
2.0 KiB
C
// PR c++/91360 - Implement C++20 P1143R2: constinit
|
|
// { dg-do compile { target c++20 } }
|
|
|
|
constinit constinit int v1; // { dg-error "duplicate .constinit." }
|
|
constexpr constinit int v2 = 1; // { dg-error "can use at most one of the .constinit. and .constexpr. specifiers" }
|
|
constinit constexpr int v3 = 1; // { dg-error "an use at most one of the .constinit. and .constexpr. specifiers" }
|
|
|
|
extern static constinit int v4; // { dg-error "conflicting specifiers" }
|
|
extern thread_local constinit int v5;
|
|
extern constinit int v6;
|
|
|
|
constinit typedef int T; // { dg-error ".constinit. cannot appear in a typedef declaration" }
|
|
|
|
struct S2 {
|
|
constinit int m1; // { dg-error "non-static data member .m1. declared .constinit." }
|
|
constinit unsigned int b : 32; // { dg-error " non-static data member .b. declared .constinit." }
|
|
};
|
|
|
|
struct S3 {
|
|
constinit S3() {} // { dg-error ".constinit. on function return type is not allowed" }
|
|
constinit ~S3() {} // { dg-error ".constinit. on function return type is not allowed" }
|
|
};
|
|
|
|
constinit struct S4 { // { dg-error ".constinit. cannot be used for type declarations" }
|
|
};
|
|
|
|
template<constinit int I> // { dg-error "a parameter cannot be declared .constinit." }
|
|
struct X { };
|
|
|
|
int
|
|
fn1 ()
|
|
{
|
|
// Not static storage
|
|
constinit int a1 = 42; // { dg-error "17:.constinit. can only be applied to a variable with static or thread storage" }
|
|
constinit int a2 = 42; // { dg-error "17:.constinit. can only be applied to a variable with static or thread storage" }
|
|
extern constinit int e1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
constinit int // { dg-error ".constinit. on function return type is not allowed" }
|
|
fn3 ()
|
|
{
|
|
}
|
|
|
|
void
|
|
fn2 (int i, constinit int p) // { dg-error "a parameter cannot be declared .constinit." }
|
|
{
|
|
constinit auto l = [i](){ return i; }; // { dg-error "18:.constinit. can only be applied to a variable with static or thread storage" }
|
|
}
|
|
|
|
struct B { int d; };
|
|
|
|
void
|
|
fn3 (B b)
|
|
{
|
|
constinit auto [ a ] = b; // { dg-error ".constinit. can only be applied to a variable with static or thread storage" }
|
|
}
|