From 7e7fbd05a5dfdb0addfc8b5af2fcbed8c7b5fb87 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 15 Apr 2011 00:35:23 +0000 Subject: [PATCH] C1X: add a language standard git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129553 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticFrontendKinds.td | 3 +++ include/clang/Basic/LangOptions.h | 3 ++- include/clang/Basic/TokenKinds.def | 1 + include/clang/Frontend/LangStandard.h | 16 ++++++++++------ include/clang/Frontend/LangStandards.def | 12 ++++++++++++ lib/Basic/IdentifierTable.cpp | 4 +++- lib/Frontend/CompilerInvocation.cpp | 1 + lib/Serialization/ASTReader.cpp | 2 ++ lib/Serialization/ASTWriter.cpp | 1 + 9 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index d93502c774..ebd42b329a 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -115,6 +115,9 @@ def warn_pch_target_triple : Error< def warn_pch_c99 : Error< "C99 support was %select{disabled|enabled}0 in PCH file but is " "currently %select{disabled|enabled}1">; +def warn_pch_c1x : Error< + "C1X support was %select{disabled|enabled}0 in PCH file but is " + "currently %select{disabled|enabled}1">; def warn_pch_cplusplus : Error< "C++ support was %select{disabled|enabled}0 in PCH file but is " "currently %select{disabled|enabled}1">; diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index beafdba3c9..3a739eaf4a 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -34,6 +34,7 @@ public: unsigned Digraphs : 1; // C94, C99 and C++ unsigned HexFloats : 1; // C99 Hexadecimal float constants. unsigned C99 : 1; // C99 Support + unsigned C1X : 1; // C1X Support unsigned Microsoft : 1; // Microsoft extensions. unsigned Borland : 1; // Borland extensions. unsigned CPlusPlus : 1; // C++ Support @@ -170,7 +171,7 @@ public: AppleKext = 0; ObjCDefaultSynthProperties = 0; NoConstantCFStrings = 0; InlineVisibilityHidden = 0; - C99 = Microsoft = Borland = CPlusPlus = CPlusPlus0x = 0; + C99 = C1X = Microsoft = Borland = CPlusPlus = CPlusPlus0x = 0; CXXOperatorNames = PascalStrings = WritableStrings = ConstStrings = 0; Exceptions = ObjCExceptions = CXXExceptions = SjLjExceptions = 0; TraditionalCPP = Freestanding = NoBuiltin = 0; diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index c446d6a626..d7d436c92c 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -190,6 +190,7 @@ PUNCTUATOR(greatergreatergreater, ">>>") // is a keyword in the implementation namespace that should // always be treated as a keyword // KEYC99 - This is a keyword introduced to C in C99 +// KEYC1X - This is a keyword introduced to C in C1X // KEYCXX - This is a C++ keyword, or a C++-specific keyword in the // implementation namespace // KEYNOCXX - This is a keyword in every non-C++ dialect. diff --git a/include/clang/Frontend/LangStandard.h b/include/clang/Frontend/LangStandard.h index 441d34f5a3..74ca5191dd 100644 --- a/include/clang/Frontend/LangStandard.h +++ b/include/clang/Frontend/LangStandard.h @@ -19,12 +19,13 @@ namespace frontend { enum LangFeatures { BCPLComment = (1 << 0), C99 = (1 << 1), - CPlusPlus = (1 << 2), - CPlusPlus0x = (1 << 3), - Digraphs = (1 << 4), - GNUMode = (1 << 5), - HexFloat = (1 << 6), - ImplicitInt = (1 << 7) + C1X = (1 << 2), + CPlusPlus = (1 << 3), + CPlusPlus0x = (1 << 4), + Digraphs = (1 << 5), + GNUMode = (1 << 6), + HexFloat = (1 << 7), + ImplicitInt = (1 << 8) }; } @@ -56,6 +57,9 @@ public: /// isC99 - Language is a superset of C99. bool isC99() const { return Flags & frontend::C99; } + /// isC1X - Language is a superset of C1X. + bool isC1X() const { return Flags & frontend::C1X; } + /// isCPlusPlus - Language is a C++ variant. bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; } diff --git a/include/clang/Frontend/LangStandards.def b/include/clang/Frontend/LangStandards.def index 06df563c6d..586e5c8fa2 100644 --- a/include/clang/Frontend/LangStandards.def +++ b/include/clang/Frontend/LangStandards.def @@ -59,6 +59,18 @@ LANGSTANDARD(gnu9x, "gnu9x", "ISO C 1999 with GNU extensions", BCPLComment | C99 | Digraphs | GNUMode | HexFloat) +// C1X modes +LANGSTANDARD(c1x, "c1x", + "ISO C 201X", + BCPLComment | C99 | C1X | Digraphs | HexFloat) +LANGSTANDARD(iso9899_201x, + "iso9899:201x", "ISO C 201X", + BCPLComment | C99 | C1X | Digraphs | HexFloat) + +LANGSTANDARD(gnu1x, "gnu1x", + "ISO C 201X with GNU extensions", + BCPLComment | C99 | C1X | Digraphs | GNUMode | HexFloat) + // C++ modes LANGSTANDARD(cxx98, "c++98", "ISO C++ 1998 with amendments", diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index 3d08bf807e..bbea23ab8d 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/lib/Basic/IdentifierTable.cpp @@ -91,7 +91,8 @@ namespace { KEYNOCXX = 0x80, KEYBORLAND = 0x100, KEYOPENCL = 0x200, - KEYALL = 0x3ff + KEYC1X = 0x400, + KEYALL = 0x7ff }; } @@ -118,6 +119,7 @@ static void AddKeyword(llvm::StringRef Keyword, else if (LangOpts.AltiVec && (Flags & KEYALTIVEC)) AddResult = 2; else if (LangOpts.OpenCL && (Flags & KEYOPENCL)) AddResult = 2; else if (!LangOpts.CPlusPlus && (Flags & KEYNOCXX)) AddResult = 2; + else if (LangOpts.C1X && (Flags & KEYC1X)) AddResult = 2; // Don't add this keyword if disabled in this language. if (AddResult == 0) return; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 00418967fe..3dd1be93de 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1335,6 +1335,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd); Opts.BCPLComment = Std.hasBCPLComments(); Opts.C99 = Std.isC99(); + Opts.C1X = Std.isC1X(); Opts.CPlusPlus = Std.isCPlusPlus(); Opts.CPlusPlus0x = Std.isCPlusPlus0x(); Opts.Digraphs = Std.hasDigraphs(); diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index a7c3fea7d6..66b4890d2a 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -79,6 +79,7 @@ PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts) { PARSE_LANGOPT_BENIGN(Digraphs); PARSE_LANGOPT_BENIGN(HexFloats); PARSE_LANGOPT_IMPORTANT(C99, diag::warn_pch_c99); + PARSE_LANGOPT_IMPORTANT(C1X, diag::warn_pch_c1x); PARSE_LANGOPT_IMPORTANT(Microsoft, diag::warn_pch_microsoft_extensions); PARSE_LANGOPT_BENIGN(MSCVersion); PARSE_LANGOPT_IMPORTANT(CPlusPlus, diag::warn_pch_cplusplus); @@ -2799,6 +2800,7 @@ bool ASTReader::ParseLanguageOptions( PARSE_LANGOPT(Digraphs); PARSE_LANGOPT(HexFloats); PARSE_LANGOPT(C99); + PARSE_LANGOPT(C1X); PARSE_LANGOPT(Microsoft); PARSE_LANGOPT(CPlusPlus); PARSE_LANGOPT(CPlusPlus0x); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 85b5326da9..d6a9a95ea4 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1007,6 +1007,7 @@ void ASTWriter::WriteLanguageOptions(const LangOptions &LangOpts) { Record.push_back(LangOpts.Digraphs); // C94, C99 and C++ Record.push_back(LangOpts.HexFloats); // C99 Hexadecimal float constants. Record.push_back(LangOpts.C99); // C99 Support + Record.push_back(LangOpts.C1X); // C1X Support Record.push_back(LangOpts.Microsoft); // Microsoft extensions. // LangOpts.MSCVersion is ignored because all it does it set a macro, which is // already saved elsewhere. -- 2.40.0