Fix false positive in -Wunused-variable when a ctor call make involve cleanups.

llvm-svn: 166625
This commit is contained in:
David Blaikie 2012-10-24 21:29:06 +00:00
parent 69b07a2c3a
commit a9d4a936a8
2 changed files with 14 additions and 0 deletions

View File

@ -1286,6 +1286,8 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
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()) {

View File

@ -123,3 +123,15 @@ namespace PR11550 {
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()));
}
}