From Jason Turner

[basic.lookup.elab]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp62ye_h1_/{from.md → to.md} +24 -44
tmp/tmp62ye_h1_/{from.md → to.md} RENAMED
@@ -1,69 +1,49 @@
1
  ### Elaborated type specifiers <a id="basic.lookup.elab">[[basic.lookup.elab]]</a>
2
 
3
- An *elaborated-type-specifier* [[dcl.type.elab]] may be used to refer to
4
- a previously declared *class-name* or *enum-name* even though the name
5
- has been hidden by a non-type declaration [[basic.scope.hiding]].
6
-
7
- If the *elaborated-type-specifier* has no *nested-name-specifier*, and
8
- unless the *elaborated-type-specifier* appears in a declaration with the
9
- following form:
10
-
11
- ``` bnf
12
- class-key attribute-specifier-seqₒₚₜ identifier ';'
13
- ```
14
-
15
- the *identifier* is looked up according to  [[basic.lookup.unqual]] but
16
- ignoring any non-type names that have been declared. If the
17
- *elaborated-type-specifier* is introduced by the `enum` keyword and this
18
- lookup does not find a previously declared *type-name*, the
19
- *elaborated-type-specifier* is ill-formed. If the
20
- *elaborated-type-specifier* is introduced by the *class-key* and this
21
- lookup does not find a previously declared *type-name*, or if the
22
- *elaborated-type-specifier* appears in a declaration with the form:
23
-
24
- ``` bnf
25
- class-key attribute-specifier-seqₒₚₜ identifier ';'
26
- ```
27
-
28
- the *elaborated-type-specifier* is a declaration that introduces the
29
- *class-name* as described in  [[basic.scope.pdecl]].
30
-
31
- If the *elaborated-type-specifier* has a *nested-name-specifier*,
32
- qualified name lookup is performed, as described in 
33
- [[basic.lookup.qual]], but ignoring any non-type names that have been
34
- declared. If the name lookup does not find a previously declared
35
- *type-name*, the *elaborated-type-specifier* is ill-formed.
36
 
37
  [*Example 1*:
38
 
39
  ``` cpp
40
  struct Node {
41
- struct Node* Next; // OK: Refers to injected-class-name Node
42
- struct Data* Data; // OK: Declares type Data at global scope and member Data
43
  };
44
 
45
  struct Data {
46
- struct Node* Node; // OK: Refers to Node at global scope
47
  friend struct ::Glob; // error: Glob is not declared, cannot introduce a qualified type[dcl.type.elab]
48
- friend struct Glob; // OK: Refers to (as yet) undeclared Glob at global scope.
49
  ...
50
  };
51
 
52
  struct Base {
53
- struct Data; // OK: Declares nested Data
54
- struct ::Data* thatData; // OK: Refers to ::Data
55
- struct Base::Data* thisData; // OK: Refers to nested Data
56
- friend class ::Data; // OK: global Data is a friend
57
- friend class Data; // OK: nested Data is a friend
58
  struct Data { ... }; // Defines nested Data
59
  };
60
 
61
- struct Data; // OK: Redeclares Data at global scope
62
  struct ::Data; // error: cannot introduce a qualified type[dcl.type.elab]
63
  struct Base::Data; // error: cannot introduce a qualified type[dcl.type.elab]
64
  struct Base::Datum; // error: Datum undefined
65
- struct Base::Data* pBase; // OK: refers to nested Data
66
  ```
67
 
68
  — *end example*]
69
 
 
1
  ### Elaborated type specifiers <a id="basic.lookup.elab">[[basic.lookup.elab]]</a>
2
 
3
+ If the *class-key* or `enum` keyword in an *elaborated-type-specifier*
4
+ is followed by an *identifier* that is not followed by `::`, lookup for
5
+ the *identifier* is type-only [[basic.lookup.general]].
6
+
7
+ [*Note 1*: In general, the recognition of an
8
+ *elaborated-type-specifier* depends on the following tokens. If the
9
+ *identifier* is followed by `::`, see
10
+ [[basic.lookup.qual]]. — *end note*]
11
+
12
+ If the terminal name of the *elaborated-type-specifier* is a qualified
13
+ name, lookup for it is type-only. If the name lookup does not find a
14
+ previously declared *type-name*, the *elaborated-type-specifier* is
15
+ ill-formed.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  [*Example 1*:
18
 
19
  ``` cpp
20
  struct Node {
21
+ struct Node* Next; // OK, refers to injected-class-name Node
22
+ struct Data* Data; // OK, declares type Data at global scope and member Data
23
  };
24
 
25
  struct Data {
26
+ struct Node* Node; // OK, refers to Node at global scope
27
  friend struct ::Glob; // error: Glob is not declared, cannot introduce a qualified type[dcl.type.elab]
28
+ friend struct Glob; // OK, refers to (as yet) undeclared Glob at global scope.
29
  ...
30
  };
31
 
32
  struct Base {
33
+ struct Data; // OK, declares nested Data
34
+ struct ::Data* thatData; // OK, refers to ::Data
35
+ struct Base::Data* thisData; // OK, refers to nested Data
36
+ friend class ::Data; // OK, global Data is a friend
37
+ friend class Data; // OK, nested Data is a friend
38
  struct Data { ... }; // Defines nested Data
39
  };
40
 
41
+ struct Data; // OK, redeclares Data at global scope
42
  struct ::Data; // error: cannot introduce a qualified type[dcl.type.elab]
43
  struct Base::Data; // error: cannot introduce a qualified type[dcl.type.elab]
44
  struct Base::Datum; // error: Datum undefined
45
+ struct Base::Data* pBase; // OK, refers to nested Data
46
  ```
47
 
48
  — *end example*]
49