aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-04-12 17:49:18 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-04-12 17:49:18 +0000
commit99850388609234e01901e316bca6ca6ffbd09337 (patch)
treec302d6761773fc3b7ed18989a1188dcb1c3f2dc4 /lib/Sema/SemaExpr.cpp
parent5ce2827de3aa069a4796dea404c0679620581dbe (diff)
objective-c numeric literal: type of boolean is
that of typedef BOOL if found. // rdar://11231426 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154595 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 1711f356c6..7748b8c8a6 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -11259,6 +11259,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 ObjCBoolLiteralQT = Context.ObjCBuiltinBoolTy;
+ // signed char is the default type for boolean literals. Use 'BOOL'
+ // instead, if BOOL typedef is visible in its scope instead.
+ Decl *TD =
+ LookupSingleName(TUScope, &Context.Idents.get("BOOL"),
+ SourceLocation(), LookupOrdinaryName);
+ if (TypeDecl *BoolTD = dyn_cast_or_null<TypeDecl>(TD)) {
+ QualType QT = QualType(BoolTD->getTypeForDecl(), 0);
+ if (!QT.isNull())
+ ObjCBoolLiteralQT = QT;
+ }
+
return Owned(new (Context) ObjCBoolLiteralExpr(Kind == tok::kw___objc_yes,
- Context.ObjCBuiltinBoolTy, OpLoc));
+ ObjCBoolLiteralQT, OpLoc));
}