No longer reject tag declarations in the clause-1 of a for loop.
authorAaron Ballman <aaron@aaronballman.com>
Fri, 18 Dec 2020 12:53:39 +0000 (07:53 -0500)
committerAaron Ballman <aaron@aaronballman.com>
Fri, 18 Dec 2020 12:56:17 +0000 (07:56 -0500)
commit2d2498ec6c42b12eae873257e6ddce3333fe8348
treec82d071101b7942f1a2f1567a9d130afd3aa078c
parent430d5d8429473c2b10b109991d7577a3cea41140
No longer reject tag declarations in the clause-1 of a for loop.

We currently reject this valid C construct by claiming it declares a
non-local variable: for (struct { int i; } s={0}; s.i != 0; s.i--) ;

We expected all declaration in the clause-1 declaration statement to be
a local VarDecl, but there can be other declarations involved such as a
tag declaration. This fixes PR35757.
clang/lib/Sema/SemaStmt.cpp
clang/test/Sema/for.c