add a new LangOptions::GNUMode bit to distinguish between GNU99 and C99 etc.
authorChris Lattner <sabre@nondot.org>
Fri, 20 Mar 2009 15:44:26 +0000 (15:44 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 20 Mar 2009 15:44:26 +0000 (15:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67374 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/clang.cpp
include/clang/Basic/LangOptions.h

index 1fd54d4b9eeb8c919ef57bf6ece16e6dd592911f..c42d375882379ce0cd18525f6a7c7b87cc21c729 100644 (file)
@@ -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.
index ee04439cadd50c245ed26bf7929847d369fd8ed3..b49d500470775ff09f1a536bc77fa5a5979bcfd7 100644 (file)
@@ -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;