summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-20 15:44:26 +0000
committerChris Lattner <sabre@nondot.org>2009-03-20 15:44:26 +0000
commit91d63d1248370198919041239d1bf439c10b5e10 (patch)
treea1dee1d36cfbdd2ef2c2d53857041a8c07223f7d
parent4655d731e129902af1061e4cc9d6888a04a16d12 (diff)
downloadbcm5719-llvm-91d63d1248370198919041239d1bf439c10b5e10.tar.gz
bcm5719-llvm-91d63d1248370198919041239d1bf439c10b5e10.zip
add a new LangOptions::GNUMode bit to distinguish between GNU99 and C99 etc.
llvm-svn: 67374
-rw-r--r--clang/Driver/clang.cpp11
-rw-r--r--clang/include/clang/Basic/LangOptions.h3
2 files changed, 9 insertions, 5 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 1fd54d4b9ee..c42d3758823 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/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/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index ee04439cadd..b49d5004707 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/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;
OpenPOWER on IntegriCloud