summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/warn-unreachable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/warn-unreachable.cpp')
-rw-r--r--test/SemaCXX/warn-unreachable.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-unreachable.cpp b/test/SemaCXX/warn-unreachable.cpp
index 604a3c0..f36300a 100644
--- a/test/SemaCXX/warn-unreachable.cpp
+++ b/test/SemaCXX/warn-unreachable.cpp
@@ -76,3 +76,34 @@ void test6() {
S
(halt()); // expected-warning {{will never be executed}}
}
+
+// Don't warn about unreachable code in template instantiations, as
+// they may only be unreachable in that specific instantiation.
+void isUnreachable();
+
+template <typename T> void test_unreachable_templates() {
+ T::foo();
+ isUnreachable(); // no-warning
+}
+
+struct TestUnreachableA {
+ static void foo() __attribute__((noreturn));
+};
+struct TestUnreachableB {
+ static void foo();
+};
+
+void test_unreachable_templates_harness() {
+ test_unreachable_templates<TestUnreachableA>();
+ test_unreachable_templates<TestUnreachableB>();
+}
+
+// Do warn about explict template specializations, as they represent
+// actual concrete functions that somebody wrote.
+
+template <typename T> void funcToSpecialize() {}
+template <> void funcToSpecialize<int>() {
+ halt();
+ dead(); // expected-warning {{will never be executed}}
+}
+
OpenPOWER on IntegriCloud