Update ChangeLog and version files for release
[official-gcc.git] / gcc / testsuite / c-c++-common / builtin-arith-overflow-1.c
blob69b508386d5de3d6866c7489cd049232b4be9936
1 /* { dg-do compile } */
3 int
4 f1 (void)
6 int x = __builtin_add_overflow (); /* { dg-error "not enough arguments to function" } */
7 x += __builtin_sub_overflow (); /* { dg-error "not enough arguments to function" } */
8 x += __builtin_mul_overflow (); /* { dg-error "not enough arguments to function" } */
9 return x;
12 int
13 f2 (int a, int b, int *c, int d)
15 int x = __builtin_add_overflow (a, b, c, d); /* { dg-error "too many arguments to function" } */
16 x += __builtin_sub_overflow (a, b, c, d, d, d); /* { dg-error "too many arguments to function" } */
17 x += __builtin_mul_overflow (a, b, c, d); /* { dg-error "too many arguments to function" } */
18 return x;
21 enum E { e0 = 0, e1 = 1 };
23 #ifndef __cplusplus
24 #define bool _Bool
25 #endif
27 int
28 f3 (float fa, int a, _Complex long int ca, double fb, void *pb, int b, enum E eb, bool bb, int *c)
30 int x = __builtin_add_overflow (fa, b, c); /* { dg-error "argument 1 in call to function\[^\n\r]*does not have integral type" } */
31 x += __builtin_sub_overflow (ca, b, c); /* { dg-error "argument 1 in call to function\[^\n\r]*does not have integral type" } */
32 x += __builtin_mul_overflow (a, fb, c); /* { dg-error "argument 2 in call to function\[^\n\r]*does not have integral type" } */
33 x += __builtin_add_overflow (a, pb, c); /* { dg-error "argument 2 in call to function\[^\n\r]*does not have integral type" } */
34 x += __builtin_sub_overflow (a, eb, c);
35 x += __builtin_mul_overflow (a, bb, c);
36 return x;
39 int
40 f4 (float *fp, double *dp, _Complex int *cp, enum E *ep, bool *bp, long long int *llp)
42 int x = __builtin_add_overflow (1, 2, fp); /* { dg-error "argument 3 in call to function\[^\n\r]*does not have pointer to integer type" } */
43 x += __builtin_sub_overflow (1, 2, dp); /* { dg-error "argument 3 in call to function\[^\n\r]*does not have pointer to integer type" } */
44 x += __builtin_mul_overflow (1, 2, cp); /* { dg-error "argument 3 in call to function\[^\n\r]*does not have pointer to integer type" } */
45 x += __builtin_add_overflow (1, 2, ep); /* { dg-error "argument 3 in call to function\[^\n\r]*does not have pointer to integer type" } */
46 x += __builtin_sub_overflow (1, 2, bp); /* { dg-error "argument 3 in call to function\[^\n\r]*does not have pointer to integer type" } */
47 x += __builtin_mul_overflow (1, 2, llp);
48 return x;