aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Frontend/InitPreprocessor.cpp7
-rw-r--r--test/Lexer/has_feature_c1x.c9
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp
index 1f2f4256d3..d0a87bd888 100644
--- a/lib/Frontend/InitPreprocessor.cpp
+++ b/lib/Frontend/InitPreprocessor.cpp
@@ -286,7 +286,12 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("__STDC_HOSTED__");
if (!LangOpts.CPlusPlus) {
- if (LangOpts.C99)
+ // FIXME: C1x doesn't have a defined version number yet, so pick something
+ // that is the minimum possible according to their placeholder scheme
+ // 201ymmL.
+ if (LangOpts.C1X)
+ Builder.defineMacro("__STDC_VERSION__", "201001L");
+ else if (LangOpts.C99)
Builder.defineMacro("__STDC_VERSION__", "199901L");
else if (!LangOpts.GNUMode && LangOpts.Digraphs)
Builder.defineMacro("__STDC_VERSION__", "199409L");
diff --git a/test/Lexer/has_feature_c1x.c b/test/Lexer/has_feature_c1x.c
index ca4e9b95ad..a502f16ce3 100644
--- a/test/Lexer/has_feature_c1x.c
+++ b/test/Lexer/has_feature_c1x.c
@@ -27,3 +27,12 @@ int no_alignas();
// CHECK-1X: has_alignas
// CHECK-NO-1X: no_alignas
+
+#if __STDC_VERSION__ > 199901L
+int is_c1x();
+#else
+int is_not_c1x();
+#endif
+
+// CHECK-1X: is_c1x
+// CHECK-NO-1X: is_not_c1x