[cfe-commits] r166625 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/warn-unused-variables.cpp
David Blaikie
dblaikie at gmail.com
Wed Oct 24 14:29:06 PDT 2012
Author: dblaikie
Date: Wed Oct 24 16:29:06 2012
New Revision: 166625
URL: http://llvm.org/viewvc/llvm-project?rev=166625&view=rev
Log:
Fix false positive in -Wunused-variable when a ctor call make involve cleanups.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=166625&r1=166624&r2=166625&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Oct 24 16:29:06 2012
@@ -1286,6 +1286,8 @@
return false;
if (const Expr *Init = VD->getInit()) {
+ if (const ExprWithCleanups *Cleanups = dyn_cast<ExprWithCleanups>(Init))
+ Init = Cleanups->getSubExpr();
const CXXConstructExpr *Construct =
dyn_cast<CXXConstructExpr>(Init);
if (Construct && !Construct->isElidable()) {
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=166625&r1=166624&r2=166625&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Wed Oct 24 16:29:06 2012
@@ -123,3 +123,15 @@
S3 z = a; // expected-warning {{unused variable 'z'}}
}
}
+
+namespace ctor_with_cleanups {
+ struct S1 {
+ ~S1();
+ };
+ struct S2 {
+ S2(const S1&);
+ };
+ void func() {
+ S2 s((S1()));
+ }
+}
More information about the cfe-commits
mailing list