* [pushed] c++: missing aggregate base ctor [PR102045]
@ 2022-03-28 13:33 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-03-28 13:33 UTC (permalink / raw)
To: gcc-patches
When make_base_init_ok changes a call to a complete constructor into a call
to a base constructor, we were never marking the base ctor as used, so it
didn't get emitted.
Tested x86_64-pc-linux-gnu, applying to trunk.
PR c++/102045
gcc/cp/ChangeLog:
* call.cc (make_base_init_ok): Call make_used.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/aggr-base12.C: New test.
---
gcc/cp/call.cc | 1 +
gcc/testsuite/g++.dg/cpp1z/aggr-base12.C | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp1z/aggr-base12.C
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index dfe370d685d..73fede5a3df 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -8958,6 +8958,7 @@ make_base_init_ok (tree exp)
call target. It would be possible to splice in the appropriate
arguments, but probably not worth the complexity. */
return false;
+ mark_used (fn);
AGGR_INIT_EXPR_FN (exp) = build_address (fn);
return true;
}
diff --git a/gcc/testsuite/g++.dg/cpp1z/aggr-base12.C b/gcc/testsuite/g++.dg/cpp1z/aggr-base12.C
new file mode 100644
index 00000000000..6f5a6b2056a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aggr-base12.C
@@ -0,0 +1,24 @@
+// PR c++/102045
+// { dg-do link { target c++17 } }
+
+template<typename T>
+struct span
+{
+ template<unsigned long N>
+ constexpr span(T (&a)[N]) : data(a), len(N) { }
+ constexpr bool empty() const { return len == 0; }
+ T* data;
+ unsigned long len;
+};
+
+struct byte_writer: span<char> {
+ constexpr void do_something() noexcept {
+ (void)this->empty();
+ }
+};
+
+int main() {
+ char array[1];
+ auto writer = byte_writer{array};
+ writer.do_something();
+}
base-commit: bc86a86a4f2c057bc0e0be94dcbb8c128ae7f717
prerequisite-patch-id: 09e711b54e7911a4a04bd7808abc1b73ae4482ba
prerequisite-patch-id: 566cf0772894d0c6a842b2e0ca62eb1d5ae8ad33
prerequisite-patch-id: b1def7e83e76c1652efb483cb2b67e472d15b720
--
2.27.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-28 13:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 13:33 [pushed] c++: missing aggregate base ctor [PR102045] 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).