@@ -532,6 +532,27 @@ build_unary_op (tree_code code, tree type, tree arg)
532532 return compound_expr (TREE_OPERAND (arg, 0 ), result);
533533 }
534534
535+ if (code == ADDR_EXPR)
536+ {
537+ /* Can't take the address of a manifest constant, get the real value of
538+ the decl instead. */
539+ if (TREE_CODE (arg) == CONST_DECL)
540+ arg = DECL_INITIAL (arg);
541+
542+ /* Some expression lowering may request an address of a compile-time
543+ constant. Make sure it is assigned to a location we can reference. */
544+ if (CONSTANT_CLASS_P (arg) && TREE_CODE (arg) != STRING_CST)
545+ arg = force_target_expr (arg);
546+
547+ d_mark_addressable (arg);
548+ tree result = build_fold_addr_expr_with_type_loc (input_location, arg,
549+ type);
550+ if (TREE_CODE (result) == ADDR_EXPR)
551+ TREE_NO_TRAMPOLINE (result) = 1 ;
552+
553+ return result;
554+ }
555+
535556 return fold_build1_loc (input_location, code, type, arg);
536557}
537558
@@ -624,25 +645,7 @@ build_address (tree exp)
624645 else
625646 ptrtype = build_pointer_type (type);
626647
627- /* Maybe rewrite: &(e1, e2) => (e1, &e2). */
628- tree init = stabilize_expr (&exp);
629-
630- /* Can't take the address of a manifest constant, instead use its value. */
631- if (TREE_CODE (exp) == CONST_DECL)
632- exp = DECL_INITIAL (exp);
633-
634- /* Some expression lowering may request an address of a compile-time constant.
635- Make sure it is assigned to a location we can reference. */
636- if (CONSTANT_CLASS_P (exp) && TREE_CODE (exp) != STRING_CST)
637- exp = force_target_expr (exp);
638-
639- d_mark_addressable (exp);
640- exp = build_fold_addr_expr_with_type_loc (input_location, exp, ptrtype);
641-
642- if (TREE_CODE (exp) == ADDR_EXPR)
643- TREE_NO_TRAMPOLINE (exp) = 1 ;
644-
645- return compound_expr (init, exp);
648+ return build_unary_op (ADDR_EXPR, ptrtype, exp);
646649}
647650
648651/* Mark EXP saying that we need to be able to take the
0 commit comments