forked from OSchip/llvm-project
objective-c numeric literal: type of boolean is
that of typedef BOOL if found. // rdar://11231426 llvm-svn: 154595
This commit is contained in:
parent
6f3e5ad704
commit
30c3de97a9
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
|
||||
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"__declspec(X)=" %t-rw.cpp
|
||||
// rdar://11231426
|
||||
|
||||
typedef bool BOOL;
|
||||
|
||||
BOOL yes() {
|
||||
return __objc_yes;
|
||||
}
|
||||
|
||||
BOOL no() {
|
||||
return __objc_no;
|
||||
}
|
||||
|
||||
BOOL which (int flag) {
|
||||
return flag ? yes() : no();
|
||||
}
|
||||
|
||||
int main() {
|
||||
which (__objc_yes);
|
||||
which (__objc_no);
|
||||
return __objc_yes;
|
||||
}
|
||||
|
||||
void y(BOOL (^foo)());
|
||||
|
||||
void x() {
|
||||
y(^{
|
||||
return __objc_yes;
|
||||
});
|
||||
}
|
|
@ -1,6 +1,15 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fblocks %s
|
||||
|
||||
typedef unsigned char BOOL;
|
||||
// rdar://11231426
|
||||
typedef bool BOOL;
|
||||
|
||||
void y(BOOL (^foo)());
|
||||
|
||||
void x() {
|
||||
y(^{
|
||||
return __objc_yes;
|
||||
});
|
||||
}
|
||||
|
||||
@protocol NSCopying
|
||||
- copy;
|
||||
|
|
Loading…
Reference in New Issue