]>
Commit | Line | Data |
---|---|---|
8d08fdba MS |
1 | /* Convert language-specific tree expression to rtl instructions, |
2 | for GNU compiler. | |
23a5b65a | 3 | Copyright (C) 1988-2014 Free Software Foundation, Inc. |
8d08fdba | 4 | |
f5adbb8d | 5 | This file is part of GCC. |
8d08fdba | 6 | |
f5adbb8d | 7 | GCC is free software; you can redistribute it and/or modify |
8d08fdba | 8 | it under the terms of the GNU General Public License as published by |
e77f031d | 9 | the Free Software Foundation; either version 3, or (at your option) |
8d08fdba MS |
10 | any later version. |
11 | ||
f5adbb8d | 12 | GCC is distributed in the hope that it will be useful, |
8d08fdba MS |
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
e77f031d NC |
18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
8d08fdba MS |
20 | |
21 | ||
22 | #include "config.h" | |
8d052bc7 | 23 | #include "system.h" |
4977bab6 ZW |
24 | #include "coretypes.h" |
25 | #include "tm.h" | |
8d08fdba MS |
26 | #include "tree.h" |
27 | #include "flags.h" | |
8d08fdba | 28 | #include "cp-tree.h" |
b1474bb7 | 29 | #include "tm_p.h" |
8d08fdba | 30 | |
6524147c | 31 | /* Expand C++-specific constants. Currently, this means PTRMEM_CST. */ |
87533b37 | 32 | |
b928a651 | 33 | tree |
d9b4e85e | 34 | cplus_expand_constant (tree cst) |
87533b37 MM |
35 | { |
36 | switch (TREE_CODE (cst)) | |
37 | { | |
38 | case PTRMEM_CST: | |
39 | { | |
40 | tree type = TREE_TYPE (cst); | |
41 | tree member; | |
c8094d83 | 42 | |
87533b37 MM |
43 | /* Find the member. */ |
44 | member = PTRMEM_CST_MEMBER (cst); | |
45 | ||
deaae9d7 JM |
46 | /* We can't lower this until the class is complete. */ |
47 | if (!COMPLETE_TYPE_P (DECL_CONTEXT (member))) | |
48 | return cst; | |
49 | ||
c8094d83 | 50 | if (TREE_CODE (member) == FIELD_DECL) |
b3dd05b1 MM |
51 | { |
52 | /* Find the offset for the field. */ | |
53 | cst = byte_position (member); | |
54 | while (!same_type_p (DECL_CONTEXT (member), | |
55 | TYPE_PTRMEM_CLASS_TYPE (type))) | |
56 | { | |
57 | /* The MEMBER must have been nestled within an | |
58 | anonymous aggregate contained in TYPE. Find the | |
59 | anonymous aggregate. */ | |
60 | member = lookup_anon_field (TYPE_PTRMEM_CLASS_TYPE (type), | |
61 | DECL_CONTEXT (member)); | |
62 | cst = size_binop (PLUS_EXPR, cst, byte_position (member)); | |
63 | } | |
64 | cst = fold (build_nop (type, cst)); | |
65 | } | |
87533b37 MM |
66 | else |
67 | { | |
530ec96d MM |
68 | tree delta; |
69 | tree pfn; | |
87533b37 | 70 | |
18ae7f63 AO |
71 | expand_ptrmemfunc_cst (cst, &delta, &pfn); |
72 | cst = build_ptrmemfunc1 (type, delta, pfn); | |
87533b37 MM |
73 | } |
74 | } | |
75 | break; | |
76 | ||
77 | default: | |
78 | /* There's nothing to do. */ | |
79 | break; | |
80 | } | |
81 | ||
82 | return cst; | |
83 | } | |
03a904b5 JJ |
84 | |
85 | /* Called whenever an expression is used | |
86 | in a rvalue context. */ | |
87 | ||
88 | tree | |
89 | mark_rvalue_use (tree expr) | |
90 | { | |
91 | mark_exp_read (expr); | |
92 | return expr; | |
93 | } | |
94 | ||
95 | /* Called whenever an expression is used | |
96 | in a lvalue context. */ | |
97 | ||
98 | tree | |
99 | mark_lvalue_use (tree expr) | |
100 | { | |
101 | mark_exp_read (expr); | |
102 | return expr; | |
103 | } | |
104 | ||
105 | /* Called whenever an expression is used in a type use context. */ | |
106 | ||
107 | tree | |
108 | mark_type_use (tree expr) | |
109 | { | |
110 | mark_exp_read (expr); | |
111 | return expr; | |
112 | } | |
113 | ||
114 | /* Mark EXP as read, not just set, for set but not used -Wunused | |
115 | warning purposes. */ | |
116 | ||
117 | void | |
118 | mark_exp_read (tree exp) | |
119 | { | |
120 | if (exp == NULL) | |
121 | return; | |
122 | ||
123 | switch (TREE_CODE (exp)) | |
124 | { | |
125 | case VAR_DECL: | |
126 | case PARM_DECL: | |
127 | DECL_READ_P (exp) = 1; | |
128 | break; | |
129 | case ARRAY_REF: | |
130 | case COMPONENT_REF: | |
131 | case MODIFY_EXPR: | |
132 | case REALPART_EXPR: | |
133 | case IMAGPART_EXPR: | |
134 | CASE_CONVERT: | |
135 | case ADDR_EXPR: | |
d84686d1 | 136 | case INDIRECT_REF: |
759deff3 | 137 | case FLOAT_EXPR: |
03a904b5 JJ |
138 | mark_exp_read (TREE_OPERAND (exp, 0)); |
139 | break; | |
140 | case COMPOUND_EXPR: | |
141 | mark_exp_read (TREE_OPERAND (exp, 1)); | |
142 | break; | |
143 | case COND_EXPR: | |
144 | if (TREE_OPERAND (exp, 1)) | |
145 | mark_exp_read (TREE_OPERAND (exp, 1)); | |
146 | if (TREE_OPERAND (exp, 2)) | |
147 | mark_exp_read (TREE_OPERAND (exp, 2)); | |
148 | break; | |
149 | default: | |
150 | break; | |
151 | } | |
152 | } | |
153 |