[clang] [Clang] [Sema] Allow non-local/non-variable declarations in for loop (PR #129737)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 7 07:38:47 PST 2025
================
@@ -1,13 +1,21 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify=c11 -std=c11 -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify=c23 -std=c23 -Wpre-c23-compat %s
// Check C99 6.8.5p3
void b1 (void) { for (void (*f) (void);;); }
-void b2 (void) { for (void f (void);;); } // expected-error {{non-variable declaration in 'for' loop}}
-void b3 (void) { for (static int f;;); } // expected-error {{declaration of non-local variable}}
-void b4 (void) { for (typedef int f;;); } // expected-error {{non-variable declaration in 'for' loop}}
+void b2 (void) { for (void f (void);;); } /* c11-warning {{non-variable declaration in 'for' loop is a C23 extension}}
----------------
shafik wrote:
Apologies for the drive by after commit review but I really would like to see that. Having spent some time digging into regression the past few months a main pattern is lack of testing and so I am trying to push asking for more in the testing arena.
https://github.com/llvm/llvm-project/pull/129737
More information about the cfe-commits
mailing list