[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / rounding-math.c
blobcd1498af4a78243ba20d0b806a18ee641121a165
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))
8 double a = 1.0 / 3.0;
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))];
14 typedef int T[1];
16 enum Enum { enum_a = (int)f(3) };
18 struct Bitfield {
19 unsigned int n : 1;
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}}
27 void vlas(void) {
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; };