From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/SemaCXX/warn-sign-conversion.cpp | 80 +++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 clang/test/SemaCXX/warn-sign-conversion.cpp (limited to 'clang/test/SemaCXX/warn-sign-conversion.cpp') diff --git a/clang/test/SemaCXX/warn-sign-conversion.cpp b/clang/test/SemaCXX/warn-sign-conversion.cpp new file mode 100644 index 0000000..ba2bc9b --- /dev/null +++ b/clang/test/SemaCXX/warn-sign-conversion.cpp @@ -0,0 +1,80 @@ +// RUN: %clang_cc1 -verify -fsyntax-only -Wsign-conversion %s + +// NOTE: When a 'enumeral mismatch' warning is implemented then expect several +// of the following cases to be impacted. + +// namespace for anonymous enums tests +namespace test1 { + enum { A }; + enum { B = -1 }; + + template struct Foo { + enum { C }; + enum { D = ~0U }; + }; + + enum { E = ~0U }; + + void doit_anonymous( int i ) { + int a1 = 1 ? i : A; + int a2 = 1 ? A : i; + + int b1 = 1 ? i : B; + int b2 = 1 ? B : i; + + int c1 = 1 ? i : Foo::C; + int c2 = 1 ? Foo::C : i; + + int d1a = 1 ? i : Foo::D; // expected-warning {{test1::Foo::::D; // expected-warning {{warn-sign-conversion.cpp:13:5>' to 'int'}} + int d2a = 1 ? Foo::D : i; // expected-warning {{operand of ? changes signedness: 'test1::Foo::::D : i; // expected-warning {{warn-sign-conversion.cpp:13:5>' to 'int'}} + int d3a = 1 ? B : Foo::D; // expected-warning {{operand of ? changes signedness: 'test1::Foo::::D; // expected-warning {{warn-sign-conversion.cpp:13:5>' to 'int'}} + int d4a = 1 ? Foo::D : B; // expected-warning {{operand of ? changes signedness: 'test1::Foo::::D : B; // expected-warning {{warn-sign-conversion.cpp:13:5>' to 'int'}} + + int e1a = 1 ? i : E; // expected-warning {{operand of ? changes signedness: 'test1::' to 'int'}} + int e2a = 1 ? E : i; // expected-warning {{operand of ? changes signedness: 'test1::' to 'int'}} + int e3a = 1 ? E : B; // expected-warning {{operand of ? changes signedness: 'test1::' to 'int'}} + int e4a = 1 ? B : E; // expected-warning {{operand of ? changes signedness: 'test1::' to 'int'}} + } +} + +// namespace for named enums tests +namespace test2 { + enum Named1 { A }; + enum Named2 { B = -1 }; + + template struct Foo { + enum Named3 { C }; + enum Named4 { D = ~0U }; + }; + + enum Named5 { E = ~0U }; + + void doit_anonymous( int i ) { + int a1 = 1 ? i : A; + int a2 = 1 ? A : i; + + int b1 = 1 ? i : B; + int b2 = 1 ? B : i; + + int c1 = 1 ? i : Foo::C; + int c2 = 1 ? Foo::C : i; + + int d1 = 1 ? i : Foo::D; // expected-warning {{operand of ? changes signedness: 'test2::Foo::Named4' to 'int'}} + int d2 = 1 ? Foo::D : i; // expected-warning {{operand of ? changes signedness: 'test2::Foo::Named4' to 'int'}} + int d3 = 1 ? B : Foo::D; // expected-warning {{operand of ? changes signedness: 'test2::Foo::Named4' to 'int'}} + int d4 = 1 ? Foo::D : B; // expected-warning {{operand of ? changes signedness: 'test2::Foo::Named4' to 'int'}} + + int e1 = 1 ? i : E; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}} + int e2 = 1 ? E : i; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}} + int e3 = 1 ? E : B; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}} + int e4 = 1 ? B : E; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}} + } +} -- cgit v1.2.3