diff options
author | John McCall <rjmccall@apple.com> | 2010-05-18 03:19:21 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-05-18 03:19:21 +0000 |
commit | d3dfbd6f4fd79a6a5626bb8ae9990964ae6979b7 (patch) | |
tree | c35cfa65091adba5d427aee075037bd4cb289b28 /clang/test/SemaCXX/switch.cpp | |
parent | 34c3b52a2ccb798d8e80556122dc358be102b72e (diff) | |
download | bcm5719-llvm-d3dfbd6f4fd79a6a5626bb8ae9990964ae6979b7.tar.gz bcm5719-llvm-d3dfbd6f4fd79a6a5626bb8ae9990964ae6979b7.zip |
If a switch condition is constant, don't warn about missing enum cases.
If a switch condition is constant, warn if there's no case for it.
Constant switch conditions do come up in reasonable template code.
llvm-svn: 104010
Diffstat (limited to 'clang/test/SemaCXX/switch.cpp')
-rw-r--r-- | clang/test/SemaCXX/switch.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/switch.cpp b/clang/test/SemaCXX/switch.cpp index c256960af1d..fc13630bbf1 100644 --- a/clang/test/SemaCXX/switch.cpp +++ b/clang/test/SemaCXX/switch.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum %s void test() { bool x = true; @@ -40,3 +40,20 @@ void x3(C &c) { switch (c) { // expected-error{{incomplete class type}} } } + +namespace test3 { + enum En { A, B, C }; + template <En how> void foo() { + int x = 0, y = 5; + + switch (how) { //expected-warning {{no case matching constant switch condition '2'}} + case A: x *= y; break; + case B: x += y; break; + // No case for C, but it's okay because we have a constant condition. + } + } + + template void foo<A>(); + template void foo<B>(); + template void foo<C>(); //expected-note {{in instantiation}} +} |