|
60 | 60 | *
|
61 | 61 | * WG14 DR459: yes
|
62 | 62 | * atomic_load missing const qualifier
|
| 63 | + * |
| 64 | + * WG14 DR475: yes |
| 65 | + * Misleading Atomic library references to atomic types |
| 66 | + * |
| 67 | + * WG14 DR485: yes |
| 68 | + * Problem with the specification of ATOMIC_VAR_INIT |
| 69 | + * |
| 70 | + * WG14 DR486: yes |
| 71 | + * Inconsistent specification for arithmetic on atomic objects |
| 72 | + * |
| 73 | + * WG14 DR490: yes |
| 74 | + * Unwritten Assumptions About if-then |
63 | 75 | */
|
64 | 76 |
|
65 | 77 | /* WG14 DR412: yes
|
@@ -201,13 +213,112 @@ void dr463(void) {
|
201 | 213 | (void)(1 << ((__CHAR_BIT__ * sizeof(int)) - 1));
|
202 | 214 | }
|
203 | 215 |
|
204 |
| -/* WG14 DR464: yes |
205 |
| - * Clarifying the Behavior of the #line Directive |
| 216 | +/* WG14 DR478: yes |
| 217 | + * Valid uses of the main function |
| 218 | + */ |
| 219 | +int main(void) { |
| 220 | + /* This DR clarifies that C explicitly allows you to call main() in a hosted |
| 221 | + * environment; it is not special as it is in C++, so recursive calls are |
| 222 | + * fine as well as nonrecursive direct calls. |
| 223 | + */ |
| 224 | + main(); /* ok */ |
| 225 | +} |
| 226 | + |
| 227 | +void dr478(void) { |
| 228 | + int (*fp)(void) = main; /* ok */ |
| 229 | + main(); /* ok */ |
| 230 | +} |
| 231 | + |
| 232 | +/* WG14 DR481: yes |
| 233 | + * Controlling expression of _Generic primary expression |
| 234 | + */ |
| 235 | +void dr481(void) { |
| 236 | + /* The controlling expression undergoes lvalue to rvalue conversion, and that |
| 237 | + * performs array decay and strips qualifiers. |
| 238 | + */ |
| 239 | + (void)_Generic("bla", char *: "blu"); |
| 240 | + (void)_Generic((int const){ 0 }, int: "blu"); /* c89only-warning {{compound literals are a C99-specific feature}} */ |
| 241 | + (void)_Generic(+(int const){ 0 }, int: "blu"); /* c89only-warning {{compound literals are a C99-specific feature}} */ |
| 242 | + |
| 243 | + (void)_Generic("bla", /* expected-error {{controlling expression type 'char *' not compatible with any generic association type}} */ |
| 244 | + char[4]: "blu"); /* expected-warning {{due to lvalue conversion of the controlling expression, association of type 'char[4]' will never be selected because it is of array type}} */ |
| 245 | + |
| 246 | + (void)_Generic((int const){ 0 }, /* expected-error {{controlling expression type 'int' not compatible with any generic association type}} |
| 247 | + c89only-warning {{compound literals are a C99-specific feature}} |
| 248 | + */ |
| 249 | + int const: "blu"); /* expected-warning {{due to lvalue conversion of the controlling expression, association of type 'const int' will never be selected because it is qualified}} */ |
| 250 | + |
| 251 | + (void)_Generic(+(int const){ 0 }, /* expected-error {{controlling expression type 'int' not compatible with any generic association type}} |
| 252 | + c89only-warning {{compound literals are a C99-specific feature}} |
| 253 | + */ |
| 254 | + int const: "blu"); /* expected-warning {{due to lvalue conversion of the controlling expression, association of type 'const int' will never be selected because it is qualified}} */ |
| 255 | +} |
| 256 | + |
| 257 | +/* WG14 DR489: partial |
| 258 | + * Integer Constant Expression |
206 | 259 | *
|
207 |
| - * Note: the behavior described by this DR allows for two different |
208 |
| - * interpretations, but WG14 N2322 (adopted for C2x) adds a recommended |
209 |
| - * practice which is what we're testing our interpretation against. |
| 260 | + * The DR is about whether unevaluated operands have to follow the same |
| 261 | + * restrictions as the rest of the expression in an ICE, and according to the |
| 262 | + * committee, they do. |
| 263 | + */ |
| 264 | +void dr489(void) { |
| 265 | + struct S { |
| 266 | + int bit : 12 || 1.0f; /* expected-warning {{expression is not an integer constant expression; folding it to a constant is a GNU extension}} */ |
| 267 | + }; |
| 268 | + enum E { |
| 269 | + Val = 0 && 1.0f /* expected-warning {{expression is not an integer constant expression; folding it to a constant is a GNU extension}} */ |
| 270 | + }; |
| 271 | + |
| 272 | + int i; |
| 273 | + |
| 274 | + /* FIXME: mentioning the 'aligned' attribute is confusing, but also, should |
| 275 | + * this be folded as an ICE as a GNU extension? GCC does not fold it. |
| 276 | + */ |
| 277 | + _Alignas(0 ? i++ : 8) char c; /* expected-error {{'aligned' attribute requires integer constant}} */ |
| 278 | + |
| 279 | + /* FIXME: this should get the constant folding diagnostic as this is not a |
| 280 | + * valid ICE because the floating-point constants are not the immediate |
| 281 | + * operand of a cast. It should then also get a diagnostic about trying to |
| 282 | + * declare a VLA with static storage duration and the C99 extension warning |
| 283 | + * for VLAs in C89. |
| 284 | + */ |
| 285 | + static int vla[sizeof(1.0f + 1.0f)]; |
| 286 | + |
| 287 | + int val[5] = { [1 ? 0 : i--] = 12 }; /* expected-warning {{expression is not an integer constant expression; folding it to a constant is a GNU extension}} |
| 288 | + c89only-warning {{designated initializers are a C99 feature}} |
| 289 | + */ |
| 290 | + |
| 291 | + /* FIXME: this should be the constant folding diagnostic as this is not a |
| 292 | + * valid ICE because of the / operator. |
| 293 | + */ |
| 294 | + _Static_assert(sizeof(0 / 0), ""); |
| 295 | + |
| 296 | + /* FIXME: this should also get the constant folding diagnostic as this is not |
| 297 | + * a valid ICE because of the = operator. |
| 298 | + */ |
| 299 | + (void)_Generic(i = 12, int : 0); /* expected-warning {{expression with side effects has no effect in an unevaluated context}} */ |
| 300 | + |
| 301 | + switch (i) { |
| 302 | + case (int)0.0f: break; /* okay, a valid ICE */ |
| 303 | + |
| 304 | + /* FIXME: this should be accepted in C2x and up without a diagnostic, as C23 |
| 305 | + * added compound literals to the allowed list of things in an ICE. The |
| 306 | + * diagnostic is correct for C17 and earlier though. |
| 307 | + */ |
| 308 | + case (int){ 2 }: break; /* expected-warning {{expression is not an integer constant expression; folding it to a constant is a GNU extension}} |
| 309 | + c89only-warning {{compound literals are a C99-specific feature}} |
| 310 | + */ |
| 311 | + case 12 || main(): break; /* expected-warning {{expression is not an integer constant expression; folding it to a constant is a GNU extension}} */ |
| 312 | + } |
| 313 | +} |
| 314 | + |
| 315 | +/* WG14 DR492: yes |
| 316 | + * Named Child struct-union with no Member |
210 | 317 | */
|
211 |
| -#line 10000 |
212 |
| -_Static_assert(__LI\ |
213 |
| -NE__ == 10000, ""); |
| 318 | +struct dr492_t { |
| 319 | + union U11 { /* expected-warning {{declaration does not declare anything}} */ |
| 320 | + int m11; |
| 321 | + float m12; |
| 322 | + }; |
| 323 | + int m13; |
| 324 | +} dr492; |
0 commit comments