[pushed] c++: fix arm-eabi bootstrap [PR105567]
Commit Message
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.
Tested x86_64-pc-linux-gnu and arm-eabi sim, applying to trunk.
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.
---
gcc/cp/typeck.cc | 4 ++--
gcc/testsuite/g++.dg/template/ctor10.C | 10 ++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/template/ctor10.C
base-commit: 0acdbe29f66017fc5cca40dcbd72a0dd41491d07
@@ -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;
new file mode 100644
@@ -0,0 +1,10 @@
+// PR bootstrap/105567
+// This was breaking with cdtor_returns_this.
+
+template <class T>
+struct A
+{
+ A() { return; }
+};
+
+A<int> a;