summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2011-07-15 00:00:51 +0000
committerRichard Trieu <rtrieu@google.com>2011-07-15 00:00:51 +0000
commitcfe3926ae99e2db2452c036aba330f3e698d2b7f (patch)
tree6da68793430e4f44b178ac58adf9efb7d324bfae /clang/test
parente625325d9f920e49e18e6aef47b05e87405b7717 (diff)
downloadbcm5719-llvm-cfe3926ae99e2db2452c036aba330f3e698d2b7f.tar.gz
bcm5719-llvm-cfe3926ae99e2db2452c036aba330f3e698d2b7f.zip
Remove warnings of constant operands of logical operators from template instantiations. Upon instantiation of template, value-dependent parameters are replaced by equivalent literals, so code like:
template<unsigned int A, unsigned int B> struct S { int foo() { int x = A && B; } } will not warn on A && B on every instantiation. This will still warn on other cases inside templates, which will be caught on checking the template definition. llvm-svn: 135222
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/expressions.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/expressions.cpp b/clang/test/SemaCXX/expressions.cpp
index 95ece48e51f..8a294face38 100644
--- a/clang/test/SemaCXX/expressions.cpp
+++ b/clang/test/SemaCXX/expressions.cpp
@@ -63,3 +63,25 @@ int test2(int x) {
return x && (-1); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
return x && (5); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
}
+
+template<unsigned int A, unsigned int B> struct S
+{
+ enum {
+ e1 = A && B,
+ e2 = A && 7 // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ };
+
+ int foo() {
+ int x = A && B;
+ int y = B && 3; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+
+ return x + y;
+ }
+};
+
+void test3() {
+ S<5, 8> s1;
+ S<2, 7> s2;
+ (void)s1.foo();
+ (void)s2.foo();
+}
OpenPOWER on IntegriCloud