[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / C / drs / dr268.c
blob0fb2a6d958391b8e413f20bae7361359dc9b3631
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
6 */
8 /* expected-no-diagnostics */
10 /* WG14 DR268: yes
11 * Jumps into iteration statements
13 void foo(void);
14 void dr268(void) {
15 int i = 5;
16 goto goto_target;
18 for (i = 0; i < 10; ++i) {
19 if (i > 2) ++i;
20 goto_target:
21 foo();
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
26 * first pass through.
28 /* Get us to the right function.
29 CHECK-LABEL: define{{.*}} void @dr268() {{.*}} {
31 First is the initialization and goto.
32 CHECK: store i32 5
33 CHECK-NEXT: br label %[[GOTO_TARGET:.+]]
35 Then comes the initialization of the for loop variable.
36 CHECK: store i32 0
37 CHECK-NEXT: br label %[[FOR_COND:.+]]
39 Then comes the for loop condition check label followed eventually by the
40 for loop body label.
41 CHECK: [[FOR_COND]]:
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:.+]]
56 CHECK: [[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]]