On 13-04-16 09:18 AM, Rafael Espíndola wrote:
* Try to stay under 80 columns.
Yipes! Fixed.
* Avoid trailing white space.
* If possible, include the test into an existing generic test. Can you
add these to test/SemaCXX/warn-unused-filescoped.cpp?
Done.
And specific to this patch, I think FD->getCanonicalDecl will give you
the right answer for all kinds of FunctionDecl, no?
Ah. Brilliant. I've changed the code so that it always gets the storage
class from the canonical declaration, instead of having a separate check
for explicit specialization.
Thanks!
- ½
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp (revision 179592)
+++ lib/Sema/SemaDecl.cpp (working copy)
@@ -1218,8 +1218,11 @@
if (MD->isVirtual() || IsDisallowedCopyOrAssign(MD))
return false;
} else {
- // 'static inline' functions are used in headers; don't warn.
- if (FD->getStorageClass() == SC_Static &&
+ // 'static inline' functions are used in headers; don't warn.
+ // 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;
}
Index: test/SemaCXX/warn-unused-filescoped.cpp
===================================================================
--- test/SemaCXX/warn-unused-filescoped.cpp (revision 179592)
+++ test/SemaCXX/warn-unused-filescoped.cpp (working copy)
@@ -133,6 +133,27 @@
};
}
+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 {};
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits