Skip to content

Commit ac60314

Browse files
jensmaurerzygoloid
authored andcommitted
[dcl.attr.contract] Rephrase comments in examples
1 parent 19d07de commit ac60314

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

source/declarations.tex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4366,13 +4366,13 @@
43664366
class X {
43674367
public:
43684368
int v() const;
4369-
void f() [[expects: x > 0]]; // Ill-formed
4369+
void f() [[expects: x > 0]]; // error: \tcode{x} is private
43704370
void g() [[expects: v() > 0]]; // OK
43714371
friend void r(int z) [[expects: z > 0]]; // OK
4372-
friend void s(int z) [[expects: z > x]]; // Ill-formed
4372+
friend void s(int z) [[expects: z > x]]; // error: \tcode{x} is private
43734373
protected:
43744374
int w();
4375-
void h() [[expects: x > 0]]; // Ill-formed
4375+
void h() [[expects: x > 0]]; // error: \tcode{x} is private
43764376
void i() [[ensures: y > 0]]; // OK
43774377
void j() [[ensures: w() > 0]]; // OK
43784378
int y;
@@ -4384,7 +4384,7 @@
43844384
class Y : public X {
43854385
public:
43864386
void a() [[expects: v() > 0]]; // OK
4387-
void b() [[ensures: w() > 0]]; // Ill-formed
4387+
void b() [[ensures: w() > 0]]; // error: \tcode{w} is protected
43884388
protected:
43894389
void c() [[expects: w() > 0]]; // OK
43904390
};
@@ -4627,7 +4627,7 @@
46274627
int g(int * p)
46284628
[[ensures r: p != nullptr]]
46294629
{
4630-
*p = 42; // OK, p is not modified
4630+
*p = 42; // OK, \tcode{p} is not modified
46314631
}
46324632

46334633
int h(int x)
@@ -4644,7 +4644,7 @@
46444644
A function pointer cannot include contract conditions.
46454645
\begin{example}
46464646
\begin{codeblock}
4647-
typedef int (*fpt)() [[ensures r: r != 0]]; // Ill-formed
4647+
typedef int (*fpt)() [[ensures r: r != 0]]; // error: contract condition not on a function declaration
46484648

46494649
int g(int x)
46504650
[[expects: x >= 0]]
@@ -4653,8 +4653,8 @@
46534653
return x+1;
46544654
}
46554655

4656-
int (*pf)(int) = g; // OK
4657-
int x = pf(5); // contract conditions of g are checked
4656+
int (*pf)(int) = g; // OK
4657+
int x = pf(5); // contract conditions of \tcode{g} are checked
46584658
\end{codeblock}
46594659
\end{example}
46604660
\end{note}
@@ -4693,7 +4693,7 @@
46934693
}
46944694

46954695
struct C : A, B {
4696-
virtual void g(); // Ill-formed, no diagnostic required
4696+
virtual void g(); // ill-formed, no diagnostic required
46974697
};
46984698
\end{codeblock}
46994699
\end{example}

0 commit comments

Comments
 (0)