diff options
Diffstat (limited to 'clang/test/SemaCXX')
| -rw-r--r-- | clang/test/SemaCXX/bool.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/conversion.cpp | 11 | ||||
| -rw-r--r-- | clang/test/SemaCXX/expressions.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/overload-call.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-literal-conversion.cpp | 28 |
5 files changed, 27 insertions, 18 deletions
diff --git a/clang/test/SemaCXX/bool.cpp b/clang/test/SemaCXX/bool.cpp index 2b3ab68848e..f027186735b 100644 --- a/clang/test/SemaCXX/bool.cpp +++ b/clang/test/SemaCXX/bool.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion %s // Bool literals can be enum values. enum { diff --git a/clang/test/SemaCXX/conversion.cpp b/clang/test/SemaCXX/conversion.cpp index b019536e1a3..4b44bede8db 100644 --- a/clang/test/SemaCXX/conversion.cpp +++ b/clang/test/SemaCXX/conversion.cpp @@ -65,7 +65,7 @@ void test3() { int c = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to 'int'}} int d; d = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to 'int'}} - bool bl = NULL; // FIXME: this should warn but we currently suppress a bunch of conversion-to-bool warnings including this one + bool bl = NULL; // expected-warning {{implicit conversion of NULL constant to 'bool'}} char ch = NULL; // expected-warning {{implicit conversion of NULL constant to 'char'}} unsigned char uch = NULL; // expected-warning {{implicit conversion of NULL constant to 'unsigned char'}} short sh = NULL; // expected-warning {{implicit conversion of NULL constant to 'short'}} @@ -104,3 +104,12 @@ namespace test4 { tmpl2<int*>(); } } + +namespace test5 { + template<int I> + void func() { + bool b = I; + } + + template void func<3>(); +} diff --git a/clang/test/SemaCXX/expressions.cpp b/clang/test/SemaCXX/expressions.cpp index 355833e693f..2635fb8d176 100644 --- a/clang/test/SemaCXX/expressions.cpp +++ b/clang/test/SemaCXX/expressions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion %s void choice(int); int choice(bool); diff --git a/clang/test/SemaCXX/overload-call.cpp b/clang/test/SemaCXX/overload-call.cpp index 09eb71d36d7..2b5ebb962b6 100644 --- a/clang/test/SemaCXX/overload-call.cpp +++ b/clang/test/SemaCXX/overload-call.cpp @@ -233,7 +233,7 @@ float* intref(const int&); void intref_test() { float* ir1 = intref(5); - float* ir2 = intref(5.5); // expected-warning{{implicit conversion turns literal floating-point number into integer}} + float* ir2 = intref(5.5); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 5.5 to 5}} } void derived5(C&); // expected-note{{candidate function not viable: cannot bind base class object of type 'A' to derived class reference 'C &' for 1st argument}} diff --git a/clang/test/SemaCXX/warn-literal-conversion.cpp b/clang/test/SemaCXX/warn-literal-conversion.cpp index 5fcae5dc80e..d7bec4c73e5 100644 --- a/clang/test/SemaCXX/warn-literal-conversion.cpp +++ b/clang/test/SemaCXX/warn-literal-conversion.cpp @@ -5,29 +5,29 @@ void foo(int y); // Warn when a literal float or double is assigned or bound to an integer. void test0() { // Float - int y0 = 1.2222F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y1 = (1.2222F); // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y2 = (((1.2222F))); // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y3 = 12E-1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y4 = 1.23E1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} + int y0 = 1.2222F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2222 to 1}} + int y1 = (1.2222F); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2222 to 1}} + int y2 = (((1.2222F))); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2222 to 1}} + int y3 = 12E-1F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2 to 1}} + int y4 = 1.23E1F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 12.3 to 12}} // Double - int y5 = 1.2222; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y6 = 12E-1; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y7 = 1.23E1; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y8 = (1.23E1); // expected-warning {{implicit conversion turns literal floating-point number into integer}} + int y5 = 1.2222; // expected-warning {{implicit conversion from 'double' to 'int' changes value from 1.2222 to 1}} + int y6 = 12E-1; // expected-warning {{implicit conversion from 'double' to 'int' changes value from 1.2 to 1}} + int y7 = 1.23E1; // expected-warning {{implicit conversion from 'double' to 'int' changes value from 12.3 to 12}} + int y8 = (1.23E1); // expected-warning {{implicit conversion from 'double' to 'int' changes value from 12.3 to 12}} // Test assignment to an existing variable. - y8 = 2.22F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} + y8 = 2.22F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 2.22 to 2}} // Test direct initialization. - int y9(1.23F); // expected-warning {{implicit conversion turns literal floating-point number into integer}} + int y9(1.23F); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.23 to 1}} // Test passing a literal floating-point value to a function that takes an integer. - foo(1.2F); // expected-warning {{implicit conversion turns literal floating-point number into integer}} + foo(1.2F); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2 to 1}} - int y10 = -1.2F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} + int y10 = -1.2F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2 to 1}} - // -Wconversion-literal does NOT catch const values. + // -Wliteral-conversion does NOT catch const values. // (-Wconversion DOES catch them.) static const float sales_tax_rate = .095F; int z = sales_tax_rate; |

