Commit 751e630
committed
[clang] Allow class with anonymous union member to be const-default-constructible even if a union member has a default member initializer (#95854)
Resolves #95854
Clang incorrectly considers a class with an anonymous union member to not be
const-default-constructible even if a union member has a default member initializer.
This is valid as per ``8.3`` in `Draft C++ Standard <https://eel.is/c++draft/dcl.init#general-8.3>`_.
The ``allowConstDefaultInit`` member function in ``CXXRecordDecl`` needs
special-case unions to handle the rule. (#GH95854).
```
struct A {
union {
int n = 0;
int m;
};
};
const A a;
```
-- As per https://eel.is/c++draft/dcl.init#general-8.31 parent 00c622e commit 751e630
File tree
4 files changed
+37
-2
lines changed- clang
- docs
- include/clang/AST
- lib/AST
- test/SemaCXX
4 files changed
+37
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
756 | 756 | | |
757 | 757 | | |
758 | 758 | | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
759 | 765 | | |
760 | 766 | | |
761 | 767 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1392 | 1392 | | |
1393 | 1393 | | |
1394 | 1394 | | |
1395 | | - | |
| 1395 | + | |
| 1396 | + | |
1396 | 1397 | | |
1397 | 1398 | | |
1398 | 1399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
1021 | 1024 | | |
1022 | 1025 | | |
1023 | 1026 | | |
| |||
1086 | 1089 | | |
1087 | 1090 | | |
1088 | 1091 | | |
1089 | | - | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1090 | 1097 | | |
1091 | 1098 | | |
1092 | 1099 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments