From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id AA20C384B075; Mon, 9 May 2022 23:33:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA20C384B075 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Patrick Palka To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10605] c++: ICE with requires-expr and -Wsequence-point [PR105304] X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 09ab962a42d81eff636c1ebc7de43dac7cc7a7c0 X-Git-Newrev: 9a8b7edbe65ec6350a996eab51a7c26a087e6d2b Message-Id: <20220509233307.AA20C384B075@sourceware.org> Date: Mon, 9 May 2022 23:33:07 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2022 23:33:07 -0000 https://gcc.gnu.org/g:9a8b7edbe65ec6350a996eab51a7c26a087e6d2b commit r10-10605-g9a8b7edbe65ec6350a996eab51a7c26a087e6d2b Author: Patrick Palka Date: Mon Apr 25 21:49:00 2022 -0400 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.c (verify_tree) [restart]: Move up to before the NULL test. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires30.C: New test. (cherry picked from commit c83b9c54d9dee2dce5d8268472a745b013d166cc) Diff: --- gcc/c-family/c-common.c | 2 +- gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 064c2f263f0..661a194fc89 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1838,12 +1838,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 00000000000..f500af3f616 --- /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(); }) + ; +}