This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Getting type used in THROW_EXPR
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Brendon Costa" <brendon at christian dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 14 Oct 2006 10:15:47 +0200
- Subject: Re: Getting type used in THROW_EXPR
- References: <453096BC.4050404@christian.net>
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.