From Jason Turner

[cpp.cond]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptagp4fp8/{from.md → to.md} +21 -31
tmp/tmptagp4fp8/{from.md → to.md} RENAMED
@@ -34,12 +34,13 @@ has-attribute-expression:
34
  '__has_cpp_attribute (' pp-tokens ')'
35
  ```
36
 
37
  The expression that controls conditional inclusion shall be an integral
38
  constant expression except that identifiers (including those lexically
39
- identical to keywords) are interpreted as described below[^2] and it may
40
- contain zero or more *defined-macro-expression*s and/or
 
41
  *has-include-expression*s and/or *has-attribute-expression*s as unary
42
  operator expressions.
43
 
44
  A *defined-macro-expression* evaluates to `1` if the identifier is
45
  currently defined as a macro name (that is, if it is predefined or if it
@@ -78,10 +79,11 @@ detected by any non-zero result. — *end note*]
78
 
79
  **Table: __has_cpp_attribute values** <a id="cpp.cond.ha">[cpp.cond.ha]</a>
80
 
81
  | Attribute | Value |
82
  | -------------------- | --------- |
 
83
  | `carries_dependency` | `200809L` |
84
  | `deprecated` | `201309L` |
85
  | `fallthrough` | `201603L` |
86
  | `likely` | `201803L` |
87
  | `maybe_unused` | `201603L` |
@@ -89,15 +91,15 @@ detected by any non-zero result. — *end note*]
89
  | `nodiscard` | `201907L` |
90
  | `noreturn` | `200809L` |
91
  | `unlikely` | `201803L` |
92
 
93
 
94
- The `#ifdef` and `#ifndef` directives, and the `defined` conditional
95
- inclusion operator, shall treat `__has_include` and
96
- `__has_cpp_attribute` as if they were the names of defined macros. The
97
- identifiers `__has_include` and `__has_cpp_attribute` shall not appear
98
- in any context not mentioned in this subclause.
99
 
100
  Each preprocessing token that remains (in the list of preprocessing
101
  tokens that will become the controlling expression) after all macro
102
  replacements have occurred shall be in the lexical form of a token
103
  [[lex.token]].
@@ -133,53 +135,41 @@ Therefore it is not subject to this replacement. — *end note*]
133
  The resulting tokens comprise the controlling constant expression which
134
  is evaluated according to the rules of  [[expr.const]] using arithmetic
135
  that has at least the ranges specified in  [[support.limits]]. For the
136
  purposes of this token conversion and evaluation all signed and unsigned
137
  integer types act as if they have the same representation as,
138
- respectively, `intmax_t` or `uintmax_t` [[cstdint]].
139
 
140
  [*Note 3*: Thus on an implementation where
141
  `std::numeric_limits<int>::max()` is `0x7FFF` and
142
  `std::numeric_limits<unsigned int>::max()` is `0xFFFF`, the integer
143
  literal `0x8000` is signed and positive within a `#if` expression even
144
  though it is unsigned in translation phase 7
145
  [[lex.phases]]. — *end note*]
146
 
147
- This includes interpreting *character-literal*s, which may involve
148
- converting escape sequences into execution character set members.
149
- Whether the numeric value for these *character-literal*s matches the
150
- value obtained when an identical *character-literal* occurs in an
151
- expression (other than within a `#if` or `#elif` directive) is
152
- *implementation-defined*.
153
 
154
- [*Note 4*:
 
155
 
156
- Thus, the constant expression in the following `#if` directive and `if`
157
- statement [[stmt.if]] is not guaranteed to evaluate to the same value in
158
- these two contexts:
159
-
160
- ``` cpp
161
- #if 'z' - 'a' == 25
162
- if ('z' - 'a' == 25)
163
- ```
164
-
165
- — *end note*]
166
-
167
- Also, whether a single-character *character-literal* may have a negative
168
- value is *implementation-defined*. Each subexpression with type `bool`
169
- is subjected to integral promotion before processing continues.
170
 
171
  Preprocessing directives of the forms
172
 
173
  ``` bnf
174
  '# ifdef ' identifier new-line groupₒₚₜ
175
  '# ifndef ' identifier new-line groupₒₚₜ
 
 
176
  ```
177
 
178
  check whether the identifier is or is not currently defined as a macro
