Problems with SgType::baseType()


	Given an arbitrary expression, my program must output a text
representation of the type of that expression. I have written a
function that switches on the variant() field of the type. The code
looks something like this

char    *EntTypeName(SgType *type)
        static char     s[255];

        if (!type)
                return "???";

        switch (type->variant()) {
                case DEFAULT:
                case T_INT:	return "int";
                case T_FLOAT:	return "float";
                case T_ARRAY:
                case T_POINTER:
                        char stars[30];
                        *stars = '\0';
                        while ( type->variant() == T_ARRAY ||
                                type->variant() == T_POINTER ) {
                                type = type->baseType();
                                strcat(stars, "*");
                        sprintf(s, "%s %s", EntTypeName(type), stars);
                        return s;

It usually works fine, but I'm having problems with some pointer
expressions. The program I'm parsing contains the following array

		float	test[200];

Suppose that I build the expression SgExpression *e = &(test[i * 10])

When I call EntTypeName(e->type()), I obtain the string "float ***",
when I should be obtaining "float *". This problem doesn't show up if I
use regular float pointers. I followed the execution with gdb. The
while() loop for case T_POINTER is executed three times because
baseType() returns T_POINTER 3 times.

I also tried to use internalBaseType() and it works in this example,
but if I have a real triple indirect pointer, it prints just one '*'.

Well, I hope the explanation is sufficiently clear. Am I doing anything

Thanks. Diego.

Diego A. Novillo                  | "We each pay a fabulous price for our
diego@cs.ualberta.ca              |  visions of paradise. But a spirit with
Computing Science - U of Alberta  |  a vision is a dream with a mission"
Edmonton, Alberta - Canada        |             Rush - Mission