[cfe-commits] r89106 - in /cfe/trunk: lib/AST/Expr.cpp test/SemaCXX/warn-unused-variables.cpp
Anders Carlsson
andersca at mac.com
Tue Nov 17 09:11:23 PST 2009
Author: andersca
Date: Tue Nov 17 11:11:23 2009
New Revision: 89106
URL: http://llvm.org/viewvc/llvm-project?rev=89106&view=rev
Log:
Fix PR5531.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=89106&r1=89105&r2=89106&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Nov 17 11:11:23 2009
@@ -814,6 +814,11 @@
}
return false;
}
+
+ case CXXTemporaryObjectExprClass:
+ case CXXConstructExprClass:
+ return false;
+
case ObjCMessageExprClass:
return false;
@@ -855,15 +860,19 @@
Loc = cast<CStyleCastExpr>(this)->getLParenLoc();
R1 = cast<CStyleCastExpr>(this)->getSubExpr()->getSourceRange();
return true;
- case CXXFunctionalCastExprClass:
- // If this is a cast to void, check the operand. Otherwise, the result of
- // the cast is unused.
- if (getType()->isVoidType())
+ case CXXFunctionalCastExprClass: {
+ const CastExpr *CE = cast<CastExpr>(this);
+
+ // If this is a cast to void or a constructor conversion, check the operand.
+ // Otherwise, the result of the cast is unused.
+ if (CE->getCastKind() == CastExpr::CK_ToVoid ||
+ CE->getCastKind() == CastExpr::CK_ConstructorConversion)
return (cast<CastExpr>(this)->getSubExpr()
->isUnusedResultAWarning(Loc, R1, R2, Ctx));
Loc = cast<CXXFunctionalCastExpr>(this)->getTypeBeginLoc();
R1 = cast<CXXFunctionalCastExpr>(this)->getSubExpr()->getSourceRange();
return true;
+ }
case ImplicitCastExprClass:
// Check the operand, since implicit casts are inserted by Sema
Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=89106&r1=89105&r2=89106&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Tue Nov 17 11:11:23 2009
@@ -12,3 +12,23 @@
A a;
B b;
}
+
+// PR5531
+namespace PR5531 {
+ struct A {
+ };
+
+ struct B {
+ B(int);
+ };
+
+ struct C {
+ ~C();
+ };
+
+ void test() {
+ A();
+ B(17);
+ C();
+ }
+}
More information about the cfe-commits
mailing list