aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-08-30 18:49:41 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-08-30 18:49:41 +0000
commit961713055e636170da59d7006a878cb4ba518a5d (patch)
tree5e0e10cc514784fea4a1c5321f61e89feda76bfc /lib/Sema/SemaExpr.cpp
parentc30981a563a8947cb26b1e308d122fa2ef90fceb (diff)
objective-C: clang must implicitly convert
__objc_yes/__objc_no to (BOOL)1/(BOOL)0 when BOOL is declared; otherwise it resorts to default of 'signed char'. This is important to selecting the correct Numeric API numberWithBool: Can't have a clang test for this. Will checkin and executable llvm test. // rdar://12156616 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162922 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 2706ae43da..f2e6070539 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -11771,6 +11771,18 @@ ExprResult
Sema::ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind) {
assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
"Unknown Objective-C Boolean value!");
+ QualType BoolT = Context.ObjCBuiltinBoolTy;
+ if (!Context.getBOOLDecl()) {
+ LookupResult Result(*this, &Context.Idents.get("BOOL"), SourceLocation(),
+ Sema::LookupOrdinaryName);
+ if (LookupName(Result, getCurScope())) {
+ NamedDecl *ND = Result.getFoundDecl();
+ if (TypedefDecl *TD = dyn_cast<TypedefDecl>(ND))
+ Context.setBOOLDecl(TD);
+ }
+ }
+ if (Context.getBOOLDecl())
+ BoolT = Context.getBOOLType();
return Owned(new (Context) ObjCBoolLiteralExpr(Kind == tok::kw___objc_yes,
- Context.ObjCBuiltinBoolTy, OpLoc));
+ BoolT, OpLoc));
}