[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / warn-sign-conversion.cpp
blob4d73d09dd8390a9a624014004f91ff592fb455c7
1 // RUN: %clang_cc1 -triple %itanium_abi_triple -verify -fsyntax-only -Wsign-conversion %s
3 // NOTE: When a 'enumeral mismatch' warning is implemented then expect several
4 // of the following cases to be impacted.
6 // namespace for unnamed enums tests
7 namespace test1 {
8 enum { A };
9 enum { B = -1 };
11 template <typename T> struct Foo {
12 enum { C };
13 enum { D = ~0U };
16 enum { E = ~0U };
18 void doit_unnamed( int i ) {
19 int a1 = 1 ? i : A;
20 int a2 = 1 ? A : i;
22 int b1 = 1 ? i : B;
23 int b2 = 1 ? B : i;
25 int c1 = 1 ? i : Foo<bool>::C;
26 int c2 = 1 ? Foo<bool>::C : i;
28 int d1a = 1 ? i : Foo<bool>::D; // expected-warning {{test1::Foo<bool>::(unnamed enum at }}
29 int d1b = 1 ? i : Foo<bool>::D; // expected-warning {{warn-sign-conversion.cpp:13:5)' to 'int'}}
30 int d2a = 1 ? Foo<bool>::D : i; // expected-warning {{operand of ? changes signedness: 'test1::Foo<bool>::(unnamed enum at }}
31 int d2b = 1 ? Foo<bool>::D : i; // expected-warning {{warn-sign-conversion.cpp:13:5)' to 'int'}}
32 int d3a = 1 ? B : Foo<bool>::D; // expected-warning {{operand of ? changes signedness: 'test1::Foo<bool>::(unnamed enum at }}
33 int d3b = 1 ? B : Foo<bool>::D; // expected-warning {{warn-sign-conversion.cpp:13:5)' to 'int'}}
34 int d4a = 1 ? Foo<bool>::D : B; // expected-warning {{operand of ? changes signedness: 'test1::Foo<bool>::(unnamed enum at }}
35 int d4b = 1 ? Foo<bool>::D : B; // expected-warning {{warn-sign-conversion.cpp:13:5)' to 'int'}}
37 int e1a = 1 ? i : E; // expected-warning {{operand of ? changes signedness: 'test1::(unnamed enum at }}
38 int e1b = 1 ? i : E; // expected-warning {{warn-sign-conversion.cpp:16:3)' to 'int'}}
39 int e2a = 1 ? E : i; // expected-warning {{operand of ? changes signedness: 'test1::(unnamed enum at }}
40 int e2b = 1 ? E : i; // expected-warning {{warn-sign-conversion.cpp:16:3)' to 'int'}}
41 int e3a = 1 ? E : B; // expected-warning {{operand of ? changes signedness: 'test1::(unnamed enum at }}
42 int e3b = 1 ? E : B; // expected-warning {{warn-sign-conversion.cpp:16:3)' to 'int'}}
43 int e4a = 1 ? B : E; // expected-warning {{operand of ? changes signedness: 'test1::(unnamed enum at }}
44 int e4b = 1 ? B : E; // expected-warning {{warn-sign-conversion.cpp:16:3)' to 'int'}}
48 // namespace for named enums tests
49 namespace test2 {
50 enum Named1 { A };
51 enum Named2 { B = -1 };
53 template <typename T> struct Foo {
54 enum Named3 { C };
55 enum Named4 { D = ~0U };
58 enum Named5 { E = ~0U };
60 void doit_unnamed( int i ) {
61 int a1 = 1 ? i : A;
62 int a2 = 1 ? A : i;
64 int b1 = 1 ? i : B;
65 int b2 = 1 ? B : i;
67 int c1 = 1 ? i : Foo<bool>::C;
68 int c2 = 1 ? Foo<bool>::C : i;
70 int d1 = 1 ? i : Foo<bool>::D; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}}
71 int d2 = 1 ? Foo<bool>::D : i; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}}
72 int d3 = 1 ? B : Foo<bool>::D; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}}
73 int d4 = 1 ? Foo<bool>::D : B; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}}
75 int e1 = 1 ? i : E; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}}
76 int e2 = 1 ? E : i; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}}
77 int e3 = 1 ? E : B; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}}
78 int e4 = 1 ? B : E; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}}