From 3a43d8df596a0af13379c3d2a78e2f7e7b156f30 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 13 Oct 2010 20:00:38 +0000 Subject: [PATCH] _Bool is not a keyword in C++. Fixes PR7388 and PR8349. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116422 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/TokenKinds.def | 3 ++- lib/Basic/IdentifierTable.cpp | 4 ++-- test/CodeGenObjC/ivar-layout-64-bitfields.m | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index f222eeaf70..14cb0f3a25 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -183,6 +183,7 @@ PUNCTUATOR(at, "@") // KEYC99 - This is a keyword introduced to C in C99 // 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. // KEYCXX0X - This is a C++ keyword introduced to C++ in C++0x // KEYGNU - This is a keyword if GNU extensions are enabled // KEYMS - This is a keyword if Microsoft extensions are enabled @@ -222,7 +223,7 @@ KEYWORD(unsigned , KEYALL) KEYWORD(void , KEYALL) KEYWORD(volatile , KEYALL) KEYWORD(while , KEYALL) -KEYWORD(_Bool , KEYNOMS) +KEYWORD(_Bool , KEYNOCXX) KEYWORD(_Complex , KEYALL) KEYWORD(_Imaginary , KEYALL) KEYWORD(__func__ , KEYALL) diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index 6b673e39d3..bd30c68da2 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/lib/Basic/IdentifierTable.cpp @@ -73,7 +73,7 @@ namespace { KEYMS = 32, BOOLSUPPORT = 64, KEYALTIVEC = 128, - KEYNOMS = 256, + KEYNOCXX = 256, KEYBORLAND = 512 }; } @@ -99,7 +99,7 @@ static void AddKeyword(llvm::StringRef Keyword, else if (LangOpts.Borland && (Flags & KEYBORLAND)) AddResult = 1; else if (LangOpts.Bool && (Flags & BOOLSUPPORT)) AddResult = 2; else if (LangOpts.AltiVec && (Flags & KEYALTIVEC)) AddResult = 2; - else if (!LangOpts.Microsoft && (Flags & KEYNOMS)) AddResult = 2; + else if (!LangOpts.CPlusPlus && (Flags & KEYNOCXX)) AddResult = 2; // Don't add this keyword if disabled in this language. if (AddResult == 0) return; diff --git a/test/CodeGenObjC/ivar-layout-64-bitfields.m b/test/CodeGenObjC/ivar-layout-64-bitfields.m index 9710e16172..700ce18d74 100644 --- a/test/CodeGenObjC/ivar-layout-64-bitfields.m +++ b/test/CodeGenObjC/ivar-layout-64-bitfields.m @@ -1,5 +1,10 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s // RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s + +#ifdef __cplusplus +typedef bool _Bool; +#endif + @interface I { struct { -- 2.40.0