aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSimon Martin <simon@nasilyan.com>2024-05-24 17:00:17 +0200
committerSimon Martin <simon@nasilyan.com>2024-06-04 17:10:56 +0200
commitcfbd8735359d84a2d716549415eac70e885167bf (patch)
tree4cf03d1913472695325181049d433edcf3a1286a /gcc
parent2197814011eec75022aa8550f10621409b69d4a1 (diff)
downloadgcc-cfbd8735359d84a2d716549415eac70e885167bf.zip
gcc-cfbd8735359d84a2d716549415eac70e885167bf.tar.gz
gcc-cfbd8735359d84a2d716549415eac70e885167bf.tar.bz2
Fix PR c++/111106: missing ; causes internal compiler error
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/pt.cc3
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/consteval37.C16
2 files changed, 18 insertions, 1 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index dfce1b3..edb94a0 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -28019,7 +28019,8 @@ dependent_type_p (tree type)
/* 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;
}
diff --git a/gcc/testsuite/g++.dg/cpp2a/consteval37.C b/gcc/testsuite/g++.dg/cpp2a/consteval37.C
new file mode 100644
index 0000000..519d83d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/consteval37.C
@@ -0,0 +1,16 @@
+// 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 "" }