forked from OSchip/llvm-project
Fix false positive in -Wunused-variable when a ctor call make involve cleanups.
llvm-svn: 166625
This commit is contained in:
parent
69b07a2c3a
commit
a9d4a936a8
|
@ -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()) {
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue