| 1 |
// RUN: %clang_cc1 -std=c89 -emit-llvm %s -o - | FileCheck %s --check-prefix=C89 |
| 2 |
// RUN: %clang_cc1 -std=c99 -emit-llvm %s -o - | FileCheck %s --check-prefix=C99 |
| 3 |
|
| 4 |
void f(void* arg); |
| 5 |
void g(void) { |
| 6 |
__attribute__((cleanup(f))) void *g; |
| 7 |
} |
| 8 |
|
| 9 |
void cleaner(int *p); |
| 10 |
|
| 11 |
// C89-LABEL: define{{.*}} void @test_nested_for_loop_cleanup() |
| 12 |
// C99-LABEL: define{{.*}} void @test_nested_for_loop_cleanup() |
| 13 |
void test_nested_for_loop_cleanup(void) { |
| 14 |
for (int i = 10; 0;) { |
| 15 |
for (__attribute__((cleanup(cleaner))) int j = 20; 0;) |
| 16 |
; |
| 17 |
i = 5; // Some operation after inner loop |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
// C89: for.end: |
| 22 |
// C89-NEXT: store i32 5, ptr %i, align 4 |
| 23 |
// C89-NEXT: call void @cleaner(ptr noundef %j) |
| 24 |
|
| 25 |
// C99: for.cond.cleanup: |
| 26 |
// C99-NEXT: call void @cleaner(ptr noundef %j) |
| 27 |
// C99-NEXT: br label %for.end |