diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-16 15:21:30 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-16 15:21:30 +0000 |
| commit | 3c4a251ce8cc9c7aacc96949413bea3efcb21289 (patch) | |
| tree | 87f5c11657640b75dffc4addb75cc83486624f95 /clang | |
| parent | f6edda8c30524b64e859512f2ff3a01cc67c5ee9 (diff) | |
| download | bcm5719-llvm-3c4a251ce8cc9c7aacc96949413bea3efcb21289.tar.gz bcm5719-llvm-3c4a251ce8cc9c7aacc96949413bea3efcb21289.zip | |
Suppress unused warning on static inline function template specializations.
Patch by Halfdan Ingvarsson!
llvm-svn: 179598
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 5 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-unused-filescoped.cpp | 21 |
2 files changed, 25 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a17e9d0cdaf..c20b5ff068a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1219,7 +1219,10 @@ bool Sema::ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const { return false; } else { // 'static inline' functions are used in headers; don't warn. - if (FD->getStorageClass() == SC_Static && + // Make sure we get the storage class from the canonical declaration, + // since otherwise we will get spurious warnings on specialized + // static template functions. + if (FD->getCanonicalDecl()->getStorageClass() == SC_Static && FD->isInlineSpecified()) return false; } diff --git a/clang/test/SemaCXX/warn-unused-filescoped.cpp b/clang/test/SemaCXX/warn-unused-filescoped.cpp index e12668bf2a4..9fb601130d3 100644 --- a/clang/test/SemaCXX/warn-unused-filescoped.cpp +++ b/clang/test/SemaCXX/warn-unused-filescoped.cpp @@ -133,6 +133,27 @@ namespace test6 { }; } +namespace test7 +{ + template<typename T> + static inline void foo(T) { } + + // This should not emit an unused-function warning since it inherits + // the static storage type from the base template. + template<> + inline void foo(int) { } + + // Partial specialization + template<typename T, typename U> + static inline void bar(T, U) { } + + template<typename U> + inline void bar(int, U) { } + + template<> + inline void bar(int, int) { } +}; + namespace pr14776 { namespace { struct X {}; |

