64 lines · c
1/* RUN: %clang_cc1 -std=c89 -pedantic -verify -emit-llvm -o - %s | FileCheck %s2 RUN: %clang_cc1 -std=c99 -pedantic -verify -emit-llvm -o - %s | FileCheck %s3 RUN: %clang_cc1 -std=c11 -pedantic -verify -emit-llvm -o - %s | FileCheck %s4 RUN: %clang_cc1 -std=c17 -pedantic -verify -emit-llvm -o - %s | FileCheck %s5 RUN: %clang_cc1 -std=c2x -pedantic -verify -emit-llvm -o - %s | FileCheck %s6 */7 8/* expected-no-diagnostics */9 10/* WG14 DR268: yes11 * Jumps into iteration statements12 */13void foo(void);14void dr268(void) {15 int i = 5;16 goto goto_target;17 18 for (i = 0; i < 10; ++i) {19 if (i > 2) ++i;20goto_target:21 foo();22 }23 24 /* Ensure that the goto jumps into the middle of the for loop body, and that25 * the initialization and controlling expression are not evaluated on the26 * first pass through.27 */28 /* Get us to the right function.29 CHECK-LABEL: define{{.*}} void @dr268() {{.*}} {30 31 First is the initialization and goto.32 CHECK: store i32 533 CHECK-NEXT: br label %[[GOTO_TARGET:.+]]34 35 Then comes the initialization of the for loop variable.36 CHECK: store i32 037 CHECK-NEXT: br label %[[FOR_COND:.+]]38 39 Then comes the for loop condition check label followed eventually by the40 for loop body label.41 CHECK: [[FOR_COND]]:42 CHECK: {{.+}} = icmp slt i32 {{.+}}, 1043 CHECK: [[FOR_BODY:.+]]:44 CHECK: {{.+}} = icmp sgt i32 {{.+}}, 245 46 Then comes the then branch of the if statement.47 CHECK: %[[I:.+]] = load i32,48 CHECK-NEXT: %[[INC:.+]] = add nsw i32 %[[I]], 149 CHECK-NEXT: store i32 %[[INC]],50 51 Eventually, we get to the goto label and its call52 CHECK: [[GOTO_TARGET]]:53 CHECK-NEXT: call void @foo()54 CHECK-NEXT: br label %[[FOR_INC:.+]]55 56 CHECK: [[FOR_INC]]:57 CHECK-NEXT: %[[I2:.+]] = load i32,58 CHECK-NEXT: %[[INC2:.+]] = add nsw i32 %[[I2]], 159 CHECK-NEXT: store i32 %[[INC2]],60 CHECK-NEXT: br label %[[FOR_COND]]61 */62}63 64