This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Getting type used in THROW_EXPR


On 10/14/06, Brendon Costa <brendon@christian.net> wrote:
Hi all,

I have yet another question that has arisen as i have started testing my
code. Basically I am trying to get the type that is being used in
throwing an exception.


Is there a simple macro i can use to get the type of an exception from a THROW_EXPR? I think this is a matter of getting the TREE_TYPE for the value passed into the function: except.c: build_throw(tree exp)

If you look at cp/cp-tree.def you will see


/* A throw expression.  operand 0 is the expression, if there was one,
  else it is NULL_TREE.  */
DEFTREECODE (THROW_EXPR, "throw_expr", tcc_expression, 1)

which means that TREE_OPERAND (t, 0) is the expression thrown.  Based
on whether that is a reference already or not, you need to create a
reference by your own using build1 (ADDR_EXPR, ...) with a properly
constructed reference type (I guess there's some helper for that in the
C++ frontend).

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]