@@ -2171,6 +2171,8 @@ get_evaluation_semantic(tree contract)
2171
2171
return CES_QUICK;
2172
2172
case CCS_NOEXCEPT_ENFORCE:
2173
2173
return CES_NOEXCEPT_ENFORCE;
2174
+ case CCS_NOEXCEPT_OBSERVE:
2175
+ return CES_NOEXCEPT_OBSERVE;
2174
2176
}
2175
2177
}
2176
2178
@@ -2375,12 +2377,14 @@ build_contract_check (tree contract)
2375
2377
finish_if_stmt_cond (cond, if_stmt);
2376
2378
/* Using the P2900 names here c++2a ENFORCE=NEVER, OBSERVE=MAYBE. */
2377
2379
if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2378
- || semantic == CCS_NOEXCEPT_ENFORCE)
2380
+ || semantic == CCS_NOEXCEPT_ENFORCE
2381
+ || semantic == CCS_NOEXCEPT_OBSERVE)
2379
2382
{
2380
2383
tree violation = build_contract_violation (contract,
2381
2384
/* 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);
2384
2388
}
2385
2389
2386
2390
if (semantic == CCS_QUICK)
@@ -2417,7 +2421,8 @@ build_contract_check (tree contract)
2417
2421
violation object or handler. */
2418
2422
tree excp_ = NULL_TREE;
2419
2423
if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2420
- || semantic ==CCS_NOEXCEPT_ENFORCE)
2424
+ || semantic ==CCS_NOEXCEPT_ENFORCE
2425
+ || semantic == CCS_NOEXCEPT_OBSERVE)
2421
2426
{
2422
2427
excp_ = build_decl (loc, VAR_DECL, NULL , boolean_type_node);
2423
2428
/* compiler-generated. */
@@ -2433,7 +2438,8 @@ build_contract_check (tree contract)
2433
2438
2434
2439
tree violation = NULL_TREE;
2435
2440
if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2436
- || semantic == CCS_NOEXCEPT_ENFORCE)
2441
+ || semantic == CCS_NOEXCEPT_ENFORCE
2442
+ || semantic == CCS_NOEXCEPT_OBSERVE)
2437
2443
violation = build_contract_violation (contract, /* is_const*/ false );
2438
2444
2439
2445
/* Wrap the contract check in a try-catch. */
@@ -2446,7 +2452,8 @@ build_contract_check (tree contract)
2446
2452
tree handler = begin_handler ();
2447
2453
finish_handler_parms (NULL_TREE, handler); /* catch (...) */
2448
2454
if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2449
- || semantic == CCS_NOEXCEPT_ENFORCE)
2455
+ || semantic == CCS_NOEXCEPT_ENFORCE
2456
+ || semantic == CCS_NOEXCEPT_OBSERVE)
2450
2457
{
2451
2458
/* Update the violation object type. */
2452
2459
tree v_type = get_pseudo_contract_violation_type ();
@@ -2457,7 +2464,9 @@ build_contract_check (tree contract)
2457
2464
r = cp_build_init_expr (r, build_int_cst (integer_type_node,
2458
2465
CDM_EVAL_EXCEPTION));
2459
2466
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);
2461
2470
/* Note we had an exception. */
2462
2471
finish_expr_stmt (cp_build_init_expr (excp_, boolean_true_node));
2463
2472
}
@@ -2476,7 +2485,8 @@ build_contract_check (tree contract)
2476
2485
finish_if_stmt_cond (cond, if_not_cond);
2477
2486
2478
2487
if (semantic == CCS_ENFORCE || semantic == CCS_OBSERVE
2479
- || semantic == CCS_NOEXCEPT_ENFORCE)
2488
+ || semantic == CCS_NOEXCEPT_ENFORCE
2489
+ || semantic == CCS_NOEXCEPT_OBSERVE)
2480
2490
{
2481
2491
tree if_not_excp = begin_if_stmt ();
2482
2492
cond = build_x_unary_op (loc, TRUTH_NOT_EXPR, excp_, NULL_TREE,
0 commit comments