Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / builtin-tgmath-err-1.c
blob9016ec742bed41b6ddebbc0fa2f1ac1dad714229
1 /* Test __builtin_tgmath: errors that indicate a bad definition of a
2 type-generic macro rather than bad arguments in a call to it. */
3 /* { dg-do compile } */
4 /* { dg-options "" } */
6 void *p;
7 double d;
8 double unprototyped_d ();
9 long double unprototyped_ld ();
10 double variadic_d (double, ...);
11 long double variadic_ld (long double, ...);
12 double no_arguments_d (void);
13 long double no_arguments_ld (void);
14 double f_d (double);
15 long double f_ld (long double);
16 double many_args (double, double, double, double);
17 int f_i_d (double);
18 _Complex int f_ci_d (double);
19 void * f_p_d (double);
20 double f_d_i (int);
21 double f_d_ci (_Complex int);
22 double f_d_p (void *);
23 long double f_ld_d (double);
24 _Complex double f_cd_d (double);
25 double f_d_f (float);
26 double f_d_dd (double, double);
27 long double f_ld_ldld (long double, long double);
28 float f_f_fd (float, double);
30 void
31 test (void)
33 /* Arguments individually invalid or no consistent number of
34 arguments followed by those arguments. */
35 __builtin_tgmath (); /* { dg-error "too few arguments" } */
36 __builtin_tgmath (f_d); /* { dg-error "too few arguments" } */
37 __builtin_tgmath (f_d, f_ld); /* { dg-error "too few arguments" } */
38 __builtin_tgmath (many_args, many_args, many_args); /* { dg-error "too few arguments" } */
39 __builtin_tgmath (many_args, d, d, d, d); /* { dg-error "too few arguments" } */
40 __builtin_tgmath (f_ld, many_args, d); /* { dg-error "has wrong number of arguments" } */
41 __builtin_tgmath (unprototyped_d, unprototyped_ld, d); /* { dg-error "is unprototyped" } */
42 __builtin_tgmath (f_d, unprototyped_ld, d); /* { dg-error "is unprototyped" } */
43 __builtin_tgmath (variadic_d, variadic_ld, d); /* { dg-error "variable arguments" } */
44 __builtin_tgmath (f_d, variadic_ld, d); /* { dg-error "variable arguments" } */
45 __builtin_tgmath (p, p, p); /* { dg-error "is not a function pointer" } */
46 __builtin_tgmath (f_d, p, p); /* { dg-error "is not a function pointer" } */
47 __builtin_tgmath (no_arguments_d, no_arguments_d, no_arguments_ld); /* { dg-error "has no arguments" } */
48 __builtin_tgmath (f_d, no_arguments_d, no_arguments_ld); /* { dg-error "has no arguments" } */
50 /* Invalid varying types of arguments. */
51 __builtin_tgmath (f_i_d, f_ld, 0); /* { dg-error "invalid type-generic return type" } */
52 __builtin_tgmath (f_ci_d, f_ld, 0); /* { dg-error "invalid type-generic return type" } */
53 __builtin_tgmath (f_p_d, f_ld, 0); /* { dg-error "invalid type-generic return type" } */
54 __builtin_tgmath (f_ld, f_i_d, 0); /* { dg-error "invalid type-generic return type" } */
55 __builtin_tgmath (f_ld, f_ci_d, 0); /* { dg-error "invalid type-generic return type" } */
56 __builtin_tgmath (f_ld, f_p_d, 0); /* { dg-error "invalid type-generic return type" } */
57 __builtin_tgmath (f_d_i, f_ld, 0); /* { dg-error "invalid type-generic type for argument" } */
58 __builtin_tgmath (f_d_ci, f_ld, 0); /* { dg-error "invalid type-generic type for argument" } */
59 __builtin_tgmath (f_d_p, f_ld, 0); /* { dg-error "invalid type-generic type for argument" } */
60 __builtin_tgmath (f_ld, f_d_i, 0); /* { dg-error "invalid type-generic type for argument" } */
61 __builtin_tgmath (f_ld, f_d_ci, 0); /* { dg-error "invalid type-generic type for argument" } */
62 __builtin_tgmath (f_ld, f_d_p, 0); /* { dg-error "invalid type-generic type for argument" } */
64 /* Arguments same type. */
65 __builtin_tgmath (f_d, f_d, 0); /* { dg-error "all have the same type" } */
67 /* Missing or invalid type-generic parameter. */
68 __builtin_tgmath (f_d, f_ld_d, 0); /* { dg-error "lack type-generic parameter" } */
69 __builtin_tgmath (f_d, f_ld, f_cd_d, 0); /* { dg-error "lack type-generic parameter" } */
70 __builtin_tgmath (f_d, f_ld, f_d, 0); /* { dg-error "duplicate type-generic parameter type" } */
72 /* Variation not consistent with the identified type-generic
73 parameter. */
74 __builtin_tgmath (f_d, f_ld, f_d_f, 0); /* { dg-error "bad return type for function argument" } */
75 __builtin_tgmath (f_d_dd, f_ld_ldld, f_f_fd, 0, 0); /* { dg-error "bad type for argument" } */