[gcc r10-9415] c++: Normalization and deduction guide rewriting [PR96199]
Jason Merrill
jason@gcc.gnu.org
Thu Mar 4 04:49:33 GMT 2021
https://gcc.gnu.org/g:a588c87ba309492b351c1a55b08d907b65913e2c
commit r10-9415-ga588c87ba309492b351c1a55b08d907b65913e2c
Author: Jason Merrill <jason@redhat.com>
Date: Wed Mar 3 17:38:55 2021 -0500
c++: Normalization and deduction guide rewriting [PR96199]
This is a subset of r11-2748; we don't want to rewrite all deduction guides
in GCC 10, but we do need the push_nested_class in normalization to avoid
breaking cmcstl2.
gcc/cp/ChangeLog:
PR c++/96199
* cp-tree.h (struct push_nested_class_guard): New.
* constraint.cc (get_normalized_constraints_from_decl): Use it.
Diff:
---
gcc/cp/constraint.cc | 2 ++
gcc/cp/cp-tree.h | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index f54c220253f..89a2bb5223b 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -841,6 +841,8 @@ get_normalized_constraints_from_decl (tree d, bool diag = false)
if (tree *p = hash_map_safe_get (normalized_map, tmpl))
return *p;
+ push_nested_class_guard pncs (DECL_CONTEXT (d));
+
tree args = generic_targs_for (tmpl);
tree ci = get_constraints (decl);
tree norm = get_normalized_constraints_from_info (ci, args, tmpl, diag);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 82716d33c49..9a66fe5884f 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -8132,6 +8132,24 @@ is_constrained_auto (const_tree t)
return is_auto (t) && PLACEHOLDER_TYPE_CONSTRAINTS (t);
}
+/* RAII class to push/pop class scope T; if T is not a class, do nothing. */
+
+struct push_nested_class_guard
+{
+ bool push;
+ push_nested_class_guard (tree t)
+ : push (t && CLASS_TYPE_P (t))
+ {
+ if (push)
+ push_nested_class (t);
+ }
+ ~push_nested_class_guard ()
+ {
+ if (push)
+ pop_nested_class ();
+ }
+};
+
#if CHECKING_P
namespace selftest {
extern void run_cp_tests (void);
More information about the Gcc-cvs
mailing list