]> granicus.if.org Git - clang/commitdiff
Clean up the C++0x __has_feature tests. Specifically:
authorDouglas Gregor <dgregor@apple.com>
Wed, 26 Jan 2011 15:36:03 +0000 (15:36 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 26 Jan 2011 15:36:03 +0000 (15:36 +0000)
  - 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 :)

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

include/clang/Sema/Overload.h
lib/Lex/PPMacroExpansion.cpp
test/Lexer/has_feature_cxx0x.cpp

index 4a7cb20e61464564cc85888a0c0f7d384ca8394c..28fa561b1bc0aadacb9e28c2efa9c37796e622b3 100644 (file)
@@ -130,7 +130,7 @@ namespace clang {
     /// 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;
index cde5d22a75827bd30165aaf8ad9a825c063b8cc8..47a35bd153c20e7823da0122df9b65676516fd7e 100644 (file)
@@ -540,26 +540,27 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
            .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);
 }
index 5d1d0b864c5512efaa5528539ce58e3b14586d7d..46de7122109b525bfa619ed56e58813dfcb8b145 100644 (file)
@@ -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 @@ int no_decltype();
 
 
 #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 @@ int no_static_assert();
 // 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