Skip to content

Commit 559872f

Browse files
joshuabernetkoeppe
authored andcommitted
P4451R2 Early Adoption of an Always-Enforced Label
1 parent 4938f0e commit 559872f

5 files changed

Lines changed: 52 additions & 9 deletions

File tree

‎source/basic.tex‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7820,6 +7820,28 @@
78207820
if a \grammarterm{result-name-introducer}\iref{dcl.contract.res} has been specified.
78217821
\end{note}
78227822

7823+
\rSec2[basic.contract.control]{Control}
7824+
7825+
\indextext{contract assertion!control}%
7826+
7827+
\begin{bnf}
7828+
\nontermdef{assertion-control-specifier}\br
7829+
\terminal{<} id-expression \terminal{>}
7830+
\end{bnf}
7831+
7832+
\pnum
7833+
The optional \grammarterm{assertion-control-specifier} of a
7834+
\grammarterm{precondition-specifier}, \grammarterm{postcondition-specifier},
7835+
or \grammarterm{assertion-statement} indicates that the
7836+
introduced contract assertion is a \defnadj{terminating}{contract assertion}.
7837+
7838+
\pnum
7839+
The \grammarterm{id-expression}
7840+
shall not be
7841+
type-dependent or value-dependent and
7842+
shall denote
7843+
\tcode{std::con\-tracts::con\-trols::enforced}\iref{contracts.syn}.
7844+
78237845
\rSec2[basic.contract.eval]{Evaluation}
78247846

78257847
\pnum
@@ -7839,7 +7861,11 @@
78397861
It is
78407862
\impldef{evaluation semantic used for the evaluation of a contract assertion}
78417863
which evaluation semantic is used
7842-
for any given evaluation of a contract assertion.
7864+
for any given evaluation of a contract assertion;
7865+
the evaluation semantic
7866+
used for the evaluation
7867+
of a terminating contract assertion
7868+
is a terminating semantic.
78437869
\begin{note}
78447870
The range and flexibility of available choices of
78457871
evaluation semantics depends on the implementation
@@ -7848,12 +7874,19 @@
78487874
for different evaluations of the same contract assertion,
78497875
including evaluations during constant evaluation.
78507876
\end{note}
7877+
\begin{note}
7878+
The notional evaluation of a contract assertion
7879+
to determine if a variable is constant-initializable
7880+
is always performed with the ignore evaluation semantic\iref{expr.const.init}.
7881+
\end{note}
78517882

78527883
\pnum
78537884
\recommended
78547885
An implementation should provide
78557886
the option to translate a program
7856-
such that all evaluations of contract assertions use the ignore semantic
7887+
such that all evaluations of contract assertions
7888+
that are not terminating contract assertions
7889+
use the ignore semantic
78577890
as well as
78587891
the option to translate a program
78597892
such that all evaluations of contract assertions use the enforce semantic.

‎source/declarations.tex‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4675,12 +4675,13 @@
46754675

46764676
\begin{bnf}
46774677
\nontermdef{precondition-specifier}\br
4678-
\keyword{pre} \opt{attribute-specifier-seq} \terminal{(} conditional-expression \terminal{)}
4678+
\keyword{pre} \opt{assertion-control-specifier} \opt{attribute-specifier-seq} \terminal{(} conditional-expression \terminal{)}
46794679
\end{bnf}
46804680

46814681
\begin{bnf}
46824682
\nontermdef{postcondition-specifier}\br
4683-
\keyword{post} \opt{attribute-specifier-seq} \terminal{(} \opt{result-name-introducer} conditional-expression \terminal{)}
4683+
\keyword{post} \opt{assertion-control-specifier} \opt{attribute-specifier-seq} \br
4684+
\bnfindent \terminal{(} \opt{result-name-introducer} conditional-expression \terminal{)}
46844685
\end{bnf}
46854686

46864687
\pnum
@@ -4761,6 +4762,10 @@
47614762
if
47624763
\begin{itemize}
47634764
\item
4765+
both $C_1$ and $C_2$
4766+
have \grammarterm{assertion-control-specifier}s
4767+
or neither does,
4768+
\item
47644769
their predicates $P_1$ and $P_2$ would
47654770
satisfy the one-definition rule\iref{basic.def.odr}
47664771
if placed in function definitions on

‎source/preprocessor.tex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2421,7 +2421,7 @@
24212421
\defnxname{cpp_constexpr_in_decltype} & \tcode{201711L} \\ \rowsep
24222422
\defnxname{cpp_constexpr_virtual_inheritance} & \tcode{202506L} \\ \rowsep
24232423
\defnxname{cpp_constinit} & \tcode{201907L} \\ \rowsep
2424-
\defnxname{cpp_contracts} & \tcode{202606L} \\ \rowsep
2424+
\defnxname{cpp_contracts} & \tcode{202611L} \\ \rowsep
24252425
\defnxname{cpp_decltype} & \tcode{200707L} \\ \rowsep
24262426
\defnxname{cpp_decltype_auto} & \tcode{201304L} \\ \rowsep
24272427
\defnxname{cpp_deduction_guides} & \tcode{202207L} \\ \rowsep

‎source/statements.tex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@
12401240

12411241
\begin{bnf}
12421242
\nontermdef{assertion-statement}\br
1243-
\terminal{contract_assert} \opt{attribute-specifier-seq} \terminal{(} conditional-expression \terminal{)} \terminal{;}
1243+
\terminal{contract_assert} \opt{assertion-control-specifier} \opt{attribute-specifier-seq} \terminal{(} conditional-expression \terminal{)} \terminal{;}
12441244
\end{bnf}
12451245

12461246
\pnum

‎source/support.tex‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@
613613
#define @\defnlibxname{cpp_lib_containers_ranges}@ 202202L
614614
// also in \libheader{vector}, \libheader{list}, \libheader{forward_list}, \libheader{map}, \libheader{set}, \libheader{unordered_map}, \libheader{unordered_set},
615615
// \libheader{deque}, \libheader{queue}, \libheader{stack}, \libheader{string}
616-
#define @\defnlibxname{cpp_lib_contracts}@ 202502L // freestanding, also in \libheader{contracts}
616+
#define @\defnlibxname{cpp_lib_contracts}@ 202611L // freestanding, also in \libheader{contracts}
617617
#define @\defnlibxname{cpp_lib_copyable_function}@ 202306L // also in \libheader{functional}
618618
#define @\defnlibxname{cpp_lib_coroutine}@ 201902L // freestanding, also in \libheader{coroutine}
619619
#define @\defnlibxname{cpp_lib_counting_scope}@ 202506L // also in \libheader{execution}
@@ -4287,8 +4287,9 @@
42874287
\rSec2[contracts.syn]{Header \tcode{<contracts>} synopsis}
42884288

42894289
\pnum
4290-
The header \libheader{contracts} defines types
4291-
for reporting information about contract violations\iref{basic.contract.eval}.
4290+
The header \libheader{contracts} provides facilities
4291+
for reporting information about contract violations\iref{basic.contract.eval}
4292+
and controlling the behavior of contract assertions\iref{basic.contract.control}.
42924293

42934294
\indexheader{contracts}
42944295
\indexlibraryglobal{contract_violation}%
@@ -4331,6 +4332,10 @@
43314332
};
43324333

43334334
void invoke_default_contract_violation_handler(const contract_violation&);
4335+
4336+
namespace controls {
4337+
inline constexpr @\unspec@ enforced = @\unspec@;
4338+
}
43344339
}
43354340
\end{codeblock}
43364341

0 commit comments

Comments
 (0)