Commit 5b3ba26
authored
[Clang] [Sema] Allow non-local/non-variable declarations in for loop (#129737)
Currently, we error on non-variable or non-local variable declarations
in `for` loops such as `for (struct S {}; 0; ) {}`. However, this is
valid in C23, so this patch changes the error to a compatibilty warning
and also allows this as an extension in earlier language modes. This
also matches GCC’s behaviour.1 parent 4b454af commit 5b3ba26
File tree
4 files changed
+42
-12
lines changed- clang
- docs
- include/clang/Basic
- lib/Sema
- test/Sema
4 files changed
+42
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
251 | 253 | | |
252 | 254 | | |
253 | 255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10797 | 10797 | | |
10798 | 10798 | | |
10799 | 10799 | | |
| 10800 | + | |
| 10801 | + | |
| 10802 | + | |
| 10803 | + | |
| 10804 | + | |
| 10805 | + | |
| 10806 | + | |
| 10807 | + | |
| 10808 | + | |
| 10809 | + | |
| 10810 | + | |
| 10811 | + | |
| 10812 | + | |
| 10813 | + | |
| 10814 | + | |
| 10815 | + | |
| 10816 | + | |
10800 | 10817 | | |
10801 | 10818 | | |
10802 | 10819 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2269 | 2269 | | |
2270 | 2270 | | |
2271 | 2271 | | |
2272 | | - | |
2273 | | - | |
2274 | | - | |
2275 | | - | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
2276 | 2277 | | |
2277 | 2278 | | |
2278 | 2279 | | |
| |||
2284 | 2285 | | |
2285 | 2286 | | |
2286 | 2287 | | |
2287 | | - | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
2288 | 2291 | | |
2289 | 2292 | | |
2290 | 2293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
8 | 13 | | |
9 | 14 | | |
10 | | - | |
11 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
12 | 19 | | |
13 | | - | |
| 20 | + | |
| 21 | + | |
0 commit comments