Skip to content

Commit 3b66c50

Browse files
committed
c++, contracts: Add support for a contract scope.
This allows us to associate a scope with contract checks which is necessary to disambiguate cases where lambdas are permitted to have captures. Signed-off-by: Iain Sandoe <[email protected]>
1 parent c6f0494 commit 3b66c50

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

gcc/cp/name-lookup.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4630,7 +4630,8 @@ cp_binding_level_descriptor (cp_binding_level *scope)
46304630
"template-parameter-scope",
46314631
"template-explicit-spec-scope",
46324632
"transaction-scope",
4633-
"openmp-scope"
4633+
"openmp-scope",
4634+
"contract-check-scope"
46344635
};
46354636
static_assert (ARRAY_SIZE (scope_kind_names) == sk_count,
46364637
"must keep names aligned with scope_kind enum");
@@ -4720,6 +4721,7 @@ begin_scope (scope_kind kind, tree entity)
47204721
case sk_scoped_enum:
47214722
case sk_transaction:
47224723
case sk_omp:
4724+
case sk_contract:
47234725
case sk_stmt_expr:
47244726
scope->keep = keep_next_level_flag;
47254727
break;

gcc/cp/name-lookup.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ enum scope_kind {
214214
"template <>", this scope is always empty. */
215215
sk_transaction, /* A synchronized or atomic statement. */
216216
sk_omp, /* An OpenMP structured block. */
217+
sk_contract, /* A P2900 contract. */
217218
sk_count /* Number of scope_kind enumerations. */
218219
};
219220

@@ -287,7 +288,7 @@ struct GTY(()) cp_binding_level {
287288
/* The kind of scope that this object represents. However, a
288289
SK_TEMPLATE_SPEC scope is represented with KIND set to
289290
SK_TEMPLATE_PARMS and EXPLICIT_SPEC_P set to true. */
290-
ENUM_BITFIELD (scope_kind) kind : 4;
291+
ENUM_BITFIELD (scope_kind) kind : 5;
291292

292293
/* True if this scope is an SK_TEMPLATE_SPEC scope. This field is
293294
only valid if KIND == SK_TEMPLATE_PARMS. */
@@ -315,7 +316,7 @@ struct GTY(()) cp_binding_level {
315316
parent scope. */
316317
unsigned artificial : 1;
317318

318-
/* 21 bits left to fill a 32-bit word. */
319+
/* 20 bits left to fill a 32-bit word. */
319320
};
320321

321322
/* The binding level currently in effect. */

0 commit comments

Comments
 (0)