summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-unreachable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCXX/warn-unreachable.cpp')
-rw-r--r--clang/test/SemaCXX/warn-unreachable.cpp19
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}}
}
-
OpenPOWER on IntegriCloud