comparison gcc/cp/expr.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Convert language-specific tree expression to rtl instructions, 1 /* Convert language-specific tree expression to rtl instructions,
2 for GNU compiler. 2 for GNU compiler.
3 Copyright (C) 1988-2018 Free Software Foundation, Inc. 3 Copyright (C) 1988-2020 Free Software Foundation, Inc.
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify 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 8 it under the terms of the GNU General Public License as published by
94 location_t loc /* = UNKNOWN_LOCATION */, 94 location_t loc /* = UNKNOWN_LOCATION */,
95 bool reject_builtin /* = true */) 95 bool reject_builtin /* = true */)
96 { 96 {
97 #define RECUR(t) mark_use ((t), rvalue_p, read_p, loc, reject_builtin) 97 #define RECUR(t) mark_use ((t), rvalue_p, read_p, loc, reject_builtin)
98 98
99 if (expr == NULL_TREE || expr == error_mark_node) 99 if (expr == NULL_TREE || error_operand_p (expr))
100 return expr; 100 return expr;
101 101
102 if (reject_builtin && reject_gcc_builtin (expr, loc)) 102 if (reject_builtin && reject_gcc_builtin (expr, loc))
103 return error_mark_node; 103 return error_mark_node;
104 104
185 if (r != ref) 185 if (r != ref)
186 expr = convert_from_reference (r); 186 expr = convert_from_reference (r);
187 } 187 }
188 break; 188 break;
189 189
190 CASE_CONVERT:
191 case VIEW_CONVERT_EXPR: 190 case VIEW_CONVERT_EXPR:
192 if (location_wrapper_p (expr)) 191 if (location_wrapper_p (expr))
193 loc = EXPR_LOCATION (expr); 192 {
193 loc = EXPR_LOCATION (expr);
194 tree op = TREE_OPERAND (expr, 0);
195 tree nop = RECUR (op);
196 if (nop == error_mark_node)
197 return error_mark_node;
198 TREE_OPERAND (expr, 0) = nop;
199 /* If we're replacing a DECL with a constant, we also need to change
200 the TREE_CODE of the location wrapper. */
201 if (op != nop && rvalue_p)
202 TREE_SET_CODE (expr, NON_LVALUE_EXPR);
203 return expr;
204 }
205 gcc_fallthrough();
206 CASE_CONVERT:
194 recurse_op[0] = true; 207 recurse_op[0] = true;
195 break; 208 break;
209
210 case MODIFY_EXPR:
211 {
212 tree lhs = TREE_OPERAND (expr, 0);
213 /* [expr.ass] "A simple assignment whose left operand is of
214 a volatile-qualified type is deprecated unless the assignment
215 is either a discarded-value expression or appears in an
216 unevaluated context." */
217 if (read_p
218 && !cp_unevaluated_operand
219 && (TREE_THIS_VOLATILE (lhs)
220 || CP_TYPE_VOLATILE_P (TREE_TYPE (lhs)))
221 && !TREE_THIS_VOLATILE (expr))
222 {
223 warning_at (location_of (expr), OPT_Wvolatile,
224 "using value of simple assignment with %<volatile%>-"
225 "qualified left operand is deprecated");
226 /* Make sure not to warn about this assignment again. */
227 TREE_THIS_VOLATILE (expr) = true;
228 }
229 break;
230 }
196 231
197 default: 232 default:
198 break; 233 break;
199 } 234 }
200 235
261 * comma expression (8.19) where the right operand is one of these 296 * comma expression (8.19) where the right operand is one of these
262 expressions. */ 297 expressions. */
263 if (expr == NULL_TREE) 298 if (expr == NULL_TREE)
264 return expr; 299 return expr;
265 300
301 STRIP_ANY_LOCATION_WRAPPER (expr);
302
266 switch (TREE_CODE (expr)) 303 switch (TREE_CODE (expr))
267 { 304 {
268 case COND_EXPR: 305 case COND_EXPR:
269 TREE_OPERAND (expr, 2) = mark_discarded_use (TREE_OPERAND (expr, 2)); 306 TREE_OPERAND (expr, 2) = mark_discarded_use (TREE_OPERAND (expr, 2));
270 gcc_fallthrough (); 307 gcc_fallthrough ();
358 if (f == error_mark_node) 395 if (f == error_mark_node)
359 return x; 396 return x;
360 else 397 else
361 return f; 398 return f;
362 } 399 }
400 else if (cxx_dialect >= cxx11)
401 x = maybe_constant_value (x, NULL_TREE, false, true);
363 402
364 return c_fully_fold (x, /*for_init*/false, /*maybe_constp*/NULL); 403 return c_fully_fold (x, /*for_init*/false, /*maybe_constp*/NULL);
365 } 404 }