1 // RUN: %clang_cc1 -triple x86_64-linux -std=c17 -verify=expected,norounding %s
2 // RUN: %clang_cc1 -triple x86_64-linux -std=gnu17 -verify=expected,norounding %s
3 // RUN: %clang_cc1 -triple x86_64-linux -std=c17 -verify=expected,rounding %s -frounding-math
4 // RUN: %clang_cc1 -triple x86_64-linux -std=gnu17 -verify=expected,rounding %s -frounding-math
6 #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
10 #define f(n) ((n) * (1.0 / 3.0))
11 _Static_assert(fold((int)f(3)) == 1, "");
13 typedef int T
[fold((int)f(3))];
16 enum Enum
{ enum_a
= (int)f(3) };
20 unsigned int m
: fold((int)f(3));
23 void bitfield(struct Bitfield
*b
) {
24 b
->n
= (int)(6 * (1.0 / 3.0)); // norounding-warning {{changes value from 2 to 0}}
28 // This is always a VLA due to its syntactic form.
29 typedef int vla1
[(int)(-3 * (1.0 / 3.0))];
30 struct X1
{ vla1 v
; }; // expected-error {{fields must have a constant size}}
32 // This is always folded to a constant.
33 typedef int vla2
[fold((int)(-3 * (1.0 / 3.0)))]; // expected-error {{negative size}}
34 struct X2
{ vla2 v
; };