Hello!

Thank you for the information. I am also quite confused with this issue. I
note that it seems that given the following statement:

m_pstSwtmrCBArray.27_1 = m_pstSwtmrCBArray;

where m_pstSwtmrCBArray is a global variable (a pointer). When passing a
tree pointer `v` referring to m_pstSwtmrCBArray to the following statement:

auto temp = TREE_CODE(v);

It will cause a segmentation fault of my GIMPLE pass. Not sure what's
actually going on here...

Best,
Shuai


On Fri, Feb 19, 2021 at 4:54 PM Prathamesh Kulkarni <
prathamesh.kulka...@linaro.org> wrote:

> On Fri, 19 Feb 2021 at 10:31, Shuai Wang via Gcc <gcc@gcc.gnu.org> wrote:
> >
> > Hello,
> >
> > I noticed that tree_node is implemented as a union (
> > https://code.woboq.org/gcc/gcc/tree-core.h.html#tree_node). However, I
> > cannot find a way of checking whether the current tree_node is really a
> > base or type.
> >
> > For instance, currently when I am using:
> >
> > is_gimple_constant(v)
> >
> > Given `v` as a tree type but NOT base type, the above statement would
> > crash. I am thinking there should be a method like:
> >
> > is_tree_base(v) == false
> >
> > or something like this; however, I couldn't find one. Can anyone shed
> some
> > lights on this? Thank you very much!
> If you want to ascertain which class the tree node belongs to, you can
> use either TREE_CODE, or one of the _P macros
> defined in tree.h. If you use an accessor that needs tree node
> belonging to a certain class, then you need to check for it before
> hand.
> For example before using DECL_NAME on a tree node, you need to
> explicitly check if it's indeed a decl_node using DECL_P.
> For is_gimple_constant(v), it will return true if v is a one of the
> constant nodes (*_CST), and false otherwise, so I don't see how it
> will crash if you
> pass a non-constant node ?
>
> Thanks,
> Prathamesh
> >
> > best,
> > Shuai
>

Reply via email to