From Jason Turner

[dcl.stc]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpitr_upch/{from.md → to.md} +42 -39
tmp/tmpitr_upch/{from.md → to.md} RENAMED
@@ -2,69 +2,71 @@
2
 
3
  The storage class specifiers are
4
 
5
  ``` bnf
6
  storage-class-specifier:
7
- 'static'
8
- 'thread_local'
9
- 'extern'
10
- 'mutable'
11
  ```
12
 
13
  At most one *storage-class-specifier* shall appear in a given
14
  *decl-specifier-seq*, except that `thread_local` may appear with
15
  `static` or `extern`. If `thread_local` appears in any declaration of a
16
  variable it shall be present in all declarations of that entity. If a
17
  *storage-class-specifier* appears in a *decl-specifier-seq*, there can
18
  be no `typedef` specifier in the same *decl-specifier-seq* and the
19
  *init-declarator-list* or *member-declarator-list* of the declaration
20
  shall not be empty (except for an anonymous union declared in a named
21
- namespace or in the global namespace, which shall be declared `static` (
22
- [[class.union.anon]])). The *storage-class-specifier* applies to the
23
- name declared by each *init-declarator* in the list and not to any names
24
- declared by other specifiers. A *storage-class-specifier* other than
25
- `thread_local` shall not be specified in an explicit specialization (
26
- [[temp.expl.spec]]) or an explicit instantiation ([[temp.explicit]])
27
- directive.
28
 
29
- [*Note 1*: A variable declared without a *storage-class-specifier* at
 
 
 
 
30
  block scope or declared as a function parameter has automatic storage
31
- duration by default ([[basic.stc.auto]]). — *end note*]
32
 
33
  The `thread_local` specifier indicates that the named entity has thread
34
- storage duration ([[basic.stc.thread]]). It shall be applied only to
35
- the names of variables of namespace or block scope and to the names of
36
- static data members. When `thread_local` is applied to a variable of
 
37
  block scope the *storage-class-specifier* `static` is implied if no
38
  other *storage-class-specifier* appears in the *decl-specifier-seq*.
39
 
40
- The `static` specifier can be applied only to names of variables and
41
- functions and to anonymous unions ([[class.union.anon]]). There can be
42
- no `static` function declarations within a block, nor any `static`
43
- function parameters. A `static` specifier used in the declaration of a
44
- variable declares the variable to have static storage duration (
45
- [[basic.stc.static]]), unless accompanied by the `thread_local`
46
- specifier, which declares the variable to have thread storage duration (
47
- [[basic.stc.thread]]). A `static` specifier can be used in declarations
48
- of class members;  [[class.static]] describes its effect. For the
49
- linkage of a name declared with a `static` specifier, see 
50
- [[basic.link]].
 
51
 
52
- The `extern` specifier can be applied only to the names of variables and
53
- functions. The `extern` specifier cannot be used in the declaration of
54
- class members or function parameters. For the linkage of a name declared
55
- with an `extern` specifier, see  [[basic.link]].
56
 
57
- [*Note 2*: The `extern` keyword can also be used in
58
  *explicit-instantiation*s and *linkage-specification*s, but it is not a
59
  *storage-class-specifier* in such contexts. — *end note*]
60
 
61
  The linkages implied by successive declarations for a given entity shall
62
  agree. That is, within a given scope, each declaration declaring the
63
  same variable name or the same overloading of a function name shall
64
- imply the same linkage. Each function in a given set of overloaded
65
- functions can have a different linkage, however.
66
 
67
  [*Example 1*:
68
 
69
  ``` cpp
70
  static char* f(); // f() has internal linkage
@@ -121,24 +123,25 @@ void h() {
121
  ```
122
 
123
  — *end example*]
124
 
125
  The `mutable` specifier shall appear only in the declaration of a
126
- non-static data member ([[class.mem]]) whose type is neither
127
  const-qualified nor a reference type.
128
 
129
  [*Example 3*:
130
 
131
  ``` cpp
132
  class X {
133
  mutable const int* p; // OK
134
- mutable int* const q; // ill-formed
135
  };
136
  ```
137
 
138
  — *end example*]
139
 
140
- The `mutable` specifier on a class data member nullifies a `const`
141
- specifier applied to the containing class object and permits
142
  modification of the mutable class member even though the rest of the
143
- object is `const` ([[dcl.type.cv]]).
 
144
 
 
2
 
3
  The storage class specifiers are
4
 
5
  ``` bnf
6
  storage-class-specifier:
7
+ static
8
+ thread_local
9
+ extern
10
+ mutable
11
  ```
12
 
13
  At most one *storage-class-specifier* shall appear in a given
14
  *decl-specifier-seq*, except that `thread_local` may appear with
15
  `static` or `extern`. If `thread_local` appears in any declaration of a
16
  variable it shall be present in all declarations of that entity. If a
17
  *storage-class-specifier* appears in a *decl-specifier-seq*, there can
18
  be no `typedef` specifier in the same *decl-specifier-seq* and the
19
  *init-declarator-list* or *member-declarator-list* of the declaration
20
  shall not be empty (except for an anonymous union declared in a named
21
+ namespace or in the global namespace, which shall be declared `static`
22
+ [[class.union.anon]]). The *storage-class-specifier* applies to the name
23
+ declared by each *init-declarator* in the list and not to any names
24
+ declared by other specifiers.
 
 
 
25
 
26
+ [*Note 1*: See [[temp.expl.spec]] and [[temp.explicit]] for
27
+ restrictions in explicit specializations and explicit instantiations,
28
+ respectively. — *end note*]
29
+
30
+ [*Note 2*: A variable declared without a *storage-class-specifier* at
31
  block scope or declared as a function parameter has automatic storage
32
+ duration by default [[basic.stc.auto]]. — *end note*]
33
 
34
  The `thread_local` specifier indicates that the named entity has thread
35
+ storage duration [[basic.stc.thread]]. It shall be applied only to the
36
+ declaration of a variable of namespace or block scope, to a structured
37
+ binding declaration [[dcl.struct.bind]], or to the declaration of a
38
+ static data member. When `thread_local` is applied to a variable of
39
  block scope the *storage-class-specifier* `static` is implied if no
40
  other *storage-class-specifier* appears in the *decl-specifier-seq*.
41
 
42
+ The `static` specifier shall be applied only to the declaration of a
43
+ variable or function, to a structured binding declaration
44
+ [[dcl.struct.bind]], or to the declaration of an anonymous union
45
+ [[class.union.anon]]. There can be no `static` function declarations
46
+ within a block, nor any `static` function parameters. A `static`
47
+ specifier used in the declaration of a variable declares the variable to
48
+ have static storage duration [[basic.stc.static]], unless accompanied by
49
+ the `thread_local` specifier, which declares the variable to have thread
50
+ storage duration [[basic.stc.thread]]. A `static` specifier can be used
51
+ in declarations of class members;  [[class.static]] describes its
52
+ effect. For the linkage of a name declared with a `static` specifier,
53
+ see  [[basic.link]].
54
 
55
+ The `extern` specifier shall be applied only to the declaration of a
56
+ variable or function. The `extern` specifier shall not be used in the
57
+ declaration of a class member or function parameter. For the linkage of
58
+ a name declared with an `extern` specifier, see  [[basic.link]].
59
 
60
+ [*Note 3*: The `extern` keyword can also be used in
61
  *explicit-instantiation*s and *linkage-specification*s, but it is not a
62
  *storage-class-specifier* in such contexts. — *end note*]
63
 
64
  The linkages implied by successive declarations for a given entity shall
65
  agree. That is, within a given scope, each declaration declaring the
66
  same variable name or the same overloading of a function name shall
67
+ imply the same linkage.
 
68
 
69
  [*Example 1*:
70
 
71
  ``` cpp
72
  static char* f(); // f() has internal linkage
 
123
  ```
124
 
125
  — *end example*]
126
 
127
  The `mutable` specifier shall appear only in the declaration of a
128
+ non-static data member [[class.mem]] whose type is neither
129
  const-qualified nor a reference type.
130
 
131
  [*Example 3*:
132
 
133
  ``` cpp
134
  class X {
135
  mutable const int* p; // OK
136
+ mutable int* const q; // error
137
  };
138
  ```
139
 
140
  — *end example*]
141
 
142
+ [*Note 4*: The `mutable` specifier on a class data member nullifies a
143
+ `const` specifier applied to the containing class object and permits
144
  modification of the mutable class member even though the rest of the
145
+ object is const ([[basic.type.qualifier]],
146
+ [[dcl.type.cv]]). — *end note*]
147