8sa1-gcc/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor2.C
Jason Merrill b04445d4a8 c++: Replace "C++2a" with "C++20".
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.
2020-05-13 15:16:49 -04:00

67 lines
1.5 KiB
C

// P0784R7
// { dg-do compile { target c++20 } }
struct S
{
constexpr S () : r (4), s (3) { --r; s -= 2; }
constexpr ~S () { if (s == 1) s = 0; else asm (""); if (s == 0 && r == 3) r = 0; else asm (""); }
int r, s;
};
struct T : public S
{
constexpr T () : t (2) {}
int t;
S u;
};
struct U : public S
{
constexpr U (int x) : u (x) {}
constexpr ~U () = default;
int u;
S v;
};
constexpr S a;
constexpr T b;
constexpr U c = 3;
static_assert (a.s == 1 && a.r == 3);
static_assert (b.s == 1 && b.r == 3 && b.t == 2 && b.u.s == 1 && b.u.r == 3);
static_assert (c.s == 1 && c.r == 3 && c.u == 3 && c.v.s == 1 && c.v.r == 3);
void
foo ()
{
static constexpr S d;
static constexpr T e;
static constexpr U f = 4;
static_assert (d.s == 1 && d.r == 3);
static_assert (e.s == 1 && e.r == 3 && e.t == 2 && e.u.s == 1 && e.u.r == 3);
static_assert (f.s == 1 && f.r == 3 && f.u == 4 && f.v.s == 1 && f.v.r == 3);
if (1)
{
constexpr S g;
constexpr T h;
constexpr U i = 5;
static_assert (g.s == 1 && g.r == 3);
static_assert (h.s == 1 && h.r == 3 && h.t == 2 && h.u.s == 1 && h.u.r == 3);
static_assert (i.s == 1 && i.r == 3 && i.u == 5 && i.v.s == 1 && i.v.r == 3);
}
}
constexpr bool
bar ()
{
S j;
T k;
U l = 6;
if (j.s != 1 || j.r != 3)
return false;
if (k.s != 1 || k.r != 3 || k.t != 2 || k.u.s != 1 || k.u.r != 3)
return false;
if (l.s != 1 || l.r != 3 || l.u != 6 || l.v.s != 1 || l.v.r != 3)
return false;
return true;
}
static_assert (bar ());