|
950 | 950 | enum E : int { a };
|
951 | 951 | void f(int); // \#1
|
952 | 952 | void f(Int) {} // defines \#1
|
953 |
| -void f(E) {} // OK: another overload |
| 953 | +void f(E) {} // OK, another overload |
954 | 954 |
|
955 | 955 | struct X {
|
956 | 956 | static void f();
|
|
960 | 960 | void g() &; // error: redeclaration
|
961 | 961 |
|
962 | 962 | void h(this X&, int);
|
963 |
| - void h(int) &&; // OK: another overload |
| 963 | + void h(int) &&; // OK, another overload |
964 | 964 | void j(this const X&);
|
965 | 965 | void j() const&; // error: redeclaration
|
966 | 966 | void k();
|
|
993 | 993 | enum { f }; // error: different entity for \tcode{::f}
|
994 | 994 | namespace A {}
|
995 | 995 | namespace B = A;
|
996 |
| -namespace B = A; // OK: no effect |
997 |
| -namespace B = B; // OK: no effect |
998 |
| -namespace A = B; // OK: no effect |
| 996 | +namespace B = A; // OK, no effect |
| 997 | +namespace B = B; // OK, no effect |
| 998 | +namespace A = B; // OK, no effect |
999 | 999 | namespace B {} // error: different entity for \tcode{B}
|
1000 | 1000 | \end{codeblock}
|
1001 | 1001 | \end{example}
|
|
1452 | 1452 |
|
1453 | 1453 | \begin{codeblocktu}{Translation unit \#3}
|
1454 | 1454 | import R;
|
1455 |
| -int main() { return sq(9); } // OK: \tcode{sq} from module \tcode{Q} |
| 1455 | +int main() { return sq(9); } // OK, \tcode{sq} from module \tcode{Q} |
1456 | 1456 | \end{codeblocktu}
|
1457 | 1457 | \end{example}
|
1458 | 1458 | \end{note}
|
|
1616 | 1616 | struct D : B, C { };
|
1617 | 1617 |
|
1618 | 1618 | void f(D* pd) {
|
1619 |
| - pd->v++; // OK: only one \tcode{v} (virtual) |
1620 |
| - pd->s++; // OK: only one \tcode{s} (static) |
1621 |
| - int i = pd->e; // OK: only one \tcode{e} (enumerator) |
| 1619 | + pd->v++; // OK, only one \tcode{v} (virtual) |
| 1620 | + pd->s++; // OK, only one \tcode{s} (static) |
| 1621 | + int i = pd->e; // OK, only one \tcode{e} (enumerator) |
1622 | 1622 | pd->a++; // error: ambiguous: two \tcode{a}{s} in \tcode{D}
|
1623 | 1623 | }
|
1624 | 1624 | \end{codeblock}
|
|
1658 | 1658 | right-hand instance of \tcode{W} are not hidden at all.
|
1659 | 1659 | \begin{codeblock}
|
1660 | 1660 | void D::glorp() {
|
1661 |
| - x++; // OK: \tcode{B::x} hides \tcode{V::x} |
1662 |
| - f(); // OK: \tcode{B::f()} hides \tcode{V::f()} |
| 1661 | + x++; // OK, \tcode{B::x} hides \tcode{V::x} |
| 1662 | + f(); // OK, \tcode{B::f()} hides \tcode{V::f()} |
1663 | 1663 | y++; // error: \tcode{B::y} and \tcode{C}'s \tcode{W::y}
|
1664 | 1664 | g(); // error: \tcode{B::g()} and \tcode{C}'s \tcode{W::g()}
|
1665 | 1665 | }
|
|
1685 | 1685 | D d;
|
1686 | 1686 | B* pb = &d;
|
1687 | 1687 | A* pa = &d; // error: ambiguous: \tcode{C}'s \tcode{A} or \tcode{B}'s \tcode{A}?
|
1688 |
| - V* pv = &d; // OK: only one \tcode{V} subobject |
| 1688 | + V* pv = &d; // OK, only one \tcode{V} subobject |
1689 | 1689 | }
|
1690 | 1690 | \end{codeblock}
|
1691 | 1691 | \end{example}
|
|
1886 | 1886 |
|
1887 | 1887 | void g() {
|
1888 | 1888 | N::S s;
|
1889 |
| - f(s); // OK: calls \tcode{N::f} |
| 1889 | + f(s); // OK, calls \tcode{N::f} |
1890 | 1890 | (f)(s); // error: \tcode{N::f} not considered; parentheses prevent argument-dependent lookup
|
1891 | 1891 | }
|
1892 | 1892 | \end{codeblock}
|
|
1913 | 1913 | template <class T> int h(T);
|
1914 | 1914 | }
|
1915 | 1915 |
|
1916 |
| -int x = f<N::A>(N::A()); // OK: lookup of \tcode{f} finds nothing, \tcode{f} treated as template name |
1917 |
| -int y = g<N::A>(N::A()); // OK: lookup of \tcode{g} finds a function, \tcode{g} treated as template name |
| 1916 | +int x = f<N::A>(N::A()); // OK, lookup of \tcode{f} finds nothing, \tcode{f} treated as template name |
| 1917 | +int y = g<N::A>(N::A()); // OK, lookup of \tcode{g} finds a function, \tcode{g} treated as template name |
1918 | 1918 | int z = h<N::A>(N::A()); // error: \tcode{h<} does not begin a \grammarterm{template-id}
|
1919 | 1919 | \end{codeblock}
|
1920 | 1920 |
|
|
2086 | 2086 | NS::T parm;
|
2087 | 2087 | void g(NS::T, float);
|
2088 | 2088 | int main() {
|
2089 |
| - f(parm); // OK: calls \tcode{NS::f} |
| 2089 | + f(parm); // OK, calls \tcode{NS::f} |
2090 | 2090 | extern void g(NS::T, float);
|
2091 |
| - g(parm, 1); // OK: calls \tcode{g(NS::T, float)} |
| 2091 | + g(parm, 1); // OK, calls \tcode{g(NS::T, float)} |
2092 | 2092 | }
|
2093 | 2093 | \end{codeblock}
|
2094 | 2094 | \end{example}
|
|
2215 | 2215 | template<class T>
|
2216 | 2216 | void g(T *p) { // as instantiated for \tcode{g<A>}:
|
2217 | 2217 | p->X<0>::f(); // error: \tcode{A::X} not found in \tcode{((p->X) < 0) > ::f()}
|
2218 |
| - p->template X<0>::f(); // OK: \tcode{::X} found in definition context |
2219 |
| - p->B::f(); // OK: non-type \tcode{A::B} ignored |
| 2218 | + p->template X<0>::f(); // OK, \tcode{::X} found in definition context |
| 2219 | + p->B::f(); // OK, non-type \tcode{A::B} ignored |
2220 | 2220 | p->template C<0>::f(); // error: \tcode{A::C} is not a template
|
2221 | 2221 | p->template D<0>::f(); // error: \tcode{A::D<0>} is not a class type
|
2222 | 2222 | p->T::f(); // error: \tcode{A::T} is not a class type
|
|
2405 | 2405 |
|
2406 | 2406 | void f()
|
2407 | 2407 | {
|
2408 |
| - BC::a++; // OK: \tcode{S} is $\{ \tcode{A::a}, \tcode{A::a} \}$ |
| 2408 | + BC::a++; // OK, \tcode{S} is $\{ \tcode{A::a}, \tcode{A::a} \}$ |
2409 | 2409 | }
|
2410 | 2410 |
|
2411 | 2411 | namespace D {
|
|
2419 | 2419 |
|
2420 | 2420 | void g()
|
2421 | 2421 | {
|
2422 |
| - BD::a++; // OK: \tcode{S} is $\{ \tcode{A::a}, \tcode{A::a} \}$ |
| 2422 | + BD::a++; // OK, \tcode{S} is $\{ \tcode{A::a}, \tcode{A::a} \}$ |
2423 | 2423 | }
|
2424 | 2424 | \end{codeblock}
|
2425 | 2425 | \end{example}
|
|
2445 | 2445 |
|
2446 | 2446 | void f()
|
2447 | 2447 | {
|
2448 |
| - A::a++; // OK: \tcode{a} declared directly in \tcode{A}, \tcode{S} is $\{ \tcode{A::a} \}$ |
2449 |
| - B::a++; // OK: both \tcode{A} and \tcode{B} searched (once), \tcode{S} is $\{ \tcode{A::a} \}$ |
2450 |
| - A::b++; // OK: both \tcode{A} and \tcode{B} searched (once), \tcode{S} is $\{ \tcode{B::b} \}$ |
2451 |
| - B::b++; // OK: \tcode{b} declared directly in \tcode{B}, \tcode{S} is $\{ \tcode{B::b} \}$ |
| 2448 | + A::a++; // OK, \tcode{a} declared directly in \tcode{A}, \tcode{S} is $\{ \tcode{A::a} \}$ |
| 2449 | + B::a++; // OK, both \tcode{A} and \tcode{B} searched (once), \tcode{S} is $\{ \tcode{A::a} \}$ |
| 2450 | + A::b++; // OK, both \tcode{A} and \tcode{B} searched (once), \tcode{S} is $\{ \tcode{B::b} \}$ |
| 2451 | + B::b++; // OK, \tcode{b} declared directly in \tcode{B}, \tcode{S} is $\{ \tcode{B::b} \}$ |
2452 | 2452 | }
|
2453 | 2453 | \end{codeblock}
|
2454 | 2454 | \end{example}
|
|
2509 | 2509 | \begin{example}
|
2510 | 2510 | \begin{codeblock}
|
2511 | 2511 | struct Node {
|
2512 |
| - struct Node* Next; // OK: Refers to injected-class-name \tcode{Node} |
2513 |
| - struct Data* Data; // OK: Declares type \tcode{Data} at global scope and member \tcode{Data} |
| 2512 | + struct Node* Next; // OK, refers to injected-class-name \tcode{Node} |
| 2513 | + struct Data* Data; // OK, declares type \tcode{Data} at global scope and member \tcode{Data} |
2514 | 2514 | };
|
2515 | 2515 |
|
2516 | 2516 | struct Data {
|
2517 |
| - struct Node* Node; // OK: Refers to \tcode{Node} at global scope |
| 2517 | + struct Node* Node; // OK, refers to \tcode{Node} at global scope |
2518 | 2518 | friend struct ::Glob; // error: \tcode{Glob} is not declared, cannot introduce a qualified type\iref{dcl.type.elab}
|
2519 |
| - friend struct Glob; // OK: Refers to (as yet) undeclared \tcode{Glob} at global scope. |
| 2519 | + friend struct Glob; // OK, refers to (as yet) undeclared \tcode{Glob} at global scope. |
2520 | 2520 | @\commentellip@
|
2521 | 2521 | };
|
2522 | 2522 |
|
2523 | 2523 | struct Base {
|
2524 |
| - struct Data; // OK: Declares nested \tcode{Data} |
2525 |
| - struct ::Data* thatData; // OK: Refers to \tcode{::Data} |
2526 |
| - struct Base::Data* thisData; // OK: Refers to nested \tcode{Data} |
2527 |
| - friend class ::Data; // OK: global \tcode{Data} is a friend |
2528 |
| - friend class Data; // OK: nested \tcode{Data} is a friend |
| 2524 | + struct Data; // OK, declares nested \tcode{Data} |
| 2525 | + struct ::Data* thatData; // OK, refers to \tcode{::Data} |
| 2526 | + struct Base::Data* thisData; // OK, refers to nested \tcode{Data} |
| 2527 | + friend class ::Data; // OK, global \tcode{Data} is a friend |
| 2528 | + friend class Data; // OK, nested \tcode{Data} is a friend |
2529 | 2529 | struct Data { @\commentellip@ }; // Defines nested \tcode{Data}
|
2530 | 2530 | };
|
2531 | 2531 |
|
2532 |
| -struct Data; // OK: Redeclares \tcode{Data} at global scope |
| 2532 | +struct Data; // OK, redeclares \tcode{Data} at global scope |
2533 | 2533 | struct ::Data; // error: cannot introduce a qualified type\iref{dcl.type.elab}
|
2534 | 2534 | struct Base::Data; // error: cannot introduce a qualified type\iref{dcl.type.elab}
|
2535 | 2535 | struct Base::Datum; // error: \tcode{Datum} undefined
|
2536 |
| -struct Base::Data* pBase; // OK: refers to nested \tcode{Data} |
| 2536 | +struct Base::Data* pBase; // OK, refers to nested \tcode{Data} |
2537 | 2537 | \end{codeblock}
|
2538 | 2538 | \end{example}
|
2539 | 2539 | \indextext{lookup!elaborated type specifier|)}%
|
|
2739 | 2739 | module;
|
2740 | 2740 | #include "decls.h"
|
2741 | 2741 | export module M;
|
2742 |
| -export using ::f; // OK: does not declare an entity, exports \#1 |
| 2742 | +export using ::f; // OK, does not declare an entity, exports \#1 |
2743 | 2743 | int g(); // error: matches \#2, but attached to \tcode{M}
|
2744 | 2744 | export int h(); // \#3
|
2745 | 2745 | export int k(); // \#4
|
|
2799 | 2799 | \begin{codeblock}
|
2800 | 2800 | int f(int x, int x); // error: different entities for \tcode{x}
|
2801 | 2801 | void g(); // \#1
|
2802 |
| -void g(int); // OK: different entity from \#1 |
| 2802 | +void g(int); // OK, different entity from \#1 |
2803 | 2803 | int g(); // error: same entity as \#1 with different type
|
2804 | 2804 | void h(); // \#2
|
2805 | 2805 | namespace h {} // error: same entity as \#2, but not a function
|
|
3458 | 3458 | void* p = std::malloc(sizeof(D1) + sizeof(D2));
|
3459 | 3459 | B* pb = new (p) D1;
|
3460 | 3460 | pb->mutate();
|
3461 |
| - *pb; // OK: \tcode{pb} points to valid memory |
3462 |
| - void* q = pb; // OK: \tcode{pb} points to valid memory |
| 3461 | + *pb; // OK, \tcode{pb} points to valid memory |
| 3462 | + void* q = pb; // OK, \tcode{pb} points to valid memory |
3463 | 3463 | pb->f(); // undefined behavior: lifetime of \tcode{*pb} has ended
|
3464 | 3464 | }
|
3465 | 3465 | \end{codeblock}
|
|
4651 | 4651 | void foo() {
|
4652 | 4652 | xp++; // error: \tcode{X} is incomplete
|
4653 | 4653 | arrp++; // error: incomplete type
|
4654 |
| - arrpp++; // OK: sizeof \tcode{UNKA*} is known |
| 4654 | + arrpp++; // OK, sizeof \tcode{UNKA*} is known |
4655 | 4655 | }
|
4656 | 4656 |
|
4657 | 4657 | struct X { int i; }; // now \tcode{X} is a complete type
|
|
4661 | 4661 | void bar() {
|
4662 | 4662 | xp = &x; // OK; type is ``pointer to \tcode{X}''
|
4663 | 4663 | arrp = &arr; // OK; qualification conversion\iref{conv.qual}
|
4664 |
| - xp++; // OK: \tcode{X} is complete |
| 4664 | + xp++; // OK, \tcode{X} is complete |
4665 | 4665 | arrp++; // error: \tcode{UNKA} can't be completed
|
4666 | 4666 | }
|
4667 | 4667 | \end{codeblock}
|
|
0 commit comments