1 /* RUN: %clang_cc1 -std=c89 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
2 RUN: %clang_cc1 -std=c99 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
3 RUN: %clang_cc1 -std=c11 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
4 RUN: %clang_cc1 -std=c17 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
5 RUN: %clang_cc1 -std=c2x -pedantic -verify -emit-llvm -o - %s | FileCheck %s
8 /* expected-no-diagnostics */
11 * Jumps into iteration statements
18 for (i
= 0; i
< 10; ++i
) {
24 /* Ensure that the goto jumps into the middle of the for loop body, and that
25 * the initialization and controlling expression are not evaluated on the
28 /* Get us to the right function.
29 CHECK-LABEL: define{{.*}} void @dr268() {{.*}} {
31 First is the initialization and goto.
33 CHECK-NEXT: br label %[[GOTO_TARGET:.+]]
35 Then comes the initialization of the for loop variable.
37 CHECK-NEXT: br label %[[FOR_COND:.+]]
39 Then comes the for loop condition check label followed eventually by the
42 CHECK: {{.+}} = icmp slt i32 {{.+}}, 10
43 CHECK: [[FOR_BODY:.+]]:
44 CHECK: {{.+}} = icmp sgt i32 {{.+}}, 2
46 Then comes the then branch of the if statement.
47 CHECK: %[[I:.+]] = load i32,
48 CHECK-NEXT: %[[INC:.+]] = add nsw i32 %[[I]], 1
49 CHECK-NEXT: store i32 %[[INC]],
51 Eventually, we get to the goto label and its call
52 CHECK: [[GOTO_TARGET]]:
53 CHECK-NEXT: call void @foo()
54 CHECK-NEXT: br label %[[FOR_INC:.+]]
57 CHECK-NEXT: %[[I2:.+]] = load i32,
58 CHECK-NEXT: %[[INC2:.+]] = add nsw i32 %[[I2]], 1
59 CHECK-NEXT: store i32 %[[INC2]],
60 CHECK-NEXT: br label %[[FOR_COND]]