diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-12 21:24:56 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-12 21:24:56 +0000 |
commit | 262acdab8ba128857a6e5323f767f5e154ce75e6 (patch) | |
tree | 9c9cdf4c1aea0b45f3e302cd60f82d37f673aacb /lib/Sema/SemaExpr.cpp | |
parent | 7d000652ccf5b370006d4f80d39041d2ff0d9106 (diff) |
objective-c literals: Issue warning and ignore
when BOOL is not of an intergal type when
boolean literals are used. // rdar://11231426
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154619 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 104134cdb0..2333e32e85 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -11270,9 +11270,13 @@ Sema::ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind) { 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()) + if (TypedefDecl *BoolTD = dyn_cast_or_null<TypedefDecl>(TD)) { + QualType QT = BoolTD->getUnderlyingType(); + if (!QT->isIntegralOrUnscopedEnumerationType()) { + Diag(OpLoc, diag::warn_bool_for_boolean_literal) << QT; + Diag(BoolTD->getLocation(), diag::note_previous_declaration); + } + else ObjCBoolLiteralQT = QT; } |