xref: /llvm-project/clang/test/C/drs/dr494.c (revision 7fc57d7c97c64b64ef865d71343867ab30cfcf15)
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  */
7 
8 /* WG14 DR494: yes
9  * Part 1: Alignment specifier expression evaluation
10  */
dr494(void)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.
19    */
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]]
28  */
29 }
30 
31