@@ -2171,6 +2171,8 @@ get_evaluation_semantic(tree contract)
21712171 return CES_QUICK;
21722172 case CCS_NOEXCEPT_ENFORCE:
21732173 return CES_NOEXCEPT_ENFORCE;
2174+ case CCS_NOEXCEPT_OBSERVE:
2175+ return CES_NOEXCEPT_OBSERVE;
21742176 }
21752177}
21762178
@@ -2375,12 +2377,14 @@ build_contract_check (tree contract)
23752377 finish_if_stmt_cond (cond, if_stmt);
23762378 /* Using the P2900 names here c++2a ENFORCE=NEVER, OBSERVE=MAYBE. */
23772379 if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2378- || semantic == CCS_NOEXCEPT_ENFORCE)
2380+ || semantic == CCS_NOEXCEPT_ENFORCE
2381+ || semantic == CCS_NOEXCEPT_OBSERVE)
23792382 {
23802383 tree violation = build_contract_violation (contract,
23812384 /* is_const*/ true );
2382- build_contract_handler_call (violation,
2383- semantic == CCS_NOEXCEPT_ENFORCE);
2385+ bool noexcept_wrap = (semantic == CCS_NOEXCEPT_ENFORCE)
2386+ || (semantic == CCS_NOEXCEPT_OBSERVE);
2387+ build_contract_handler_call (violation, noexcept_wrap);
23842388 }
23852389
23862390 if (semantic == CCS_QUICK)
@@ -2417,7 +2421,8 @@ build_contract_check (tree contract)
24172421 violation object or handler. */
24182422 tree excp_ = NULL_TREE;
24192423 if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2420- || semantic ==CCS_NOEXCEPT_ENFORCE)
2424+ || semantic ==CCS_NOEXCEPT_ENFORCE
2425+ || semantic == CCS_NOEXCEPT_OBSERVE)
24212426 {
24222427 excp_ = build_decl (loc, VAR_DECL, NULL , boolean_type_node);
24232428 /* compiler-generated. */
@@ -2433,7 +2438,8 @@ build_contract_check (tree contract)
24332438
24342439 tree violation = NULL_TREE;
24352440 if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2436- || semantic == CCS_NOEXCEPT_ENFORCE)
2441+ || semantic == CCS_NOEXCEPT_ENFORCE
2442+ || semantic == CCS_NOEXCEPT_OBSERVE)
24372443 violation = build_contract_violation (contract, /* is_const*/ false );
24382444
24392445 /* Wrap the contract check in a try-catch. */
@@ -2446,7 +2452,8 @@ build_contract_check (tree contract)
24462452 tree handler = begin_handler ();
24472453 finish_handler_parms (NULL_TREE, handler); /* catch (...) */
24482454 if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2449- || semantic == CCS_NOEXCEPT_ENFORCE)
2455+ || semantic == CCS_NOEXCEPT_ENFORCE
2456+ || semantic == CCS_NOEXCEPT_OBSERVE)
24502457 {
24512458 /* Update the violation object type. */
24522459 tree v_type = get_pseudo_contract_violation_type ();
@@ -2457,7 +2464,9 @@ build_contract_check (tree contract)
24572464 r = cp_build_init_expr (r, build_int_cst (integer_type_node,
24582465 CDM_EVAL_EXCEPTION));
24592466 finish_expr_stmt (r);
2460- build_contract_handler_call (violation, semantic == CCS_NOEXCEPT_ENFORCE);
2467+ bool noexcept_wrap = (semantic == CCS_NOEXCEPT_ENFORCE)
2468+ || (semantic == CCS_NOEXCEPT_OBSERVE);
2469+ build_contract_handler_call (violation, noexcept_wrap);
24612470 /* Note we had an exception. */
24622471 finish_expr_stmt (cp_build_init_expr (excp_, boolean_true_node));
24632472 }
@@ -2476,7 +2485,8 @@ build_contract_check (tree contract)
24762485 finish_if_stmt_cond (cond, if_not_cond);
24772486
24782487 if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2479- || semantic == CCS_NOEXCEPT_ENFORCE)
2488+ || semantic == CCS_NOEXCEPT_ENFORCE
2489+ || semantic == CCS_NOEXCEPT_OBSERVE)
24802490 {
24812491 tree if_not_excp = begin_if_stmt ();
24822492 cond = build_x_unary_op (loc, TRUTH_NOT_EXPR, excp_, NULL_TREE,
0 commit comments