]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: ICE with requires-expr and -Wsequence-point [PR105304]
authorPatrick Palka <ppalka@redhat.com>
Tue, 26 Apr 2022 01:49:00 +0000 (21:49 -0400)
committerPatrick Palka <ppalka@redhat.com>
Tue, 26 Apr 2022 01:49:00 +0000 (21:49 -0400)
Here we're crashing from verify_sequence_points for this requires-expr
condition because it contains a templated CAST_EXPR with empty operand,
and verify_tree doesn't ignore this empty operand only because the
manual tail recursion that it performs for unary expression trees skips
the NULL test.

PR c++/105304

gcc/c-family/ChangeLog:

* c-common.cc (verify_tree) [restart]: Move up to before the
NULL test.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-requires30.C: New test.

gcc/c-family/c-common.cc
gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C [new file with mode: 0644]

index 70f55f3a3465a60f75e5bdec2c28de371f1a9774..bb0544eeaea798c786cb2aafd62275a172d2a63b 100644 (file)
@@ -2009,12 +2009,12 @@ verify_tree (tree x, struct tlist **pbefore_sp, struct tlist **pno_sp,
   enum tree_code code;
   enum tree_code_class cl;
 
+ restart:
   /* X may be NULL if it is the operand of an empty statement expression
      ({ }).  */
   if (x == NULL)
     return;
 
- restart:
   code = TREE_CODE (x);
   cl = TREE_CODE_CLASS (code);
 
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C
new file mode 100644 (file)
index 0000000..f500af3
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/105304
+// { dg-do compile { target c++20 } }
+// { dg-additional-options "-Wall -Wsequence-point" }
+
+struct A { };
+
+int main() {
+  if (requires { A(); })
+    ;
+}