summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
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
commit30c3de97a93609ce6cba3ee2f160dedc7d9d77d9 (patch)
treed0c42de16d3946049dedfb362c81aa976c3b0d38 /clang/lib/Sema
parent6f3e5ad704a5c0e662882b42f13968d89c5ff19d (diff)
downloadbcm5719-llvm-30c3de97a93609ce6cba3ee2f160dedc7d9d77d9.tar.gz
bcm5719-llvm-30c3de97a93609ce6cba3ee2f160dedc7d9d77d9.zip
objective-c numeric literal: type of boolean is
that of typedef BOOL if found. // rdar://11231426 llvm-svn: 154595
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 1711f356c62..7748b8c8a66 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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));
}
OpenPOWER on IntegriCloud