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(C2x , 1, 0, "C2x") 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") Index: include/clang/Frontend/LangStandard.h =================================================================== --- include/clang/Frontend/LangStandard.h +++ include/clang/Frontend/LangStandard.h @@ -22,14 +22,15 @@ C89 = (1 << 1), C99 = (1 << 2), C11 = (1 << 3), - CPlusPlus = (1 << 4), - CPlusPlus11 = (1 << 5), - CPlusPlus14 = (1 << 6), - CPlusPlus1z = (1 << 7), - Digraphs = (1 << 8), - GNUMode = (1 << 9), - HexFloat = (1 << 10), - ImplicitInt = (1 << 11) + C2x = (1 << 4), + CPlusPlus = (1 << 5), + CPlusPlus11 = (1 << 6), + CPlusPlus14 = (1 << 7), + CPlusPlus1z = (1 << 8), + Digraphs = (1 << 9), + GNUMode = (1 << 10), + HexFloat = (1 << 11), + ImplicitInt = (1 << 12) }; } @@ -67,6 +68,9 @@ /// isC11 - Language is a superset of C11. bool isC11() const { return Flags & frontend::C11; } + /// isC2x - Language is a superset of C2x. + bool isC2x() const { return Flags & frontend::C2x; } + /// isCPlusPlus - Language is a C++ variant. bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; } Index: include/clang/Frontend/LangStandards.def =================================================================== --- include/clang/Frontend/LangStandards.def +++ include/clang/Frontend/LangStandards.def @@ -91,6 +91,11 @@ "ISO C 2011 with GNU extensions", LineComment | C99 | C11 | Digraphs | GNUMode | HexFloat) +// C2X modes +LANGSTANDARD(c2x, "c2x", + "Working draft for ISO C 202x", + LineComment | C99 | C11 | C2x | Digraphs | HexFloat) + // C++ modes LANGSTANDARD(cxx98, "c++98", "ISO C++ 1998 with amendments", Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -1535,6 +1535,7 @@ Opts.LineComment = Std.hasLineComments(); Opts.C99 = Std.isC99(); Opts.C11 = Std.isC11(); + Opts.C2x = Std.isC2x(); Opts.CPlusPlus = Std.isCPlusPlus(); Opts.CPlusPlus11 = Std.isCPlusPlus11(); Opts.CPlusPlus14 = Std.isCPlusPlus14(); Index: test/Driver/clang_std_c.c =================================================================== --- test/Driver/clang_std_c.c +++ test/Driver/clang_std_c.c @@ -0,0 +1,7 @@ +/* Test various -std driver options for C. */ +// RUN: %clang -std=c11 -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: %clang -std=c2x -fsyntax-only %s 2>&1 | FileCheck %s + +// CHECK-NOT: invalid value 'c11' in '-std=c11' +// CHECK-NOT: invalid value 'c2x' in '-std=c2x' +