1 // { dg-do compile }
2 // { dg-options "-std=c++17" }
3
4 // Check that empty expansions and required failures.
5
6 #define COMMA ,
7
8 #define MAKE_FN(name, op) \
9 template<typename... Ts> \
10 constexpr auto name (Ts... ts) { return (... op ts); } // { dg-error "empty" }
11
12 MAKE_FN (add, +);
13 MAKE_FN (sub, -);
14 MAKE_FN (mul, *);
15 MAKE_FN (div, /);
16 MAKE_FN (mod, %);
17 MAKE_FN (bxor, ^);
18 MAKE_FN (bor, |);
19 MAKE_FN (band, &);
20 MAKE_FN (lsh, <<);
21 MAKE_FN (rsh, >>);
22
23 MAKE_FN (assign, =);
24 MAKE_FN (addi, +=);
25 MAKE_FN (subi, -=);
26 MAKE_FN (muli, *=);
27 MAKE_FN (divi, /=);
28 MAKE_FN (modi, %=);
29 MAKE_FN (bxori, ^=);
30 MAKE_FN (bori, |=);
31 MAKE_FN (bandi, &=);
32 MAKE_FN (lshi, <<=);
33 MAKE_FN (rshi, >>=);
34
35 MAKE_FN (eq, ==);
36 MAKE_FN (ne, !=);
37 MAKE_FN (lt, <);
38 MAKE_FN (gt, >);
39 MAKE_FN (le, <);
40 MAKE_FN (ge, >);
41
42 MAKE_FN (land, &&);
43 MAKE_FN (lor, ||);
44
45 MAKE_FN (comma, COMMA);
46 MAKE_FN (dot_star, .*);
47 MAKE_FN (arrow_star, ->*);
48
main()49 int main() {
50 static_assert(land() == true, "");
51 static_assert(lor() == false, "");
52 comma(); // No value to theck
53
54 // These are all errors, but the error is emitted at the point
55 // of instantiation (line 10).
56 add(); // { dg-message "required from here" }
57 mul(); // { dg-message "required from here" }
58 bor(); // { dg-message "required from here" }
59 band(); // { dg-message "required from here" }
60 sub(); // { dg-message "required from here" }
61 div(); // { dg-message "required from here" }
62 mod(); // { dg-message "required from here" }
63 lsh(); // { dg-message "required from here" }
64 rsh(); // { dg-message "required from here" }
65 assign(); // { dg-message "required from here" }
66 addi(); // { dg-message "required from here" }
67 subi(); // { dg-message "required from here" }
68 muli(); // { dg-message "required from here" }
69 divi(); // { dg-message "required from here" }
70 modi(); // { dg-message "required from here" }
71 bxor(); // { dg-message "required from here" }
72 bxori(); // { dg-message "required from here" }
73 bori(); // { dg-message "required from here" }
74 bandi(); // { dg-message "required from here" }
75 lshi(); // { dg-message "required from here" }
76 rshi(); // { dg-message "required from here" }
77 eq(); // { dg-message "required from here" }
78 ne(); // { dg-message "required from here" }
79 lt(); // { dg-message "required from here" }
80 gt(); // { dg-message "required from here" }
81 le(); // { dg-message "required from here" }
82 ge(); // { dg-message "required from here" }
83 dot_star(); // { dg-message "required from here" }
84 arrow_star(); // { dg-message "required from here" }
85 }
86