<html>
<head>
<base href="https://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 --- - Missing 'null passed to a callee that requires a non-null argument' warning for calls to functions declared with a typedef that has a nonnull attribute"
href="https://llvm.org/bugs/show_bug.cgi?id=25937">25937</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missing 'null passed to a callee that requires a non-null argument' warning for calls to functions declared with a typedef that has a nonnull attribute
</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>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>thonerma@synopsys.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I've tested this with Clang 3.5-3.7 and trunk (r234313). Clang versions prior
to 3.5 didn't support infix nonnull attribute on parameters, so I didn't bother
going back further.
$ cat t.c
typedef void (f1_t)(int *__attribute__((nonnull)) p);
f1_t f1;
typedef void (f2_t)(int *p) __attribute__((nonnull));
f2_t f2;
typedef void (f3_t)(int *p);
f3_t f3 __attribute__((nonnull));
void f() {
f1(0);
f2(0);
f3(0);
}
$ clang -c t.c
t.c:10:9: warning: null passed to a callee that requires a non-null argument
[-Wnonnull]
f3(0);
~^
1 warning generated.
Note that a warning is only emitted for the call to f3(); warnings should be
issued for the calls to f1() and f2() as well.
The Clang AST does not store the nonnull attribute for the f1_t typedef
declaration, but it does for the f2_t typedef declaration:
$ clang -Xclang -ast-dump -w -c t.c
...
|-TypedefDecl 0x80bbc28 <t.c:1:1, col:52> col:15 referenced f1_t 'void (int
*)':'void (int *)'
...
|-TypedefDecl 0x80fd950 <line:3:1, col:27> col:15 referenced f2_t 'void (int
*)':'void (int *)'
| `-NonNullAttr 0x80fd9a0 <col:44>
...
So, there appears to be two issues:
1) Infix nonnull attributes applied to parameters of typedef declarations are
not preserved in the AST.
2) Warnings are not emitted for calls to functions declared with a typedef
declaration that has nonnull attributes.</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>