Commit 200f3bd
authored
[Clang][Sema] access checking of friend declaration should not be delayed (#91430)
attempt to fix #12361
Consider this example:
```cpp
class D {
class E{
class F{};
friend void foo(D::E::F& q);
};
friend void foo(D::E::F& q);
};
void foo(D::E::F& q) {}
```
The first friend declaration of foo is correct. After that, the second
friend declaration delayed access checking and set its previous
declaration to be the first one. When doing access checking of `F`(which
is private filed of `E`), we put its canonical declaration(the first
friend declaration) into `EffectiveContext.Functions`. Actually, we are
still checking the first one. This is incorrect due to the delayed
checking.
Creating a new scope to indicate we are parsing a friend declaration and
doing access checking in time.1 parent f52ca63 commit 200f3bd
File tree
6 files changed
+68
-7
lines changed- clang
- docs
- include/clang/Sema
- lib
- Parse
- Sema
- test/SemaCXX
6 files changed
+68
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
706 | 706 | | |
707 | 707 | | |
708 | 708 | | |
| 709 | + | |
709 | 710 | | |
710 | 711 | | |
711 | 712 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
586 | 589 | | |
587 | 590 | | |
588 | 591 | | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
589 | 595 | | |
590 | 596 | | |
591 | 597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4331 | 4331 | | |
4332 | 4332 | | |
4333 | 4333 | | |
4334 | | - | |
| 4334 | + | |
4335 | 4335 | | |
4336 | | - | |
| 4336 | + | |
| 4337 | + | |
| 4338 | + | |
| 4339 | + | |
4337 | 4340 | | |
4338 | 4341 | | |
4339 | 4342 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1473 | 1473 | | |
1474 | 1474 | | |
1475 | 1475 | | |
1476 | | - | |
1477 | | - | |
1478 | | - | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
1479 | 1485 | | |
1480 | | - | |
1481 | | - | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
1482 | 1502 | | |
1483 | 1503 | | |
1484 | 1504 | | |
| |||
| 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 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments