brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 4d73d09 Raw
81 lines · cpp
1// RUN: %clang_cc1 -triple %itanium_abi_triple -verify -fsyntax-only -Wsign-conversion %s2 3// NOTE: When a 'enumeral mismatch' warning is implemented then expect several4// of the following cases to be impacted.5 6// namespace for unnamed enums tests7namespace test1 {8  enum { A };9  enum { B = -1 };10 11  template <typename T> struct Foo {12    enum { C };13    enum { D = ~0U };14  };15 16  enum { E = ~0U };17 18  void doit_unnamed( int i ) {19    int a1 = 1 ? i : A;20    int a2 = 1 ? A : i;21 22    int b1 = 1 ? i : B;23    int b2 = 1 ? B : i;24 25    int c1 = 1 ? i : Foo<bool>::C;26    int c2 = 1 ? Foo<bool>::C : i;27 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'}}36 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'}}45  }46}47 48// namespace for named enums tests49namespace test2 {50  enum Named1 { A };51  enum Named2 { B = -1 };52 53  template <typename T> struct Foo {54    enum Named3 { C };55    enum Named4 { D = ~0U };56  };57 58  enum Named5 { E = ~0U };59 60  void doit_unnamed( int i ) {61    int a1 = 1 ? i : A;62    int a2 = 1 ? A : i;63 64    int b1 = 1 ? i : B;65    int b2 = 1 ? B : i;66 67    int c1 = 1 ? i : Foo<bool>::C;68    int c2 = 1 ? Foo<bool>::C : i;69 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'}}74 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'}}79  }80}81