Commit 7efe2bd
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 5c717d6 commit 7efe2bd
File tree
4 files changed
+36
-2
lines changed- clang
- docs
- include/clang/AST
- lib/AST
- test/SemaCXX
4 files changed
+36
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
220 | 225 | | |
221 | 226 | | |
222 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1395 | 1395 | | |
1396 | 1396 | | |
1397 | 1397 | | |
1398 | | - | |
| 1398 | + | |
| 1399 | + | |
1399 | 1400 | | |
1400 | 1401 | | |
1401 | 1402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1057 | 1057 | | |
1058 | 1058 | | |
1059 | 1059 | | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1060 | 1063 | | |
1061 | 1064 | | |
1062 | 1065 | | |
| |||
1125 | 1128 | | |
1126 | 1129 | | |
1127 | 1130 | | |
1128 | | - | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
1129 | 1136 | | |
1130 | 1137 | | |
1131 | 1138 | | |
| |||
| 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