<div dir="ltr">Since "varargs" often involve some kind of special passing mechanisms [I've seen implementations that build data block and pass a pointer to that, rather than passing on the stack, for example], or additional code in the recipient function, I would say that `f2()` does not mean `f2(...)`. <div><br></div><div>--</div><div>Mats</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 2 October 2015 at 20:16, Aaron Ballman via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Given the following two function declarations:<br>
<br>
void f1(...);<br>
void f2();<br>
<br>
It makes sense to me that isVariadic() returns true for f1 in both C<br>
and C++. It makes sense to me that isVariadic() returns false for f2<br>
in C++. I am confused as to why it returns false instead of true for<br>
C, however.<br>
<br>
In C11, 6.7.6.3p9 states: If the list terminates with an ellipsis (,<br>
...), no information about the number or types of the parameters after<br>
the comma is supplied.<br>
<br>
p14 states, in part: "The empty list in a function declarator that is<br>
not part of a definition of that function specifies that no<br>
information about the number or types of the parameters is supplied."<br>
<br>
It seems to me that for function *declarations* (not definitions),<br>
isVariadic() should return true for f2 in C. Is there a reason it<br>
doesn't currently behave that way, or is this a bug?<br>
<br>
I ask because I was writing an AST matcher for isVariadic() for an<br>
in-progress checker, but the checker was failing to catch that f2 was<br>
a variadic function. I am not certain whether<br>
FunctionDecl::isVariadic() should be changed, whether the AST matcher<br>
isVariadic() should be smarter about C code, or whether the checker<br>
itself needs to be smarter about this particular behavior in C code.<br>
My gut reaction is that FunctionDecl::isVariadic() has a bug, but from<br>
looking at code elsewhere, everything seems to assume isVariadic()<br>
implies the ellipsis, which makes me think I just need to make my<br>
checker smarter.<br>
<br>
Thanks!<br>
<br>
~Aaron<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>