179
- name. Their conditions are equivalent to `#if` `defined` *identifier*
180
- and `#if` `!defined` *identifier* respectively.
 
181
 
182
  Each directive’s condition is checked in order. If it evaluates to false
183
  (zero), the group that it controls is skipped: directives are processed
184
  only through the name that determines the directive in order to keep
185
  track of the level of nested conditionals; the rest of the directives’
 
34
  '__has_cpp_attribute (' pp-tokens ')'
35
  ```
36
 
37
  The expression that controls conditional inclusion shall be an integral
38
  constant expression except that identifiers (including those lexically
39
+ identical to keywords) are interpreted as described below[^2]
40
+
41
+ and it may contain zero or more *defined-macro-expression*s and/or
42
  *has-include-expression*s and/or *has-attribute-expression*s as unary
43
  operator expressions.
44
 
45
  A *defined-macro-expression* evaluates to `1` if the identifier is
46
  currently defined as a macro name (that is, if it is predefined or if it
 
79
 
80
  **Table: __has_cpp_attribute values** <a id="cpp.cond.ha">[cpp.cond.ha]</a>
81
 
82
  | Attribute | Value |
83
  | -------------------- | --------- |
84
+ | `assume` | `202207L` |
85
  | `carries_dependency` | `200809L` |
86
  | `deprecated` | `201309L` |
87
  | `fallthrough` | `201603L` |
88
  | `likely` | `201803L` |
89
  | `maybe_unused` | `201603L` |
 
91
  | `nodiscard` | `201907L` |
92
  | `noreturn` | `200809L` |
93
  | `unlikely` | `201803L` |
94
 
95
 
96
+ The `#ifdef`, `#ifndef`, `#elifdef`, and `#elifndef` directives, and the
97
+ `defined` conditional inclusion operator, shall treat `__has_include`
98
+ and `__has_cpp_attribute` as if they were the names of defined macros.
99
+ The identifiers `__has_include` and `__has_cpp_attribute` shall not
100
+ appear in any context not mentioned in this subclause.
101
 
102
  Each preprocessing token that remains (in the list of preprocessing
103
  tokens that will become the controlling expression) after all macro
104
  replacements have occurred shall be in the lexical form of a token
105
  [[lex.token]].
 
135
  The resulting tokens comprise the controlling constant expression which
136
  is evaluated according to the rules of  [[expr.const]] using arithmetic
137
  that has at least the ranges specified in  [[support.limits]]. For the
138
  purposes of this token conversion and evaluation all signed and unsigned
139
  integer types act as if they have the same representation as,
140
+ respectively, `intmax_t` or `uintmax_t` [[cstdint.syn]].
141
 
142
  [*Note 3*: Thus on an implementation where
143
  `std::numeric_limits<int>::max()` is `0x7FFF` and
144
  `std::numeric_limits<unsigned int>::max()` is `0xFFFF`, the integer
145
  literal `0x8000` is signed and positive within a `#if` expression even
146
  though it is unsigned in translation phase 7
147
  [[lex.phases]]. — *end note*]
148
 
149
+ This includes interpreting *character-literal*s according to the rules
150
+ in [[lex.ccon]].
 
 
 
 
151
 
152
+ [*Note 4*: The associated character encodings of literals are the same
153
+ in `#if` and `#elif` directives and in any expression. — *end note*]
154
 
155
+ Each subexpression with type `bool` is subjected to integral promotion
156
+ before processing continues.
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  Preprocessing directives of the forms
159
 
160
  ``` bnf
161
  '# ifdef ' identifier new-line groupₒₚₜ
162
  '# ifndef ' identifier new-line groupₒₚₜ
163
+ '# elifdef ' identifier new-line groupₒₚₜ
164
+ '# elifndef' identifier new-line groupₒₚₜ
165
  ```
166
 
167
  check whether the identifier is or is not currently defined as a macro
168
+ name. Their conditions are equivalent to `#if` `defined` *identifier*,
169
+ `#if` `!defined` *identifier*, `#elif` `defined` *identifier*, and
170
+ `#elif` `!defined` *identifier*, respectively.
171
 
172
  Each directive’s condition is checked in order. If it evaluates to false
173
  (zero), the group that it controls is skipped: directives are processed
174
  only through the name that determines the directive in order to keep
175
  track of the level of nested conditionals; the rest of the directives’