]> granicus.if.org Git - clang/commitdiff
Introduce __has_feature(attribute_unused_on_fields) to determine whether
authorDaniel Jasper <djasper@google.com>
Wed, 27 Jun 2012 05:12:34 +0000 (05:12 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 27 Jun 2012 05:12:34 +0000 (05:12 +0000)
the current version of clang understands __attribute__((unused)) on
fields.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159252 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPMacroExpansion.cpp
test/SemaCXX/warn-unused-member.cpp

index c6aabde03e0a657bb34c63edb493111510de7969..a46e31af4468e36ab11f9fff5f7b6b26cc2a055d 100644 (file)
@@ -632,6 +632,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
            .Case("attribute_objc_method_family", true)
            .Case("attribute_overloadable", true)
            .Case("attribute_unavailable_with_message", true)
+           .Case("attribute_unused_on_fields", true)
            .Case("blocks", LangOpts.Blocks)
            .Case("cxx_exceptions", LangOpts.Exceptions)
            .Case("cxx_rtti", LangOpts.RTTI)
index cabc9b6cd6a985ee37d31112f55f36b5c9d29808..6a7922e8e55d2365af406e9ba82dc478e9f37c45 100644 (file)
@@ -144,6 +144,13 @@ class EverythingUsed {
   int by_initializer_;
 };
 
+class HasFeatureTest {
+#if __has_feature(attribute_unused_on_fields)
+  int unused_; // expected-warning{{private field 'unused_' is not used}}
+  int unused2_ __attribute__((unused)); // no-warning
+#endif
+};
+
 namespace templates {
 class B {
   template <typename T> void f(T t);