[cfe-commits] r124291 - in /cfe/trunk: include/clang/Sema/Overload.h lib/Lex/PPMacroExpansion.cpp test/Lexer/has_feature_cxx0x.cpp

Douglas Gregor dgregor at apple.com
Wed Jan 26 07:36:04 PST 2011


Author: dgregor
Date: Wed Jan 26 09:36:03 2011
New Revision: 124291

URL: http://llvm.org/viewvc/llvm-project?rev=124291&view=rev
Log:
Clean up the C++0x __has_feature tests. Specifically:
  - Don't publicize a C++0x feature through __has_feature if we aren't
    in C++0x mode (even if the feature is available only with a
    warning). 
  - "auto" is not implemented well enough for its __has_feature to be
    turned on.
  - Fix the test of C++0x __has_feature to actually test what we're
  trying to test. Searching for the substring "foo" when our options
  are "foo" and "no_foo" doesn't work :)

Modified:
    cfe/trunk/include/clang/Sema/Overload.h
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
    cfe/trunk/test/Lexer/has_feature_cxx0x.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=124291&r1=124290&r2=124291&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Wed Jan 26 09:36:03 2011
@@ -130,7 +130,7 @@
     /// Third - The third conversion can be a qualification conversion.
     ImplicitConversionKind Third : 8;
 
-    /// Deprecated - Whether this the deprecated conversion of a
+    /// \brief Whether this is the deprecated conversion of a
     /// string literal to a pointer to non-const character data
     /// (C++ 4.2p2).
     unsigned DeprecatedStringLiteralToCharPtr : 1;

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=124291&r1=124290&r2=124291&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Jan 26 09:36:03 2011
@@ -540,26 +540,27 @@
            .Case("attribute_overloadable", true)
            .Case("attribute_unavailable_with_message", true)
            .Case("blocks", LangOpts.Blocks)
-           .Case("cxx_attributes", LangOpts.CPlusPlus0x)
-           .Case("cxx_auto_type", LangOpts.CPlusPlus0x)
-           .Case("cxx_decltype", LangOpts.CPlusPlus0x)
-           .Case("cxx_deleted_functions", true) // Accepted as an extension.
            .Case("cxx_exceptions", LangOpts.Exceptions)
            .Case("cxx_rtti", LangOpts.RTTI)
-           .Case("cxx_strong_enums", LangOpts.CPlusPlus0x)
-           .Case("cxx_static_assert", LangOpts.CPlusPlus0x)
-           .Case("cxx_trailing_return", LangOpts.CPlusPlus0x)
            .Case("enumerator_attributes", true)
            .Case("objc_nonfragile_abi", LangOpts.ObjCNonFragileABI)
            .Case("objc_weak_class", LangOpts.ObjCNonFragileABI)
            .Case("ownership_holds", true)
            .Case("ownership_returns", true)
            .Case("ownership_takes", true)
-           .Case("cxx_inline_namespaces", LangOpts.CPlusPlus)
+           // C++0x features
+           .Case("cxx_attributes", LangOpts.CPlusPlus0x)
+         //.Case("cxx_auto_type", false)
+           .Case("cxx_decltype", LangOpts.CPlusPlus0x)
+           .Case("cxx_deleted_functions", LangOpts.CPlusPlus0x)
+           .Case("cxx_inline_namespaces", LangOpts.CPlusPlus0x)
          //.Case("cxx_lambdas", false)
          //.Case("cxx_nullptr", false)
-           .Case("cxx_rvalue_references", LangOpts.CPlusPlus)
-           .Case("cxx_variadic_templates", LangOpts.CPlusPlus)
+           .Case("cxx_rvalue_references", LangOpts.CPlusPlus0x)
+           .Case("cxx_strong_enums", LangOpts.CPlusPlus0x)
+           .Case("cxx_static_assert", LangOpts.CPlusPlus0x)
+           .Case("cxx_trailing_return", LangOpts.CPlusPlus0x)
+           .Case("cxx_variadic_templates", LangOpts.CPlusPlus0x)
            .Case("tls", PP.getTargetInfo().isTLSSupported())
            .Default(false);
 }

Modified: cfe/trunk/test/Lexer/has_feature_cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_cxx0x.cpp?rev=124291&r1=124290&r2=124291&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/has_feature_cxx0x.cpp (original)
+++ cfe/trunk/test/Lexer/has_feature_cxx0x.cpp Wed Jan 26 09:36:03 2011
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-0X %s
 
 #if __has_feature(cxx_lambdas)
-int lambdas();
+int has_lambdas();
 #else
 int no_lambdas();
 #endif
@@ -32,22 +32,23 @@
 
 
 #if __has_feature(cxx_auto_type)
-int auto_type();
+int has_auto_type();
 #else
 int no_auto_type();
 #endif
 
-// CHECK-0X: auto_type
+// FIXME: We don't implement "auto" well enough to turn on this feature test
+// CHECK-0X: no_auto_type
 // CHECK-NO-0X: no_auto_type
 
 
 #if __has_feature(cxx_attributes)
-int attributes();
+int has_attributes();
 #else
 int no_attributes();
 #endif
 
-// CHECK-0X: attributes
+// CHECK-0X: has_attributes
 // CHECK-NO-0X: no_attributes
 
 
@@ -60,43 +61,41 @@
 // CHECK-0X: has_static_assert
 // CHECK-NO-0X: no_static_assert
 
-// We accept this as an extension.
 #if __has_feature(cxx_deleted_functions)
-int deleted_functions();
+int has_deleted_functions();
 #else
 int no_deleted_functions();
 #endif
 
-// CHECK-0X: deleted_functions
-// CHECK-NO-0X: deleted_functions
+// CHECK-0X: has_deleted_functions
+// CHECK-NO-0X: no_deleted_functions
 
 
 #if __has_feature(cxx_rvalue_references)
-int rvalue_references();
+int has_rvalue_references();
 #else
 int no_rvalue_references();
 #endif
 
-// CHECK-0X: rvalue_references
-// CHECK-NO-0X: rvalue_references
+// CHECK-0X: has_rvalue_references
+// CHECK-NO-0X: no_rvalue_references
 
 
 #if __has_feature(cxx_variadic_templates)
-int variadic_templates();
+int has_variadic_templates();
 #else
 int no_variadic_templates();
 #endif
 
-// CHECK-0X: variadic_templates
-// Note: We allow variadic templates in C++98/03 with a warning.
-// CHECK-NO-0X: variadic_templates
+// CHECK-0X: has_variadic_templates
+// CHECK-NO-0X: no_variadic_templates
 
 
 #if __has_feature(cxx_inline_namespaces)
-int inline_namespaces();
+int has_inline_namespaces();
 #else
 int no_inline_namespaces();
 #endif
 
-// CHECK-0X: inline_namespaces
-// CHECK-NO-0X: inline_namespaces
+// CHECK-0X: has_inline_namespaces
+// CHECK-NO-0X: no_inline_namespaces





More information about the cfe-commits mailing list