diff options
author | Nina Ranns <dinka.ranns@gmail.com> | 2024-07-04 17:08:58 +0100 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2024-07-10 11:17:33 -0400 |
commit | c829042849da4e82668db8c845ef0847264c8687 (patch) | |
tree | 4977281161511b5aef66909103b8c1150ff4ba52 /gcc/cp/contracts.cc | |
parent | 8326956159053b215b5cfe6cd41bfceff413491e (diff) | |
download | gcc-c829042849da4e82668db8c845ef0847264c8687.zip gcc-c829042849da4e82668db8c845ef0847264c8687.tar.gz gcc-c829042849da4e82668db8c845ef0847264c8687.tar.bz2 |
c++, contracts: Fix ICE in create_tmp_var [PR113968]
During contract parsing, in grok_contract(), we proceed even if the
condition contains errors. This results in contracts with embedded errors
which eventually confuse gimplify. Checks for errors have been added in
grok_contract() to exit early if an error is encountered.
PR c++/113968
gcc/cp/ChangeLog:
* contracts.cc (grok_contract): Check for error_mark_node early
exit.
gcc/testsuite/ChangeLog:
* g++.dg/contracts/pr113968.C: New test.
Signed-off-by: Nina Ranns <dinka.ranns@gmail.com>
Diffstat (limited to 'gcc/cp/contracts.cc')
-rw-r--r-- | gcc/cp/contracts.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc index 634e3cf..a7d0fda 100644 --- a/gcc/cp/contracts.cc +++ b/gcc/cp/contracts.cc @@ -750,6 +750,9 @@ tree grok_contract (tree attribute, tree mode, tree result, cp_expr condition, location_t loc) { + if (condition == error_mark_node) + return error_mark_node; + tree_code code; if (is_attribute_p ("assert", attribute)) code = ASSERTION_STMT; @@ -785,6 +788,10 @@ grok_contract (tree attribute, tree mode, tree result, cp_expr condition, /* The condition is converted to bool. */ condition = finish_contract_condition (condition); + + if (condition == error_mark_node) + return error_mark_node; + CONTRACT_CONDITION (contract) = condition; return contract; |