Index: include/clang/Lex/Preprocessor.h
===================================================================
--- include/clang/Lex/Preprocessor.h	(revision 130612)
+++ include/clang/Lex/Preprocessor.h	(working copy)
@@ -84,6 +84,7 @@
   IdentifierInfo *Ident_Pragma, *Ident__pragma;    // _Pragma, __pragma
   IdentifierInfo *Ident__VA_ARGS__;                // __VA_ARGS__
   IdentifierInfo *Ident__has_feature;              // __has_feature
+  IdentifierInfo *Ident__has_extension;            // __has_extension
   IdentifierInfo *Ident__has_builtin;              // __has_builtin
   IdentifierInfo *Ident__has_attribute;            // __has_attribute
   IdentifierInfo *Ident__has_include;              // __has_include
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp	(revision 130612)
+++ lib/Lex/PPMacroExpansion.cpp	(working copy)
@@ -85,6 +85,7 @@
 
   // Clang Extensions.
   Ident__has_feature      = RegisterBuiltinMacro(*this, "__has_feature");
+  Ident__has_extension    = RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin      = RegisterBuiltinMacro(*this, "__has_builtin");
   Ident__has_attribute    = RegisterBuiltinMacro(*this, "__has_attribute");
   Ident__has_include      = RegisterBuiltinMacro(*this, "__has_include");
@@ -525,7 +526,7 @@
 }
 
 
-/// HasFeature - Return true if we recognize and implement the specified feature
+/// HasFeature - Return true if we recognize and implement the feature
 /// specified by the identifier.
 static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
   const LangOptions &LangOpts = PP.getLangOptions();
@@ -550,12 +551,14 @@
            .Case("cxx_exceptions", LangOpts.Exceptions)
            .Case("cxx_rtti", LangOpts.RTTI)
            .Case("enumerator_attributes", true)
-           .Case("generic_selections", 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)
+           // C1X features
+           .Case("c_static_assert", LangOpts.C1X)
+           .Case("c_generic_selections", LangOpts.C1X)
            // C++0x features
            .Case("cxx_attributes", LangOpts.CPlusPlus0x)
            .Case("cxx_auto_type", LangOpts.CPlusPlus0x)
@@ -598,6 +601,16 @@
            .Default(false);
 }
 
+/// HasExtension - Return true if we recognize and implement the feature
+/// specified by the identifier as a language extension.
+static bool HasExtension(const IdentifierInfo *II) {
+  return llvm::StringSwitch<bool>(II->getName())
+  // C1X features
+  .Case("c_static_assert", true)
+  .Case("c_generic_selections", true)
+  .Default(false);
+}
+
 /// HasAttribute -  Return true if we recognize and implement the attribute
 /// specified by the given identifier.
 static bool HasAttribute(const IdentifierInfo *II) {
@@ -847,6 +860,7 @@
     OS << CounterValue++;
     Tok.setKind(tok::numeric_constant);
   } else if (II == Ident__has_feature ||
+             II == Ident__has_extension ||
              II == Ident__has_builtin ||
              II == Ident__has_attribute) {
     // The argument to these two builtins should be a parenthesized identifier.
@@ -876,9 +890,11 @@
     else if (II == Ident__has_builtin) {
       // Check for a builtin is trivial.
       Value = FeatureII->getBuiltinID() != 0;
-    } else if (II == Ident__has_attribute)
+    } else if (II == Ident__has_attribute) {
       Value = HasAttribute(FeatureII);
-    else {
+    } else if (II == Ident__has_extension) {
+      Value = HasExtension(FeatureII);
+    } else {
       assert(II == Ident__has_feature && "Must be feature check");
       Value = HasFeature(*this, FeatureII);
     }
Index: test/Lexer/has_feature_c1X.c
===================================================================
--- test/Lexer/has_feature_c1X.c	(revision 0)
+++ test/Lexer/has_feature_c1X.c	(revision 0)
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -E -std=c1x %s -o - | FileCheck --check-prefix=CHECK-1X %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-1X %s
+
+#if __has_feature(c_static_assert)
+int has_static_assert();
+#else
+int no_static_assert();
+#endif
+
+// CHECK-1X: has_static_assert
+// CHECK-NO-1X: no_static_assert
+
+#if __has_feature(c_generic_selections)
+int has_generic_selections();
+#else
+int no_generic_selections();
+#endif
+
+// CHECK-1X: has_generic_selections
+// CHECK-NO-1X: no_generic_selections

Property changes on: test/Lexer/has_feature_c1X.c
___________________________________________________________________
Added: svn:eol-style
   + native

Index: test/Lexer/has_extension.c
===================================================================
--- test/Lexer/has_extension.c	(revision 0)
+++ test/Lexer/has_extension.c	(revision 0)
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck %s
+
+// CHECK: c_static_assert
+#if __has_extension(c_static_assert)
+int c_static_assert();
+#endif
+
+// CHECK: c_generic_selections
+#if __has_extension(c_generic_selections)
+int c_generic_selections();
+#endif
+
+// CHECK: no_dummy_extension
+#if !__has_extension(dummy_extension)
+int no_dummy_extension();
+#endif

Property changes on: test/Lexer/has_extension.c
___________________________________________________________________
Added: svn:eol-style
   + native

