Commit 7f16ac89 by Jason Merrill Committed by Jason Merrill

PR c++/86485 - -Wmaybe-unused with empty class ?:

	* typeck.c (build_static_cast_1): Use cp_build_addr_expr.

For GCC 9 I fixed this bug with a patch to gimplify_cond_expr, but this
function was also doing the wrong thing.

Using build_address does not push the ADDR_EXPR down into the arms of a
COND_EXPR, which we need for proper handling of conversion of an lvalue ?:
to another reference type.

From-SVN: r270985
parent 258195f1
2019-05-07 Jason Merrill <jason@redhat.com> 2019-05-07 Jason Merrill <jason@redhat.com>
PR c++/86485 - -Wmaybe-unused with empty class ?:
* typeck.c (build_static_cast_1): Use cp_build_addr_expr.
* pt.c (type_dependent_expression_p): A non-type template parm with * pt.c (type_dependent_expression_p): A non-type template parm with
a placeholder type is type-dependent. a placeholder type is type-dependent.
......
...@@ -5916,7 +5916,8 @@ condition_conversion (tree expr) ...@@ -5916,7 +5916,8 @@ condition_conversion (tree expr)
} }
/* Returns the address of T. This function will fold away /* Returns the address of T. This function will fold away
ADDR_EXPR of INDIRECT_REF. */ ADDR_EXPR of INDIRECT_REF. This is only for low-level usage;
most places should use cp_build_addr_expr instead. */
tree tree
build_address (tree t) build_address (tree t)
...@@ -7114,7 +7115,7 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, ...@@ -7114,7 +7115,7 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p,
base = lookup_base (TREE_TYPE (type), intype, base = lookup_base (TREE_TYPE (type), intype,
c_cast_p ? ba_unique : ba_check, c_cast_p ? ba_unique : ba_check,
NULL, complain); NULL, complain);
expr = build_address (expr); expr = cp_build_addr_expr (expr, complain);
if (sanitize_flags_p (SANITIZE_VPTR)) if (sanitize_flags_p (SANITIZE_VPTR))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment