From Jason Turner

[cpp.replace]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp8igky024/{from.md → to.md} +29 -17
tmp/tmp8igky024/{from.md → to.md} RENAMED
@@ -1,10 +1,12 @@
1
  ## Macro replacement <a id="cpp.replace">[[cpp.replace]]</a>
2
 
 
 
3
  Two replacement lists are identical if and only if the preprocessing
4
- tokens in both have the same number, ordering, spelling, and white-space
5
- separation, where all white-space separations are considered identical.
6
 
7
  An identifier currently defined as an object-like macro (see below) may
8
  be redefined by another `#define` preprocessing directive provided that
9
  the second definition is an object-like macro definition and the two
10
  replacement lists are identical, otherwise the program is ill-formed.
@@ -36,11 +38,11 @@ But the following redefinitions are invalid:
36
  #define FUNC_LIKE(b) ( b ) // different parameter spelling
37
  ```
38
 
39
  — *end example*]
40
 
41
- There shall be white-space between the identifier and the replacement
42
  list in the definition of an object-like macro.
43
 
44
  If the *identifier-list* in the macro definition does not end with an
45
  ellipsis, the number of arguments (including those arguments consisting
46
  of no preprocessing tokens) in an invocation of a function-like macro
@@ -55,28 +57,31 @@ notation in the parameters.
55
 
56
  A parameter identifier in a function-like macro shall be uniquely
57
  declared within its scope.
58
 
59
  The identifier immediately following the `define` is called the *macro
60
- name*. There is one name space for macro names. Any white-space
61
  characters preceding or following the replacement list of preprocessing
62
  tokens are not considered part of the replacement list for either form
63
  of macro.
64
 
65
  If a `#` preprocessing token, followed by an identifier, occurs
66
- lexically at the point at which a preprocessing directive could begin,
67
- the identifier is not subject to macro replacement.
68
 
69
  A preprocessing directive of the form
70
 
71
  ``` bnf
72
  '# define' identifier replacement-list new-line
73
  ```
74
 
75
  defines an *object-like macro* that causes each subsequent instance of
76
- the macro name[^5] to be replaced by the replacement list of
77
- preprocessing tokens that constitute the remainder of the directive.[^6]
 
 
 
78
  The replacement list is then rescanned for more macro names as specified
79
  below.
80
 
81
  [*Example 2*:
82
 
@@ -98,29 +103,29 @@ A preprocessing directive of the form
98
  '# define' identifier lparen identifier-list ', ...' ')' replacement-list new-line
99
  ```
100
 
101
  defines a *function-like macro* with parameters, whose use is similar
102
  syntactically to a function call. The parameters are specified by the
103
- optional list of identifiers, whose scope extends from their declaration
104
- in the identifier list until the new-line character that terminates the
105
- `#define` preprocessing directive. Each subsequent instance of the
106
  function-like macro name followed by a `(` as the next preprocessing
107
  token introduces the sequence of preprocessing tokens that is replaced
108
  by the replacement list in the definition (an invocation of the macro).
109
  The replaced sequence of preprocessing tokens is terminated by the
110
  matching `)` preprocessing token, skipping intervening matched pairs of
111
  left and right parenthesis preprocessing tokens. Within the sequence of
112
  preprocessing tokens making up an invocation of a function-like macro,
113
- new-line is considered a normal white-space character.
114
 
115
  The sequence of preprocessing tokens bounded by the outside-most
116
  matching parentheses forms the list of arguments for the function-like
117
  macro. The individual arguments within the list are separated by comma
118
  preprocessing tokens, but comma preprocessing tokens between matching
119
  inner parentheses do not separate arguments. If there are sequences of
120
  preprocessing tokens within the list of arguments that would otherwise
121
- act as preprocessing directives,[^7] the behavior is undefined.
 
 
122
 
123
  [*Example 3*:
124
 
125
  The following defines a function-like macro whose value is the maximum
126
  of its arguments. It has the disadvantages of evaluating one or the
@@ -216,11 +221,11 @@ would be ill-formed as the replacement list of the current function-like
216
  macro, the program is ill-formed. A *va-opt-replacement* is treated as
217
  if it were a parameter, and the preprocessing token sequence for the
218
  corresponding argument is defined as follows. If the substitution of
219
  `__VA_ARGS__` as neither an operand of `#` nor `##` consists of no
220
  preprocessing tokens, the argument consists of a single placemarker
221
- preprocessing token ([[cpp.concat]], [[cpp.rescan]]). Otherwise, the
222
  argument consists of the results of the expansion of the contained
223
  *pp-tokens* as the replacement list of the current function-like macro
224
  before removal of placemarker tokens, rescanning, and further
225
  replacement.
226
 
@@ -314,13 +319,20 @@ an argument) is deleted and the preceding preprocessing token is
314
  concatenated with the following preprocessing token. Placemarker
315
  preprocessing tokens are handled specially: concatenation of two
316
  placemarkers results in a single placemarker preprocessing token, and
317
  concatenation of a placemarker with a non-placemarker preprocessing
318
  token results in the non-placemarker preprocessing token. If the result
319
- is not a valid preprocessing token, the behavior is undefined. The
320
- resulting token is available for further macro replacement. The order of
321
- evaluation of `##` operators is unspecified.
 
 
 
 
 
 
 
322
 
323
  [*Example 1*:
324
 
325
  The sequence
326
 
 
1
  ## Macro replacement <a id="cpp.replace">[[cpp.replace]]</a>
2
 
3
+ ### General <a id="cpp.replace.general">[[cpp.replace.general]]</a>
4
+
5
  Two replacement lists are identical if and only if the preprocessing
6
+ tokens in both have the same number, ordering, spelling, and whitespace
7
+ separation, where all whitespace separations are considered identical.
8
 
9
  An identifier currently defined as an object-like macro (see below) may
10
  be redefined by another `#define` preprocessing directive provided that
11
  the second definition is an object-like macro definition and the two
12
  replacement lists are identical, otherwise the program is ill-formed.
 
38
  #define FUNC_LIKE(b) ( b ) // different parameter spelling
39
  ```
40
 
41
  — *end example*]
42
 
43
+ There shall be whitespace between the identifier and the replacement
44
  list in the definition of an object-like macro.
45
 
46
  If the *identifier-list* in the macro definition does not end with an
47
  ellipsis, the number of arguments (including those arguments consisting
48
  of no preprocessing tokens) in an invocation of a function-like macro
 
57
 
58
  A parameter identifier in a function-like macro shall be uniquely
59
  declared within its scope.
60
 
61
  The identifier immediately following the `define` is called the *macro
62
+ name*. There is one name space for macro names. Any whitespace
63
  characters preceding or following the replacement list of preprocessing
64
  tokens are not considered part of the replacement list for either form
65
  of macro.
66
 
67
  If a `#` preprocessing token, followed by an identifier, occurs
68
+ lexically at the point at which a preprocessing directive can begin, the
69
+ identifier is not subject to macro replacement.
70
 
71
  A preprocessing directive of the form
72
 
73
  ``` bnf
74
  '# define' identifier replacement-list new-line
75
  ```
76
 
77
  defines an *object-like macro* that causes each subsequent instance of
78
+ the macro name[^5]
79
+
80
+ to be replaced by the replacement list of preprocessing tokens that
81
+ constitute the remainder of the directive.[^6]
82
+
83
  The replacement list is then rescanned for more macro names as specified
84
  below.
85
 
86
  [*Example 2*:
87
 
 
103
  '# define' identifier lparen identifier-list ', ...' ')' replacement-list new-line
104
  ```
105
 
106
  defines a *function-like macro* with parameters, whose use is similar
107
  syntactically to a function call. The parameters are specified by the
108
+ optional list of identifiers. Each subsequent instance of the
 
 
109
  function-like macro name followed by a `(` as the next preprocessing
110
  token introduces the sequence of preprocessing tokens that is replaced
111
  by the replacement list in the definition (an invocation of the macro).
112
  The replaced sequence of preprocessing tokens is terminated by the
113
  matching `)` preprocessing token, skipping intervening matched pairs of
114
  left and right parenthesis preprocessing tokens. Within the sequence of
115
  preprocessing tokens making up an invocation of a function-like macro,
116
+ new-line is considered a normal whitespace character.
117
 
118
  The sequence of preprocessing tokens bounded by the outside-most
119
  matching parentheses forms the list of arguments for the function-like
120
  macro. The individual arguments within the list are separated by comma
121
  preprocessing tokens, but comma preprocessing tokens between matching
122
  inner parentheses do not separate arguments. If there are sequences of
123
  preprocessing tokens within the list of arguments that would otherwise
124
+ act as preprocessing directives,[^7]
125
+
126
+ the behavior is undefined.
127
 
128
  [*Example 3*:
129
 
130
  The following defines a function-like macro whose value is the maximum
131
  of its arguments. It has the disadvantages of evaluating one or the
 
221
  macro, the program is ill-formed. A *va-opt-replacement* is treated as
222
  if it were a parameter, and the preprocessing token sequence for the
223
  corresponding argument is defined as follows. If the substitution of
224
  `__VA_ARGS__` as neither an operand of `#` nor `##` consists of no
225
  preprocessing tokens, the argument consists of a single placemarker
226
+ preprocessing token [[cpp.concat]], [[cpp.rescan]]. Otherwise, the
227
  argument consists of the results of the expansion of the contained
228
  *pp-tokens* as the replacement list of the current function-like macro
229
  before removal of placemarker tokens, rescanning, and further
230
  replacement.
231
 
 
319
  concatenated with the following preprocessing token. Placemarker
320
  preprocessing tokens are handled specially: concatenation of two
321
  placemarkers results in a single placemarker preprocessing token, and
322
  concatenation of a placemarker with a non-placemarker preprocessing
323
  token results in the non-placemarker preprocessing token. If the result
324
+ begins with a sequence matching the syntax of
325
+ *universal-character-name*, the behavior is undefined.
326
+
327
+ [*Note 1*: This determination does not consider the replacement of
328
+ *universal-character-name*s in translation phase 3
329
+ [[lex.phases]]. — *end note*]
330
+
331
+ If the result is not a valid preprocessing token, the behavior is
332
+ undefined. The resulting token is available for further macro
333
+ replacement. The order of evaluation of `##` operators is unspecified.
334
 
335
  [*Example 1*:
336
 
337
  The sequence
338