[cfe-dev] Distinguish between array parameters and pointer parameters in the AST.
steve naroff
snaroff at apple.com
Fri Feb 20 08:54:44 PST 2009
On Feb 20, 2009, at 11:26 AM, Paolo Bolzoni wrote:
> dear cfe list,
>
> According to the clang AST the two parameters' type of this function
> declaration are the same:
>
> int f(int a[], int* b);
>
> while it makes sense, I'd like to distinguish.
> Is it not possible?
>
Not currently. Here is a comment from
Sema::Sema::ActOnParamDeclarator():
// Perform the default function/array conversion (C99 6.7.5.3p[7,8]).
// Doing the promotion here has a win and a loss. The win is the
type for
// both Decl's and DeclRefExpr's will match (a convenient invariant
for the
// code generator). The loss is the orginal type isn't preserved.
For example:
//
// void func(int parmvardecl[5]) { // convert "int [5]" to "int *"
// int blockvardecl[5];
// sizeof(parmvardecl); // size == 4
// sizeof(blockvardecl); // size == 20
// }
//
// For expressions, all implicit conversions are captured using the
// ImplicitCastExpr AST node (we have no such mechanism for Decl's).
//
// FIXME: If a source translation tool needs to see the original
type, then
// we need to consider storing both types (in ParmVarDecl)...
//
HTH,
snaroff
> thanks
> pb
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090220/e410a17a/attachment.html>
More information about the cfe-dev
mailing list