[clang] [CodeGen] Fix cleanup attribute for C89 for-loop init variables (PR #156643)

Jongmyeong Choi via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 17 05:02:02 PDT 2025


================
@@ -5,3 +5,26 @@ void g(void) {
   __attribute__((cleanup(f))) void *g;
 }
 
+// Test for cleanup in for-loop initialization (PR #154624)
+// RUN: %clang_cc1 -std=c89 -emit-llvm %s -o - | FileCheck %s --check-prefix=C89
+// RUN: %clang_cc1 -std=c99 -emit-llvm %s -o - | FileCheck %s --check-prefix=C99
----------------
jongmyeong-choi wrote:

When you mentioned "delete the redundant RUN line" - were you referring to this line? `// RUN: %clang_cc1 -emit-llvm %s -o %t`

And update_cc_test_checks seems to check the entire IR. I don't have much experience, so I'm wondering if this approach is better. Personally, I feel that localized tests are more intuitive.

https://github.com/llvm/llvm-project/pull/156643


More information about the cfe-commits mailing list