From: Ted Kremenek Date: Wed, 23 Dec 2009 04:11:44 +0000 (+0000) Subject: Suppress dead store warnings involving objects initialized with CXXExprTemporaries. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=604d939ac15d1398761df313679673d30bb10f27;p=clang Suppress dead store warnings involving objects initialized with CXXExprTemporaries. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91986 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CheckDeadStores.cpp b/lib/Analysis/CheckDeadStores.cpp index f081c69c2b..6e4d899862 100644 --- a/lib/Analysis/CheckDeadStores.cpp +++ b/lib/Analysis/CheckDeadStores.cpp @@ -201,6 +201,10 @@ public: // constructors/destructors don't have side effects. if (isa(E)) return; + + if (isa(E)) + return; + // A dead initialization is a variable that is dead after it // is initialized. We don't flag warnings for those variables // marked 'unused'. diff --git a/test/Analysis/dead-stores.cpp b/test/Analysis/dead-stores.cpp index 45f750688f..9778a11c92 100644 --- a/test/Analysis/dead-stores.cpp +++ b/test/Analysis/dead-stores.cpp @@ -38,6 +38,32 @@ int test2(int x) { return x; } +//===----------------------------------------------------------------------===// +// Dead store checking involving CXXTemporaryExprs +//===----------------------------------------------------------------------===// + +namespace TestTemp { + template + class pencil { + public: + ~pencil() throw() {} + }; + template struct _Row_base { + _Row_base(const pencil<_Tp>& x) {} + }; + template > + class row : protected _Row_base<_Tp, _Number2> { + typedef _Row_base<_Tp, _Number2> _Base; + typedef _Number2 pencil_type; + public: + explicit row(const pencil_type& __a = pencil_type()) : _Base(__a) {} + }; +} + +void test2_b() { + TestTemp::row x; // no-warning +} + //===----------------------------------------------------------------------===// // Test references. //===----------------------------------------------------------------------===//