1 // RUN: %clang_cc1 %s -fcxx-exceptions -fexceptions -fsyntax-only -verify -fblocks -Wunreachable-code -Wno-unused-value
3 int &halt() __attribute__((noreturn));
6 int liveti() throw(int);
7 int (*livetip)() throw(int);
35 dead(); // expected-warning {{will never be executed}}
41 --; // expected-warning {{will never be executed}}
42 // FIXME: The unreachable part is just the '?', but really all of this
43 // code is unreachable and shouldn't be separately reported.
44 halt() // expected-warning {{will never be executed}}
49 (halt()); // expected-warning {{will never be executed}}
57 halt(), foor()// expected-warning {{will never be executed}}
65 S &foonr() __attribute__((noreturn));
67 .mem; // expected-warning {{will never be executed}}
77 (halt()); // expected-warning {{will never be executed}}
80 // Don't warn about unreachable code in template instantiations, as
81 // they may only be unreachable in that specific instantiation.
84 template <typename T> void test_unreachable_templates() {
86 isUnreachable(); // no-warning
89 struct TestUnreachableA {
90 static void foo() __attribute__((noreturn));
92 struct TestUnreachableB {
96 void test_unreachable_templates_harness() {
97 test_unreachable_templates<TestUnreachableA>();
98 test_unreachable_templates<TestUnreachableB>();
101 // Do warn about explict template specializations, as they represent
102 // actual concrete functions that somebody wrote.
104 template <typename T> void funcToSpecialize() {}
105 template <> void funcToSpecialize<int>() {
107 dead(); // expected-warning {{will never be executed}}