<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60421>60421</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
C function erroneously labeled as variadic?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PMunch
</td>
</tr>
</table>
<pre>
Lifting this potential bug from https://github.com/PMunch/futhark/issues/44. In short Futhark is a tool which uses libclang in order to parse C headers into a format which can then be used to generate bindings for C in Nim. This approach seems to work very well, so this issue surprised me. Essentially with a file as simple as
```c
#define own
own int* wasm_engine_new();
```
the `is_function_variadic` call on the node for the `wasm_engine_new` returns 1. The related code in the Futhark project is here: https://github.com/PMunch/futhark/blob/master/src/opir.nim#L111-#L117.
The JSON output the Opir helper tool generates for that file is:
```json
[
{
"kind": "proc",
"file": "/tmp/test/test.h",
"position": {
"column": 10,
"line": 2
},
"name": "wasm_engine_new",
"return": {
"kind": "pointer",
"depth": 1,
"base": {
"kind": "base",
"value": "cint"
}
},
"arguments": [],
"callingConvention": "cdecl",
"variadic": true,
"inlined": false
}
]
```
Not entirely sure whether this is a bug in Clang, some technically correct but confusing C thing, or improper usage of the translation unit system in libclang (still haven't been able to find any good source of documentation for it). But in the premier case I hope you will be able to resolve it, and otherwise I hope to get a push in the right direction on how to correct this on our end.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVluP2zgP_TXKC9HAkXNpHvIwzXwB-qHbLrD7PpAl2mJHlgxdYuTfLyTHM0l2WmCBgS9j8vDwUCQjQqDOIh7Y5gvbPC9Eitr5w59_JCv1onHqcvhGbSTbQdQUYHARbSRhoEkdtN71oGMcAqufGD8xfuoo6tQspesZP00wjJ_aFLXwr4yfKISEgfHTer2ErxaCdj7CafoOFEBAdM7AqElqSAEDGGqkEbYDsuC8Qg_RwSB8QDiCRqHQByAbHQhone9FvHpLYSFqtN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