[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / expr / expr.arith.conv / p2.cpp
blob0df3e302d0b3f671cf51a98d8015f5d4a0b106a1
1 // RUN: %clang_cc1 -verify %s -std=c++17 -Weverything -Wno-deprecated -Wno-float-equal
2 // RUN: %clang_cc1 -verify %s -std=c++2a -Wdeprecated
4 static enum E1 {} e1, e1b;
5 static enum E2 {} e2;
6 static double d;
7 extern void f();
8 extern bool b;
10 void f() {
11 void(e1 * e1);
12 void(e1 * e2); // expected-warning {{arithmetic between different enumeration types}}
13 void(e1 * d); // expected-warning {{arithmetic between enumeration type 'enum E1' and floating-point type 'double'}}
14 void(d * e1); // expected-warning {{arithmetic between floating-point type 'double' and enumeration type 'enum E1'}}
16 void(e1 + e1);
17 void(e1 + e2); // expected-warning {{arithmetic between different enumeration types}}
18 void(e1 + d); // expected-warning {{arithmetic between enumeration type 'enum E1' and floating-point type 'double'}}
19 void(d + e1); // expected-warning {{arithmetic between floating-point type 'double' and enumeration type 'enum E1'}}
21 #if __cplusplus > 201703L
22 void(e1 <=> e1b); // expected-error {{include <compare>}}
23 void(e1 <=> e2); // expected-error {{invalid operands}}
24 void(e1 <=> d); // expected-error {{invalid operands}}
25 void(d <=> e1); // expected-error {{invalid operands}}
26 #endif
28 void(e1 < e1b);
29 void(e1 < e2); // expected-warning {{comparison of different enumeration types}}
30 void(e1 < d); // expected-warning {{comparison of enumeration type 'enum E1' with floating-point type 'double'}}
31 void(d < e1); // expected-warning {{comparison of floating-point type 'double' with enumeration type 'enum E1'}}
33 void(e1 == e1b);
34 void(e1 == e2); // expected-warning {{comparison of different enumeration types}}
35 void(e1 == d); // expected-warning {{comparison of enumeration type 'enum E1' with floating-point type 'double'}}
36 void(d == e1); // expected-warning {{comparison of floating-point type 'double' with enumeration type 'enum E1'}}
38 void(b ? e1 : e1b);
39 void(b ? e1 : e2); // expected-warning {{conditional expression between different enumeration types}}
40 void(b ? e1 : d); // expected-warning {{conditional expression between enumeration type 'enum E1' and floating-point type 'double'}}
41 void(b ? d : e1); // expected-warning {{conditional expression between floating-point type 'double' and enumeration type 'enum E1'}}
43 void(e1 = e1b);
44 void(e1 = e2); // expected-error {{incompatible}}
45 void(e1 = d); // expected-error {{incompatible}}
46 void(d = e1); // FIXME: Should we warn on this?
48 void(e1 += e1b); // expected-error {{incompatible}}
49 void(e1 += e2); // expected-error {{incompatible}}
50 void(e1 += d); // expected-error {{incompatible}}
51 void(d += e1); // expected-warning {{compound assignment of floating-point type 'double' from enumeration type 'enum E1'}}