summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-06-08 17:35:15 +0000
committerDouglas Gregor <dgregor@apple.com>2010-06-08 17:35:15 +0000
commit4038cf4b57da3574a32008aae6357eacdcc3f89e (patch)
tree971b6b6742f309b743240ff819f3064e3ecc9b8d /clang/lib
parent5729f51410e37f5d940f57f5c77d29b8f222e47d (diff)
downloadbcm5719-llvm-4038cf4b57da3574a32008aae6357eacdcc3f89e.tar.gz
bcm5719-llvm-4038cf4b57da3574a32008aae6357eacdcc3f89e.zip
Implement a warning when converting the literal 'false' to a
pointer. Original patch by Troy D. Straszheim; fixes PR7283. llvm-svn: 105621
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 2754d443b25..6a020d57d37 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1622,6 +1622,12 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
bool IgnoreBaseAccess) {
QualType FromType = From->getType();
+ if (CXXBoolLiteralExpr* LitBool
+ = dyn_cast<CXXBoolLiteralExpr>(From->IgnoreParens()))
+ if (LitBool->getValue() == false)
+ Diag(LitBool->getExprLoc(), diag::warn_init_pointer_from_false)
+ << ToType;
+
if (const PointerType *FromPtrType = FromType->getAs<PointerType>())
if (const PointerType *ToPtrType = ToType->getAs<PointerType>()) {
QualType FromPointeeType = FromPtrType->getPointeeType(),
@@ -6159,7 +6165,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
Sema::MultiExprArg(SemaRef, (void**) Args, NumArgs),
CommaLocs, RParenLoc);
}
-
+
/// ResolveOverloadedCallFn - Given the call expression that calls Fn
/// (which eventually refers to the declaration Func) and the call
/// arguments Args/NumArgs, attempt to resolve the function call down
OpenPOWER on IntegriCloud