From: Chris Lattner Date: Fri, 20 Mar 2009 15:44:26 +0000 (+0000) Subject: add a new LangOptions::GNUMode bit to distinguish between GNU99 and C99 etc. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e9c90b1a7402dfeca87980cb07e36bedc1a42b8;p=clang add a new LangOptions::GNUMode bit to distinguish between GNU99 and C99 etc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67374 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/clang.cpp b/Driver/clang.cpp index 1fd54d4b9e..c42d375882 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -622,9 +622,12 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, break; } + // GNUMode - Set if we're in gnu99, gnu89, gnucxx98, etc. + Options.GNUMode = LangStd >= lang_gnu_START; + if (Options.CPlusPlus) { Options.C99 = 0; - Options.HexFloats = (LangStd == lang_gnucxx98 || LangStd==lang_gnucxx0x); + Options.HexFloats = Options.GNUMode; } if (LangStd == lang_c89 || LangStd == lang_c94 || LangStd == lang_gnu89) @@ -634,15 +637,15 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs or -ansi // is specified, or -std is set to a conforming mode. - Options.Trigraphs = LangStd < lang_gnu_START; + Options.Trigraphs = !Options.GNUMode; if (Trigraphs.getPosition()) - Options.Trigraphs = Trigraphs; // Command line option wins. + Options.Trigraphs = Trigraphs; // Command line option wins if specified. // If in a conformant language mode (e.g. -std=c99) Blocks defaults to off // even if they are normally on for the target. In GNU modes (e.g. // -std=gnu99) the default for blocks depends on the target settings. // However, blocks are not turned off when compiling Obj-C or Obj-C++ code. - if (!Options.ObjC1 && LangStd < lang_gnu_START) + if (!Options.ObjC1 && !Options.GNUMode) Options.Blocks = 0; // Never accept '$' in identifiers when preprocessing assembler. diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index ee04439cad..b49d500470 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -26,6 +26,7 @@ public: unsigned BCPLComment : 1; // BCPL-style '//' comments. unsigned DollarIdents : 1; // '$' allowed in identifiers. unsigned AsmPreprocessor : 1; // Preprocessor in asm mode. + unsigned GNUMode : 1; // True in gnu99 mode false in c99 mode (etc) unsigned ImplicitInt : 1; // C89 implicit 'int'. unsigned Digraphs : 1; // C94, C99 and C++ unsigned HexFloats : 1; // C99 Hexadecimal float constants. @@ -71,7 +72,7 @@ public: LangOptions() { Trigraphs = BCPLComment = DollarIdents = AsmPreprocessor = 0; - ImplicitInt = Digraphs = 0; + GNUMode = ImplicitInt = Digraphs = 0; HexFloats = 0; GC = ObjC1 = ObjC2 = ObjCNonFragileABI = 0; C99 = Microsoft = CPlusPlus = CPlusPlus0x = NoExtensions = 0;