aaron.ballman updated this revision to Diff 125407.
aaron.ballman added a comment.

Rebased on ToT and given more context.


https://reviews.llvm.org/D40225

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Frontend/LangStandard.h
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/unknown-std.c

Index: test/Driver/unknown-std.c
===================================================================
--- test/Driver/unknown-std.c
+++ test/Driver/unknown-std.c
@@ -14,6 +14,8 @@
 // CHECK-NEXT: note: use 'gnu99' for 'ISO C 1999 with GNU extensions' standard
 // CHECK-NEXT: note: use 'c11' or 'iso9899:2011' for 'ISO C 2011' standard
 // CHECK-NEXT: note: use 'gnu11' for 'ISO C 2011 with GNU extensions' standard
+// CHECK-NEXT: note: use 'c17' or 'iso9899:2017' for 'ISO C 2017' standard
+// CHECK-NEXT: note: use 'gnu17' for 'ISO C 2017 with GNU extensions' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}
Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -370,7 +370,9 @@
     Builder.defineMacro("__STDC_HOSTED__");
 
   if (!LangOpts.CPlusPlus) {
-    if (LangOpts.C11)
+    if (LangOpts.C17)
+      Builder.defineMacro("__STDC_VERSION__", "201710L");
+    else if (LangOpts.C11)
       Builder.defineMacro("__STDC_VERSION__", "201112L");
     else if (LangOpts.C99)
       Builder.defineMacro("__STDC_VERSION__", "199901L");
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1745,6 +1745,7 @@
   Opts.LineComment = Std.hasLineComments();
   Opts.C99 = Std.isC99();
   Opts.C11 = Std.isC11();
+  Opts.C17 = Std.isC17();
   Opts.CPlusPlus = Std.isCPlusPlus();
   Opts.CPlusPlus11 = Std.isCPlusPlus11();
   Opts.CPlusPlus14 = Std.isCPlusPlus14();
Index: include/clang/Frontend/LangStandards.def
===================================================================
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -77,6 +77,15 @@
              LineComment | C99 | C11 | Digraphs | GNUMode | HexFloat)
 LANGSTANDARD_ALIAS_DEPR(gnu11, "gnu1x")
 
+// C17 modes
+LANGSTANDARD(c17, "c17",
+             C, "ISO C 2017",
+             LineComment | C99 | C11 | C17 | Digraphs | HexFloat)
+LANGSTANDARD_ALIAS(c17, "iso9899:2017")
+LANGSTANDARD(gnu17, "gnu17",
+             C, "ISO C 2017 with GNU extensions",
+             LineComment | C99 | C11 | C17 | Digraphs | GNUMode | HexFloat)
+
 // C++ modes
 LANGSTANDARD(cxx98, "c++98",
              CXX, "ISO C++ 1998 with amendments",
Index: include/clang/Frontend/LangStandard.h
===================================================================
--- include/clang/Frontend/LangStandard.h
+++ include/clang/Frontend/LangStandard.h
@@ -22,16 +22,17 @@
   LineComment = (1 << 0),
   C99 = (1 << 1),
   C11 = (1 << 2),
-  CPlusPlus = (1 << 3),
-  CPlusPlus11 = (1 << 4),
-  CPlusPlus14 = (1 << 5),
-  CPlusPlus17 = (1 << 6),
-  CPlusPlus2a = (1 << 7),
-  Digraphs = (1 << 8),
-  GNUMode = (1 << 9),
-  HexFloat = (1 << 10),
-  ImplicitInt = (1 << 11),
-  OpenCL = (1 << 12)
+  C17 = (1 << 3),
+  CPlusPlus = (1 << 4),
+  CPlusPlus11 = (1 << 5),
+  CPlusPlus14 = (1 << 6),
+  CPlusPlus17 = (1 << 7),
+  CPlusPlus2a = (1 << 8),
+  Digraphs = (1 << 9),
+  GNUMode = (1 << 10),
+  HexFloat = (1 << 11),
+  ImplicitInt = (1 << 12),
+  OpenCL = (1 << 13)
 };
 
 }
@@ -70,6 +71,9 @@
   /// isC11 - Language is a superset of C11.
   bool isC11() const { return Flags & frontend::C11; }
 
+  /// isC17 - Language is a superset of C17.
+  bool isC17() const { return Flags & frontend::C17; }
+
   /// isCPlusPlus - Language is a C++ variant.
   bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
 
Index: include/clang/Basic/LangOptions.def
===================================================================
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -82,6 +82,7 @@
 // FIXME: A lot of the BENIGN_ options should be COMPATIBLE_ instead.
 LANGOPT(C99               , 1, 0, "C99")
 LANGOPT(C11               , 1, 0, "C11")
+LANGOPT(C17               , 1, 0, "C17")
 LANGOPT(MSVCCompat        , 1, 0, "Microsoft Visual C++ full compatibility mode")
 LANGOPT(MicrosoftExt      , 1, 0, "Microsoft C++ extensions")
 LANGOPT(AsmBlocks         , 1, 0, "Microsoft inline asm blocks")
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to