Commit 858b56e
authored
[Clang] Preserve coroutine parameter referenced state (#70973)
This PR is proposing a fix for #65971. Previously, given a coroutine like this ``` task foo(int a) { co_return; } ``` Parameter `a` is never used. However, because C++ coroutines move constructs the variable to a heap allocated coroutine activation frame, we considered all parameters referenced. When diagnosing unused parameters, we cannot distinguish if the variable reference was due to coroutine parameter moves. Compiler Explorer shows that GCC warns against this case correctly, but clang does not: https://godbolt.org/z/Wo7dfqeaf This patch addresses this issue by preserving the original `ParmVarDecl`'s `Referenced` state.1 parent d76b56f commit 858b56e
File tree
2 files changed
+40
-0
lines changed- clang
- lib/Sema
- test/SemaCXX
2 files changed
+40
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1965 | 1965 | | |
1966 | 1966 | | |
1967 | 1967 | | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
1968 | 1971 | | |
1969 | 1972 | | |
1970 | 1973 | | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
1971 | 1977 | | |
1972 | 1978 | | |
1973 | 1979 | | |
| |||
| 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 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
0 commit comments