[cfe-commits] r159252 - in /cfe/trunk: lib/Lex/PPMacroExpansion.cpp test/SemaCXX/warn-unused-member.cpp

Daniel Jasper djasper at google.com
Tue Jun 26 22:12:34 PDT 2012


Author: djasper
Date: Wed Jun 27 00:12:34 2012
New Revision: 159252

URL: http://llvm.org/viewvc/llvm-project?rev=159252&view=rev
Log:
Introduce __has_feature(attribute_unused_on_fields) to determine whether
the current version of clang understands __attribute__((unused)) on
fields.

Modified:
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
    cfe/trunk/test/SemaCXX/warn-unused-member.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=159252&r1=159251&r2=159252&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Jun 27 00:12:34 2012
@@ -632,6 +632,7 @@
            .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)

Modified: cfe/trunk/test/SemaCXX/warn-unused-member.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-member.cpp?rev=159252&r1=159251&r2=159252&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-member.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-member.cpp Wed Jun 27 00:12:34 2012
@@ -144,6 +144,13 @@
   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);





More information about the cfe-commits mailing list