summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2010-08-05 06:27:49 +0000
committerNick Lewycky <nicholas@mxc.ca>2010-08-05 06:27:49 +0000
commitef7c0ffe40cd6ac9662ee074cd97daaef6d7eaa1 (patch)
tree960754d9050858e7a5afdd9847f78977a0abe1ab /clang/lib/Sema
parentda518417fa48d875a2950448f6c2027d816d51ad (diff)
downloadbcm5719-llvm-ef7c0ffe40cd6ac9662ee074cd97daaef6d7eaa1.tar.gz
bcm5719-llvm-ef7c0ffe40cd6ac9662ee074cd97daaef6d7eaa1.zip
Remove the warning for variables declared in the if-expression being used in
the else clause. The problem is that it's overly zealous and will respond to uses in assignments, or after assignments. We should bring this back once we can do it right. Fixes PR7100. llvm-svn: 110314
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp22
1 files changed, 1 insertions, 21 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 1dffa0e64c2..6799da1ab68 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1191,26 +1191,6 @@ Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S,
Diag(Property->getLocation(), diag::note_property_declare);
}
}
-
- // Warn about constructs like:
- // if (void *X = foo()) { ... } else { X }.
- // In the else block, the pointer is always false.
- if (Var->isDeclaredInCondition() && Var->getType()->isScalarType()) {
- Scope *CheckS = S;
- while (CheckS && CheckS->getControlParent()) {
- if ((CheckS->getFlags() & Scope::ElseScope) &&
- CheckS->getControlParent()->isDeclScope(DeclPtrTy::make(Var))) {
- ExprError(Diag(NameLoc, diag::warn_value_always_zero)
- << Var->getDeclName()
- << (Var->getType()->isPointerType() ? 2 :
- Var->getType()->isBooleanType() ? 1 : 0));
- break;
- }
-
- // Move to the parent of this scope.
- CheckS = CheckS->getParent();
- }
- }
} else if (FunctionDecl *Func = R.getAsSingle<FunctionDecl>()) {
if (!getLangOptions().CPlusPlus && !Func->hasPrototype()) {
// C99 DR 316 says that, if a function type comes from a
@@ -4973,7 +4953,7 @@ Sema::CheckSingleAssignmentConstraints(QualType lhsType, Expr *&rExpr) {
// This check seems unnatural, however it is necessary to ensure the proper
// conversion of functions/arrays. If the conversion were done for all
// DeclExpr's (created by ActOnIdExpression), it would mess up the unary
- // expressions that surpress this implicit conversion (&, sizeof).
+ // expressions that suppress this implicit conversion (&, sizeof).
//
// Suppress this for references: C++ 8.5.3p5.
if (!lhsType->isReferenceType())
OpenPOWER on IntegriCloud