On 3/9/21 10:22 PM, Marek Polacek wrote:
This fixes an ICE on invalid code where one of the parameters was
error_mark_node and thus resetting its DECL_CONTEXT crashed.
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
OK.
Jason
gcc/cp/ChangeLog:
PR c++/99500
* parser.c (cp_parser_requirement_parameter_list): Handle
error_mark_node.
gcc/testsuite/ChangeLog:
PR c++/99500
* g++.dg/cpp2a/concepts-err3.C: New test.
---
gcc/cp/parser.c | 7 +++++--
gcc/testsuite/g++.dg/cpp2a/concepts-err3.C | 4 ++++
2 files changed, 9 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-err3.C
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 0a7d18af98b..dbc44ed0765 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -28835,8 +28835,11 @@ cp_parser_requirement_parameter_list (cp_parser
*parser)
if (parm == void_list_node || parm == explicit_void_list_node)
break;
tree decl = TREE_VALUE (parm);
- DECL_CONTEXT (decl) = NULL_TREE;
- CONSTRAINT_VAR_P (decl) = true;
+ if (decl != error_mark_node)
+ {
+ DECL_CONTEXT (decl) = NULL_TREE;
+ CONSTRAINT_VAR_P (decl) = true;
+ }
}
return parms;
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-err3.C
b/gcc/testsuite/g++.dg/cpp2a/concepts-err3.C
new file mode 100644
index 00000000000..9427fd5c5a6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-err3.C
@@ -0,0 +1,4 @@
+// PR c++/99500
+// { dg-do compile { target c++20 } }
+
+bool b = requires (bool a, int a) { requires true; }; // { dg-error "conflicting
declaration" }
base-commit: 8dc225d311ed87633fa970164bdda19bf228b8a3