Type of Array ParmVarDecl becomes PointerType

Hi everybody,

I am using Version 3.0 and I am trying to parse the parameter of the following function declaration.

void test(int myParam[])
{

}

I have written an ASTVisitor to iterate over the "ParamDecl’s"of my “FunctionDecl’s”
The type of the “ParmVarDecl” myParam is always a “PointerType”, although I am expecting
an “ArrayType”. Is this normal behavior?

Also when I parse the following code I am loosing the size information. Sure, the
99 doesn’t make much sense, but I need it for internal analysis :wink:

void test(int myParam[99])
{

}

I hope someone can help!
Thanks in advance!!!

Hi everybody,

I am using Version 3.0 and I am trying to parse the parameter of the following function declaration.

void test(int myParam[])
{

}

I have written an ASTVisitor to iterate over the "ParamDecl’s"of my “FunctionDecl’s”
The type of the “ParmVarDecl” myParam is always a “PointerType”, although I am expecting
an “ArrayType”. Is this normal behavior?

Yes. The language specifies that parameters of array or function type are adjusted to the corresponding pointer type.

Also when I parse the following code I am loosing the size information. Sure, the
99 doesn’t make much sense, but I need it for internal analysis :wink:

void test(int myParam[99])
{

}

I hope someone can help!

Use ParmVarDecl::getOriginalType() to get the type as it was spelled in the source code, before the adjustment applied.

  • Doug

Yes, that's how C works; for most purposes, the original type doesn't
matter. You can use ParmVarDecl::getOriginalType() if you really need
it.

-Eli

You can use ParmVarDecl::getOriginalType() if you really need
Yeahhhh… :):):):slight_smile:

Doug,Eli thanks a lot!!!