Remove -fopenmp in dg-options in libgomp.c
[official-gcc.git] / gcc / cp / expr.c
blob5d900396d81cf354ebde01b051d185147d152d0d
1 /* Convert language-specific tree expression to rtl instructions,
2 for GNU compiler.
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)
10 any later version.
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/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "input.h"
27 #include "alias.h"
28 #include "symtab.h"
29 #include "tree.h"
30 #include "flags.h"
31 #include "cp-tree.h"
32 #include "tm_p.h"
34 /* Expand C++-specific constants. Currently, this means PTRMEM_CST. */
36 tree
37 cplus_expand_constant (tree cst)
39 switch (TREE_CODE (cst))
41 case PTRMEM_CST:
43 tree type = TREE_TYPE (cst);
44 tree member;
46 /* Find the member. */
47 member = PTRMEM_CST_MEMBER (cst);
49 /* We can't lower this until the class is complete. */
50 if (!COMPLETE_TYPE_P (DECL_CONTEXT (member)))
51 return cst;
53 if (TREE_CODE (member) == FIELD_DECL)
55 /* Find the offset for the field. */
56 cst = byte_position (member);
57 while (!same_type_p (DECL_CONTEXT (member),
58 TYPE_PTRMEM_CLASS_TYPE (type)))
60 /* The MEMBER must have been nestled within an
61 anonymous aggregate contained in TYPE. Find the
62 anonymous aggregate. */
63 member = lookup_anon_field (TYPE_PTRMEM_CLASS_TYPE (type),
64 DECL_CONTEXT (member));
65 cst = size_binop (PLUS_EXPR, cst, byte_position (member));
67 cst = fold (build_nop (type, cst));
69 else
71 tree delta;
72 tree pfn;
74 expand_ptrmemfunc_cst (cst, &delta, &pfn);
75 cst = build_ptrmemfunc1 (type, delta, pfn);
78 break;
80 case CONSTRUCTOR:
82 constructor_elt *elt;
83 unsigned HOST_WIDE_INT idx;
84 FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (cst), idx, elt)
85 elt->value = cplus_expand_constant (elt->value);
88 default:
89 /* There's nothing to do. */
90 break;
93 return cst;
96 /* Called whenever an expression is used
97 in a rvalue context. */
99 tree
100 mark_rvalue_use (tree expr)
102 mark_exp_read (expr);
103 return expr;
106 /* Called whenever an expression is used
107 in a lvalue context. */
109 tree
110 mark_lvalue_use (tree expr)
112 mark_exp_read (expr);
113 return expr;
116 /* Called whenever an expression is used in a type use context. */
118 tree
119 mark_type_use (tree expr)
121 mark_exp_read (expr);
122 return expr;
125 /* Mark EXP as read, not just set, for set but not used -Wunused
126 warning purposes. */
128 void
129 mark_exp_read (tree exp)
131 if (exp == NULL)
132 return;
134 switch (TREE_CODE (exp))
136 case VAR_DECL:
137 case PARM_DECL:
138 DECL_READ_P (exp) = 1;
139 break;
140 case ARRAY_REF:
141 case COMPONENT_REF:
142 case MODIFY_EXPR:
143 case REALPART_EXPR:
144 case IMAGPART_EXPR:
145 CASE_CONVERT:
146 case ADDR_EXPR:
147 case INDIRECT_REF:
148 case FLOAT_EXPR:
149 mark_exp_read (TREE_OPERAND (exp, 0));
150 break;
151 case COMPOUND_EXPR:
152 mark_exp_read (TREE_OPERAND (exp, 1));
153 break;
154 case COND_EXPR:
155 if (TREE_OPERAND (exp, 1))
156 mark_exp_read (TREE_OPERAND (exp, 1));
157 if (TREE_OPERAND (exp, 2))
158 mark_exp_read (TREE_OPERAND (exp, 2));
159 break;
160 default:
161 break;