diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-04-25 21:49:00 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-04-25 21:49:00 -0400 |
commit | c83b9c54d9dee2dce5d8268472a745b013d166cc (patch) | |
tree | 3f720156dc7cf3e2092ac714801181cbac50f425 | |
parent | 288e4c64f6b4806358aabc9b99b2fba72bf04bf6 (diff) | |
download | gcc-c83b9c54d9dee2dce5d8268472a745b013d166cc.zip gcc-c83b9c54d9dee2dce5d8268472a745b013d166cc.tar.gz gcc-c83b9c54d9dee2dce5d8268472a745b013d166cc.tar.bz2 |
c++: ICE with requires-expr and -Wsequence-point [PR105304]
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.
-rw-r--r-- | gcc/c-family/c-common.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 70f55f3..bb0544e 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -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 index 0000000..f500af3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C @@ -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(); }) + ; +} |