[cfe-dev] FunctionDecls by typedef crash the C++ front-end
Chris Lattner
clattner at apple.com
Thu Oct 23 22:33:23 PDT 2008
On Oct 23, 2008, at 6:37 PM, Argiris Kirtzidis wrote:
> e.g:
>
> typedef void fn(int);
> fn f;
>
> There are no ParmVarDecls created for the 'f' FunctionDecl, and I
> assume
> this is intended to save space.
> This crashes the C++ front-end when trying to use the ParmVarDecls
> (mostly for handling default args).
>
> In C there is no problem since ParmVarDecls are used only for
> definitions, otherwise FunctionTypeProto is used
Two options here. The best is probably for the C++ front-end to
create the parm var decls in this case, to be consistent with "void
f(int);". The typedef shouldn't affect the AST generated other than
the pretty type.
Long term, I'd love to get rid of parm var decls in the common case.
They are needed for stuff like this in C:
void f(int i, int x[i*42]);
etc. However, this is obviously not the common case, and most clients
don't care about parmvardecls in function prototypes. Considering
that tons of headers have lots of function prototypes, I think this
would be a big win. This isn't a particularly high priority though,
-Chris
More information about the cfe-dev
mailing list