Files
TheRock/compiler/amd-llvm/clang/test/C/drs/dr268.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

64 lines
1.9 KiB
C

/* RUN: %clang_cc1 -std=c89 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
RUN: %clang_cc1 -std=c99 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
RUN: %clang_cc1 -std=c11 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
RUN: %clang_cc1 -std=c17 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
RUN: %clang_cc1 -std=c2x -pedantic -verify -emit-llvm -o - %s | FileCheck %s
*/
/* expected-no-diagnostics */
/* WG14 DR268: yes
* Jumps into iteration statements
*/
void foo(void);
void dr268(void) {
int i = 5;
goto goto_target;
for (i = 0; i < 10; ++i) {
if (i > 2) ++i;
goto_target:
foo();
}
/* Ensure that the goto jumps into the middle of the for loop body, and that
* the initialization and controlling expression are not evaluated on the
* first pass through.
*/
/* Get us to the right function.
CHECK-LABEL: define{{.*}} void @dr268() {{.*}} {
First is the initialization and goto.
CHECK: store i32 5
CHECK-NEXT: br label %[[GOTO_TARGET:.+]]
Then comes the initialization of the for loop variable.
CHECK: store i32 0
CHECK-NEXT: br label %[[FOR_COND:.+]]
Then comes the for loop condition check label followed eventually by the
for loop body label.
CHECK: [[FOR_COND]]:
CHECK: {{.+}} = icmp slt i32 {{.+}}, 10
CHECK: [[FOR_BODY:.+]]:
CHECK: {{.+}} = icmp sgt i32 {{.+}}, 2
Then comes the then branch of the if statement.
CHECK: %[[I:.+]] = load i32,
CHECK-NEXT: %[[INC:.+]] = add nsw i32 %[[I]], 1
CHECK-NEXT: store i32 %[[INC]],
Eventually, we get to the goto label and its call
CHECK: [[GOTO_TARGET]]:
CHECK-NEXT: call void @foo()
CHECK-NEXT: br label %[[FOR_INC:.+]]
CHECK: [[FOR_INC]]:
CHECK-NEXT: %[[I2:.+]] = load i32,
CHECK-NEXT: %[[INC2:.+]] = add nsw i32 %[[I2]], 1
CHECK-NEXT: store i32 %[[INC2]],
CHECK-NEXT: br label %[[FOR_COND]]
*/
}