Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / C / drs / dr494.c
blobcdcfc419c4e90a3995936babb80a3c5fb5c9f460
1 /* RUN: %clang_cc1 -std=c89 %s -emit-llvm -o - | FileCheck %s
2 RUN: %clang_cc1 -std=c99 %s -emit-llvm -o - | FileCheck %s
3 RUN: %clang_cc1 -std=c11 %s -emit-llvm -o - | FileCheck %s
4 RUN: %clang_cc1 -std=c17 %s -emit-llvm -o - | FileCheck %s
5 RUN: %clang_cc1 -std=c2x %s -emit-llvm -o - | FileCheck %s
6 */
8 /* WG14 DR494: yes
9 * Part 1: Alignment specifier expression evaluation
11 void dr494(void) {
12 int i = 12;
13 int j = _Alignof(int [++i]);
14 int k = sizeof(int [++i]);
15 /* Check that we store a straight value for i and j, but have to calculate a
16 * value for storing into k. That's because sizeof() needs to execute code to
17 * get the correct value from a VLA, but _Alignof is not allowed to execute
18 * the VLA extent at runtime.
20 /* CHECK: %[[I:.+]] = alloca i32
21 CHECK: %[[J:.+]] = alloca i32
22 CHECK: %[[K:.+]] = alloca i32
23 CHECK: store i32 12, ptr %[[I]]
24 CHECK: store i32 4, ptr %[[J]]
25 CHECK: %[[ZERO:.+]] = load i32, ptr %[[I]]
26 CHECK: %[[INC:.+]] = add nsw i32 %[[ZERO]], 1
27 CHECK: store i32 %[[INC]], ptr %[[I]]