We currently fail upon the following because an assert in dependent_type_p
fails for f's parameter
=== cut here ===
consteval int id (int i) { return i; }
constexpr int
f (auto i) requires requires { id (i) } { return i; }
void g () { f (42); }
=== cut here ===
This patch fixes this by relaxing the assert to pass during error recovery.
Successfully tested on x86_64-pc-linux-gnu.
PR c++/111106
gcc/cp/ChangeLog:
* pt.cc (dependent_type_p): Don't fail assert during error recovery.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/consteval37.C: New test.
/* If we are not processing a template, then nobody should be
providing us with a dependent type. */
gcc_assert (type);
- gcc_assert (TREE_CODE (type) != TEMPLATE_TYPE_PARM || is_auto (type));
+ gcc_assert (TREE_CODE (type) != TEMPLATE_TYPE_PARM || is_auto (type)
+ || seen_error());
return false;
}
--- /dev/null
+// PR c++/111106
+// { dg-do compile { target c++20 } }
+
+consteval int id (int i) { return i; }
+
+constexpr int f (auto i)
+ requires requires { id (i) } // { dg-error "expected" }
+{
+ return i;
+}
+
+void g () {
+ f (42);
+}
+
+// { dg-excess-errors "" }