diff options
-rw-r--r-- | compilerplugins/clang/test/unusedmember.cxx | 29 | ||||
-rw-r--r-- | compilerplugins/clang/unusedmember.cxx | 4 |
2 files changed, 33 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/unusedmember.cxx b/compilerplugins/clang/test/unusedmember.cxx index a495b786919e..90f3051b98ee 100644 --- a/compilerplugins/clang/test/unusedmember.cxx +++ b/compilerplugins/clang/test/unusedmember.cxx @@ -7,6 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <cstddef> + namespace Enum { namespace @@ -223,6 +225,31 @@ void f() } } +namespace Offsetof +{ +namespace +{ +struct S +{ + int i; +}; +} +void f() { (void)offsetof(S, i); } +} + +namespace OffsetofTemplate +{ +namespace +{ +template <typename> struct S +{ + int i; +}; +template <typename T> void f1() { (void)offsetof(T, i); } +} +void f() { f1<S<void>>(); } +} + int main() { (void)&Enum::f; @@ -233,6 +260,8 @@ int main() (void)&Aligned::f; (void)&Bases::f; (void)&Unnamed::f; + (void)&Offsetof::f; + (void)&OffsetofTemplate::f; } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/compilerplugins/clang/unusedmember.cxx b/compilerplugins/clang/unusedmember.cxx index 7ee433ca2387..9cf40d721259 100644 --- a/compilerplugins/clang/unusedmember.cxx +++ b/compilerplugins/clang/unusedmember.cxx @@ -220,6 +220,10 @@ public: return true; } auto const t1 = expr->getTypeSourceInfo()->getType(); + if (t1->isTemplateTypeParmType()) + { + return true; + } RecordDecl const* d; if (auto const t2 = t1->getAs<InjectedClassNameType>()) { |