Commit c90e198
committed
Fix parsing of enum-base to follow C++11 rules.
Previously we implemented non-standard disambiguation rules to
distinguish an enum-base from a bit-field but otherwise treated a :
after an elaborated-enum-specifier as introducing an enum-base. That
misparses various examples (anywhere an elaborated-type-specifier can
appear followed by a colon, such as within a ternary operator or
_Generic).
We now implement the C++11 rules, with the old cases accepted as
extensions where that seemed reasonable. These amount to:
* an enum-base must always be accompanied by an enum definition (except
in a standalone declaration of the form 'enum E : T;')
* in a member-declaration, 'enum E :' always introduces an enum-base,
never a bit-field
* in a type-specifier (or similar context), 'enum E :' is not
permitted; the colon means whatever else it would mean in that
context.
Fixed underlying types for enums are also permitted in Objective-C and
under MS extensions, plus as a language extension in all other modes.
The behavior in ObjC and MS extensions modes is unchanged (but the
bit-field disambiguation is a bit better); remaining language modes
follow the C++11 rules.
Fixes PR45726, PR39979, PR19810, PR44941, and most of PR24297, plus C++
core issues 1514 and 1966.1 parent 49b32d8 commit c90e198
File tree
18 files changed
+298
-224
lines changed- clang
- include/clang
- Basic
- Parse
- lib
- Parse
- Sema
- test
- CXX
- drs
- expr/expr.prim/expr.prim.general
- Parser
- SemaCXX
- SemaObjC
- www
18 files changed
+298
-224
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
108 | 116 | | |
109 | 117 | | |
110 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5484 | 5484 | | |
5485 | 5485 | | |
5486 | 5486 | | |
| 5487 | + | |
| 5488 | + | |
5487 | 5489 | | |
5488 | 5490 | | |
5489 | 5491 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2181 | 2181 | | |
2182 | 2182 | | |
2183 | 2183 | | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
2184 | 2246 | | |
2185 | 2247 | | |
2186 | 2248 | | |
| |||
2408 | 2470 | | |
2409 | 2471 | | |
2410 | 2472 | | |
2411 | | - | |
2412 | | - | |
2413 | | - | |
| 2473 | + | |
2414 | 2474 | | |
2415 | | - | |
2416 | | - | |
| 2475 | + | |
| 2476 | + | |
2417 | 2477 | | |
2418 | | - | |
2419 | | - | |
2420 | | - | |
2421 | | - | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
2422 | 2481 | | |
2423 | 2482 | | |
2424 | 2483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4443 | 4443 | | |
4444 | 4444 | | |
4445 | 4445 | | |
4446 | | - | |
4447 | | - | |
| 4446 | + | |
| 4447 | + | |
| 4448 | + | |
| 4449 | + | |
| 4450 | + | |
| 4451 | + | |
| 4452 | + | |
| 4453 | + | |
| 4454 | + | |
4448 | 4455 | | |
4449 | 4456 | | |
4450 | 4457 | | |
4451 | | - | |
4452 | | - | |
4453 | | - | |
| 4458 | + | |
| 4459 | + | |
4454 | 4460 | | |
4455 | 4461 | | |
4456 | 4462 | | |
| |||
4471 | 4477 | | |
4472 | 4478 | | |
4473 | 4479 | | |
4474 | | - | |
| 4480 | + | |
4475 | 4481 | | |
4476 | | - | |
| 4482 | + | |
4477 | 4483 | | |
4478 | 4484 | | |
4479 | 4485 | | |
| |||
4503 | 4509 | | |
4504 | 4510 | | |
4505 | 4511 | | |
| 4512 | + | |
4506 | 4513 | | |
4507 | | - | |
4508 | 4514 | | |
4509 | | - | |
4510 | | - | |
4511 | | - | |
4512 | | - | |
4513 | | - | |
4514 | | - | |
4515 | | - | |
4516 | | - | |
4517 | | - | |
4518 | | - | |
4519 | | - | |
4520 | | - | |
4521 | | - | |
4522 | | - | |
4523 | | - | |
4524 | | - | |
4525 | | - | |
4526 | | - | |
4527 | | - | |
4528 | | - | |
4529 | | - | |
4530 | | - | |
4531 | | - | |
4532 | | - | |
4533 | | - | |
4534 | | - | |
4535 | | - | |
4536 | | - | |
4537 | | - | |
4538 | | - | |
4539 | | - | |
4540 | | - | |
4541 | | - | |
4542 | 4515 | | |
4543 | | - | |
4544 | | - | |
4545 | | - | |
4546 | | - | |
4547 | | - | |
4548 | | - | |
4549 | | - | |
4550 | | - | |
4551 | | - | |
4552 | | - | |
4553 | | - | |
4554 | | - | |
4555 | | - | |
4556 | | - | |
4557 | | - | |
4558 | | - | |
4559 | | - | |
4560 | | - | |
4561 | | - | |
4562 | | - | |
4563 | | - | |
4564 | | - | |
4565 | | - | |
4566 | | - | |
4567 | | - | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
| 4520 | + | |
| 4521 | + | |
| 4522 | + | |
| 4523 | + | |
| 4524 | + | |
| 4525 | + | |
| 4526 | + | |
| 4527 | + | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
| 4532 | + | |
| 4533 | + | |
| 4534 | + | |
| 4535 | + | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
4568 | 4553 | | |
4569 | 4554 | | |
4570 | 4555 | | |
4571 | | - | |
| 4556 | + | |
| 4557 | + | |
4572 | 4558 | | |
4573 | | - | |
| 4559 | + | |
| 4560 | + | |
4574 | 4561 | | |
4575 | | - | |
| 4562 | + | |
| 4563 | + | |
4576 | 4564 | | |
4577 | | - | |
| 4565 | + | |
| 4566 | + | |
4578 | 4567 | | |
4579 | 4568 | | |
4580 | 4569 | | |
| |||
4590 | 4579 | | |
4591 | 4580 | | |
4592 | 4581 | | |
4593 | | - | |
| 4582 | + | |
4594 | 4583 | | |
4595 | | - | |
| 4584 | + | |
4596 | 4585 | | |
4597 | 4586 | | |
4598 | 4587 | | |
| |||
4623 | 4612 | | |
4624 | 4613 | | |
4625 | 4614 | | |
| 4615 | + | |
| 4616 | + | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
4626 | 4624 | | |
4627 | 4625 | | |
4628 | 4626 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1283 | 1283 | | |
1284 | 1284 | | |
1285 | 1285 | | |
1286 | | - | |
| 1286 | + | |
| 1287 | + | |
1287 | 1288 | | |
1288 | 1289 | | |
1289 | 1290 | | |
| |||
1680 | 1681 | | |
1681 | 1682 | | |
1682 | 1683 | | |
1683 | | - | |
| 1684 | + | |
1684 | 1685 | | |
1685 | 1686 | | |
1686 | 1687 | | |
| |||
0 commit comments