<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - False positive for -Wunused-variable in function template when calling nontrivial ctor with __func__"
href="http://llvm.org/bugs/show_bug.cgi?id=15532">15532</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False positive for -Wunused-variable in function template when calling nontrivial ctor with __func__
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>matthewbg@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>class Parser {
class Tracer {
public:
Tracer(const char*, Parser*);
};
template <char delim> void ParseFoo() {
Tracer trace(__func__, this);
}
void ParseBar() {
Tracer trace(__func__, this);
}
};
We warn on the 'trace' variable in ParseFoo, but not the one in ParseBar. The
Decl for 'trace' in ParseBar looks like:
VarDecl 0x3c83d70 </tmp/in.ii:10:5, col:32> trace 'class Parser::Tracer'
`-CXXConstructExpr 0x3c84268 <col:12, col:32> 'class Parser::Tracer' 'void
(const char *, class Parser *)'
|-ImplicitCastExpr 0x3c84250 <col:18> 'const char *' <ArrayToPointerDecay>
| `-PredefinedExpr 0x3c83e48 <col:18> 'const char [9]' lvalue __func__
`-CXXThisExpr 0x3c83e60 <col:28> 'class Parser *' this
So, in ShouldDiagnoseUnusedDecl, we correctly determine that the constructor is
non-elidable and nontrivial, and return false.
On the other hand, the 'trace' in ParseFoo looks like this:
VarDecl 0x3c83c30 </tmp/in.ii:7:5, col:32> trace 'class Parser::Tracer'
`-ParenListExpr 0x3c83cf0 <col:17, col:32> 'NULL TYPE'
|-PredefinedExpr 0x3c83c88 <col:18> '<dependent type>' lvalue __func__
`-CXXThisExpr 0x3c83ca0 <col:28> 'class Parser *' this
We don't find a CXXConstructExpr, so ShouldDiagnoseUnusedDecl returns true.
Oops.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>