1 /* Convert language-specific tree expression to rtl instructions,
3 Copyright (C) 1988-2015 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
29 #include "double-int.h"
40 /* Expand C++-specific constants. Currently, this means PTRMEM_CST. */
43 cplus_expand_constant (tree cst)
45 switch (TREE_CODE (cst))
49 tree type = TREE_TYPE (cst);
52 /* Find the member. */
53 member = PTRMEM_CST_MEMBER (cst);
55 /* We can't lower this until the class is complete. */
56 if (!COMPLETE_TYPE_P (DECL_CONTEXT (member)))
59 if (TREE_CODE (member) == FIELD_DECL)
61 /* Find the offset for the field. */
62 cst = byte_position (member);
63 while (!same_type_p (DECL_CONTEXT (member),
64 TYPE_PTRMEM_CLASS_TYPE (type)))
66 /* The MEMBER must have been nestled within an
67 anonymous aggregate contained in TYPE. Find the
68 anonymous aggregate. */
69 member = lookup_anon_field (TYPE_PTRMEM_CLASS_TYPE (type),
70 DECL_CONTEXT (member));
71 cst = size_binop (PLUS_EXPR, cst, byte_position (member));
73 cst = fold (build_nop (type, cst));
80 expand_ptrmemfunc_cst (cst, &delta, &pfn);
81 cst = build_ptrmemfunc1 (type, delta, pfn);
89 unsigned HOST_WIDE_INT idx;
90 FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (cst), idx, elt)
91 elt->value = cplus_expand_constant (elt->value);
95 /* There's nothing to do. */
102 /* Called whenever an expression is used
103 in a rvalue context. */
106 mark_rvalue_use (tree expr)
108 mark_exp_read (expr);
112 /* Called whenever an expression is used
113 in a lvalue context. */
116 mark_lvalue_use (tree expr)
118 mark_exp_read (expr);
122 /* Called whenever an expression is used in a type use context. */
125 mark_type_use (tree expr)
127 mark_exp_read (expr);
131 /* Mark EXP as read, not just set, for set but not used -Wunused
135 mark_exp_read (tree exp)
140 switch (TREE_CODE (exp))
144 DECL_READ_P (exp) = 1;
155 mark_exp_read (TREE_OPERAND (exp, 0));
158 mark_exp_read (TREE_OPERAND (exp, 1));
161 if (TREE_OPERAND (exp, 1))
162 mark_exp_read (TREE_OPERAND (exp, 1));
163 if (TREE_OPERAND (exp, 2))
164 mark_exp_read (TREE_OPERAND (exp, 2));