diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-01-24 04:29:18 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-01-24 04:29:18 +0000 |
commit | 7e625b67e5f9bbee38634a07c11590c05e97a66f (patch) | |
tree | 54956d9c36150368f22b5bcb4d0f92365633f1b4 /clang/test/SemaCXX/warn-unreachable.cpp | |
parent | 50cfa12752a2e746668b8e27e465a743fabfc408 (diff) | |
download | bcm5719-llvm-7e625b67e5f9bbee38634a07c11590c05e97a66f.tar.gz bcm5719-llvm-7e625b67e5f9bbee38634a07c11590c05e97a66f.zip |
Simple hack to do unreachable code analysis on template patterns.
llvm-svn: 148774
Diffstat (limited to 'clang/test/SemaCXX/warn-unreachable.cpp')
-rw-r--r-- | clang/test/SemaCXX/warn-unreachable.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/warn-unreachable.cpp b/clang/test/SemaCXX/warn-unreachable.cpp index f36300af4d3..3d368759d7a 100644 --- a/clang/test/SemaCXX/warn-unreachable.cpp +++ b/clang/test/SemaCXX/warn-unreachable.cpp @@ -98,6 +98,24 @@ void test_unreachable_templates_harness() { test_unreachable_templates<TestUnreachableB>(); } +// Do warn about non-dependent unreachable code in templates +// Warn even if the template is never instantiated + +template<typename T> void test_non_dependent_unreachable_templates() { + TestUnreachableA::foo(); + isUnreachable(); // expected-warning {{will never be executed}} +} + +// Warn only once even if the template is instantiated multiple times + +template<typename T> void test_non_dependent_unreachable_templates2() { + TestUnreachableA::foo(); + isUnreachable(); // expected-warning {{will never be executed}} +} + +template void test_non_dependent_unreachable_templates2<int>(); +template void test_non_dependent_unreachable_templates2<long>(); + // Do warn about explict template specializations, as they represent // actual concrete functions that somebody wrote. @@ -106,4 +124,3 @@ template <> void funcToSpecialize<int>() { halt(); dead(); // expected-warning {{will never be executed}} } - |