aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-26 15:36:03 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-26 15:36:03 +0000
commitc78e259a5fafd889f5945bc2c48fea48cb3ef9d0 (patch)
treebe1c764635889d38ec3a6d0b599f8aa05ab6b90a
parent440a48318c53647d6416bcb1ff1af1452aa5d453 (diff)
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 :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124291 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Sema/Overload.h2
-rw-r--r--lib/Lex/PPMacroExpansion.cpp21
-rw-r--r--test/Lexer/has_feature_cxx0x.cpp37
3 files changed, 30 insertions, 30 deletions
diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h
index 4a7cb20e61..28fa561b1b 100644
--- a/include/clang/Sema/Overload.h
+++ b/include/clang/Sema/Overload.h
@@ -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;
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index cde5d22a75..47a35bd153 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -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);
}
diff --git a/test/Lexer/has_feature_cxx0x.cpp b/test/Lexer/has_feature_cxx0x.cpp
index 5d1d0b864c..46de712210 100644
--- a/test/Lexer/has_feature_cxx0x.cpp
+++ b/test/Lexer/has_feature_cxx0x.cpp
@@ -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