public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-331] c++: fix arm-eabi bootstrap [PR105567]
@ 2022-05-11 17:52 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-05-11 17:52 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4dc86f716fe6087f1cf786d69c0c6f3f5af810f0
commit r13-331-g4dc86f716fe6087f1cf786d69c0c6f3f5af810f0
Author: Jason Merrill <jason@redhat.com>
Date: Wed May 11 09:44:57 2022 -0400
c++: fix arm-eabi bootstrap [PR105567]
Since my r13-112, in the template we were changing 'return' to 'return this'
on cdtor_returns_this targets, and then getting confused by that when
instantiating. So only make that change at instantiation time.
PR bootstrap/105567
gcc/cp/ChangeLog:
* typeck.cc (check_return_expr): Don't mess with ctor return value
while parsing a template.
gcc/testsuite/ChangeLog:
* g++.dg/template/ctor10.C: New test.
Diff:
---
gcc/cp/typeck.cc | 4 ++--
gcc/testsuite/g++.dg/template/ctor10.C | 10 ++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 57e55ed48d1..6ecdd97697d 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -10448,7 +10448,7 @@ check_return_expr (tree retval, bool *no_warning)
if (retval)
error_at (loc, "returning a value from a destructor");
- if (targetm.cxx.cdtor_returns_this ())
+ if (targetm.cxx.cdtor_returns_this () && !processing_template_decl)
retval = current_class_ptr;
else
return NULL_TREE;
@@ -10463,7 +10463,7 @@ check_return_expr (tree retval, bool *no_warning)
/* You can't return a value from a constructor. */
error_at (loc, "returning a value from a constructor");
- if (targetm.cxx.cdtor_returns_this ())
+ if (targetm.cxx.cdtor_returns_this () && !processing_template_decl)
retval = current_class_ptr;
else
return NULL_TREE;
diff --git a/gcc/testsuite/g++.dg/template/ctor10.C b/gcc/testsuite/g++.dg/template/ctor10.C
new file mode 100644
index 00000000000..cf10fc5b19a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ctor10.C
@@ -0,0 +1,10 @@
+// PR bootstrap/105567
+// This was breaking with cdtor_returns_this.
+
+template <class T>
+struct A
+{
+ A() { return; }
+};
+
+A<int> a;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-11 17:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 17:52 [gcc r13-331] c++: fix arm-eabi bootstrap [PR105567] 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).