1a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar// RUN: %clang_cc1 -triple %itanium_abi_triple -verify -fsyntax-only -Wsign-conversion %s 25254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 35254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu// NOTE: When a 'enumeral mismatch' warning is implemented then expect several 45254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu// of the following cases to be impacted. 55254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 65254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu// namespace for anonymous enums tests 75254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieunamespace test1 { 85254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum { A }; 95254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum { B = -1 }; 105254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 115254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu template <typename T> struct Foo { 125254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum { C }; 135254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum { D = ~0U }; 145254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu }; 155254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 165254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum { E = ~0U }; 175254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 185254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu void doit_anonymous( int i ) { 195254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int a1 = 1 ? i : A; 205254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int a2 = 1 ? A : i; 215254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 225254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int b1 = 1 ? i : B; 235254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int b2 = 1 ? B : i; 245254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 255254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int c1 = 1 ? i : Foo<bool>::C; 265254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int c2 = 1 ? Foo<bool>::C : i; 275254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 28651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int d1a = 1 ? i : Foo<bool>::D; // expected-warning {{test1::Foo<bool>::(anonymous enum at }} 29651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int d1b = 1 ? i : Foo<bool>::D; // expected-warning {{warn-sign-conversion.cpp:13:5)' to 'int'}} 30651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int d2a = 1 ? Foo<bool>::D : i; // expected-warning {{operand of ? changes signedness: 'test1::Foo<bool>::(anonymous enum at }} 31651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int d2b = 1 ? Foo<bool>::D : i; // expected-warning {{warn-sign-conversion.cpp:13:5)' to 'int'}} 32651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int d3a = 1 ? B : Foo<bool>::D; // expected-warning {{operand of ? changes signedness: 'test1::Foo<bool>::(anonymous enum at }} 33651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int d3b = 1 ? B : Foo<bool>::D; // expected-warning {{warn-sign-conversion.cpp:13:5)' to 'int'}} 34651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int d4a = 1 ? Foo<bool>::D : B; // expected-warning {{operand of ? changes signedness: 'test1::Foo<bool>::(anonymous enum at }} 35651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int d4b = 1 ? Foo<bool>::D : B; // expected-warning {{warn-sign-conversion.cpp:13:5)' to 'int'}} 365254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 37651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int e1a = 1 ? i : E; // expected-warning {{operand of ? changes signedness: 'test1::(anonymous enum at }} 38651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int e1b = 1 ? i : E; // expected-warning {{warn-sign-conversion.cpp:16:3)' to 'int'}} 39651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int e2a = 1 ? E : i; // expected-warning {{operand of ? changes signedness: 'test1::(anonymous enum at }} 40651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int e2b = 1 ? E : i; // expected-warning {{warn-sign-conversion.cpp:16:3)' to 'int'}} 41651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int e3a = 1 ? E : B; // expected-warning {{operand of ? changes signedness: 'test1::(anonymous enum at }} 42651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int e3b = 1 ? E : B; // expected-warning {{warn-sign-conversion.cpp:16:3)' to 'int'}} 43651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int e4a = 1 ? B : E; // expected-warning {{operand of ? changes signedness: 'test1::(anonymous enum at }} 44651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int e4b = 1 ? B : E; // expected-warning {{warn-sign-conversion.cpp:16:3)' to 'int'}} 455254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu } 465254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu} 475254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 485254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu// namespace for named enums tests 495254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieunamespace test2 { 505254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum Named1 { A }; 515254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum Named2 { B = -1 }; 525254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 535254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu template <typename T> struct Foo { 545254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum Named3 { C }; 555254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum Named4 { D = ~0U }; 565254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu }; 575254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 585254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu enum Named5 { E = ~0U }; 595254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 605254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu void doit_anonymous( int i ) { 615254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int a1 = 1 ? i : A; 625254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int a2 = 1 ? A : i; 635254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 645254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int b1 = 1 ? i : B; 655254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int b2 = 1 ? B : i; 665254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 675254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int c1 = 1 ? i : Foo<bool>::C; 685254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int c2 = 1 ? Foo<bool>::C : i; 695254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 705254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int d1 = 1 ? i : Foo<bool>::D; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}} 715254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int d2 = 1 ? Foo<bool>::D : i; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}} 725254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int d3 = 1 ? B : Foo<bool>::D; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}} 735254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int d4 = 1 ? Foo<bool>::D : B; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}} 745254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu 755254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int e1 = 1 ? i : E; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}} 765254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int e2 = 1 ? E : i; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}} 775254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int e3 = 1 ? E : B; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}} 785254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu int e4 = 1 ? B : E; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}} 795254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu } 805254161b269829b74e7a9379b1bdfa27de72d7ccRichard Trieu} 81