diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-10-10 18:15:57 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-10-10 18:15:57 +0000 |
commit | 0de5720737f1d4a9399577cad470fc55b6059c52 (patch) | |
tree | 5add7ac66dc838cddc5af0fdf34be83433378785 /clang/test/SemaCXX | |
parent | 6ce53ae7526823734e6d3a3088f5ce72830baa7d (diff) | |
download | bcm5719-llvm-0de5720737f1d4a9399577cad470fc55b6059c52.tar.gz bcm5719-llvm-0de5720737f1d4a9399577cad470fc55b6059c52.zip |
Don't suggest 'noreturn' for function template instantiations, because
it might be wrong for other instantiations of the same function
template. Fixes PR10801.
llvm-svn: 141559
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r-- | clang/test/SemaCXX/warn-missing-noreturn.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/clang/test/SemaCXX/warn-missing-noreturn.cpp b/clang/test/SemaCXX/warn-missing-noreturn.cpp index ac568a5d81c..8072ac6b824 100644 --- a/clang/test/SemaCXX/warn-missing-noreturn.cpp +++ b/clang/test/SemaCXX/warn-missing-noreturn.cpp @@ -1,27 +1,27 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -Wmissing-noreturn -Wreturn-type void f() __attribute__((noreturn)); -template<typename T> void g(T) { // expected-warning {{function 'g<int>' could be declared with attribute 'noreturn'}} +template<typename T> void g(T) { f(); } -template void g<int>(int); // expected-note {{in instantiation of function template specialization 'g<int>' requested here}} +template void g<int>(int); template<typename T> struct A { - void g() { // expected-warning {{function 'g' could be declared with attribute 'noreturn'}} + void g() { f(); } }; -template struct A<int>; // expected-note {{in instantiation of member function 'A<int>::g' requested here}} +template struct A<int>; struct B { - template<typename T> void g(T) { // expected-warning {{function 'g<int>' could be declared with attribute 'noreturn'}} + template<typename T> void g(T) { f(); } }; -template void B::g<int>(int); // expected-note {{in instantiation of function template specialization 'B::g<int>' requested here}} +template void B::g<int>(int); // We don't want a warning here. struct X { @@ -103,3 +103,23 @@ rdar8875247_B test_rdar8875247_B() { return f; } // no-warning +namespace PR10801 { + struct Foo { + void wibble() __attribute((__noreturn__)); + }; + + struct Bar { + void wibble(); + }; + + template <typename T> void thingy(T thing) { + thing.wibble(); + } + + void test() { + Foo f; + Bar b; + thingy(f); + thingy(b); + } +} |