public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10722] c++: empty base constexpr -fno-elide-ctors [PR105245]
@ 2022-05-12 21:15 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-05-12 21:15 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6c7905a9f10d28dfd27ddf21d3bf38a3e261ee10
commit r10-10722-g6c7905a9f10d28dfd27ddf21d3bf38a3e261ee10
Author: Jason Merrill <jason@redhat.com>
Date: Tue Apr 12 17:46:59 2022 -0400
c++: empty base constexpr -fno-elide-ctors [PR105245]
The patch for 100111 extended our handling of empty base elision to the case
where the derived class has no other fields, but we still need to make sure
that there's some initializer for the derived object.
PR c++/105245
PR c++/100111
gcc/cp/ChangeLog:
* constexpr.c (cxx_eval_store_expression): Build a CONSTRUCTOR
as needed in empty base handling.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/constexpr-empty2.C: Add -fno-elide-constructors.
Diff:
---
gcc/cp/constexpr.c | 6 ++++++
gcc/testsuite/g++.dg/cpp1y/constexpr-empty2.C | 1 +
2 files changed, 7 insertions(+)
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 28b0a88a658..31af214a28c 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5149,6 +5149,12 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
{
/* See above on initialization of empty bases. */
gcc_assert (is_empty_class (TREE_TYPE (init)) && !lval);
+ if (!*valp)
+ {
+ /* But do make sure we have something in *valp. */
+ *valp = build_constructor (type, NULL);
+ CONSTRUCTOR_NO_CLEARING (*valp) = no_zero_init;
+ }
return init;
}
else
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-empty2.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-empty2.C
index 2acfa98364b..9768b89904e 100644
--- a/gcc/testsuite/g++.dg/cpp1y/constexpr-empty2.C
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-empty2.C
@@ -1,4 +1,5 @@
// { dg-do compile { target c++14 } }
+// { dg-additional-options -fno-elide-constructors }
struct A
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-12 21:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 21:15 [gcc r10-10722] c++: empty base constexpr -fno-elide-ctors [PR105245] Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).