aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/init.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-04-06 10:59:40 -0400
committerJason Merrill <jason@redhat.com>2022-04-06 11:33:31 -0400
commitcc76c502a761ddaee215bcbd8fe4720e46d3b9dd (patch)
treefe7c31789c257c90b6bb7905a9694ff495d19115 /gcc/cp/init.cc
parenteac5c12c1838d51bf05bd6f30f3f5d7bb760e398 (diff)
downloadgcc-cc76c502a761ddaee215bcbd8fe4720e46d3b9dd.zip
gcc-cc76c502a761ddaee215bcbd8fe4720e46d3b9dd.tar.gz
gcc-cc76c502a761ddaee215bcbd8fe4720e46d3b9dd.tar.bz2
c++: -Wunused-value and array init [PR104702]
Here, because of problems with the new warning-control code and expressions that change location, the suppress_warning on the INDIRECT_REF didn't work. Those problems still need to be worked out, but it's simple to avoid needing to use suppress_warning in the first place by using a reference instead. PR c++/104702 gcc/cp/ChangeLog: * init.cc (build_vec_init): Use a reference for the result. gcc/testsuite/ChangeLog: * g++.dg/warn/Wunused-19.C: New test.
Diffstat (limited to 'gcc/cp/init.cc')
-rw-r--r--gcc/cp/init.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index 01e7623..c20ed21 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -4908,10 +4908,9 @@ build_vec_init (tree base, tree maxindex, tree init,
/* Now make the result have the correct type. */
if (TREE_CODE (atype) == ARRAY_TYPE)
{
- atype = build_pointer_type (atype);
+ atype = build_reference_type (atype);
stmt_expr = build1 (NOP_EXPR, atype, stmt_expr);
- stmt_expr = cp_build_fold_indirect_ref (stmt_expr);
- suppress_warning (stmt_expr /* What warning? */);
+ stmt_expr = convert_from_reference (stmt_expr);
}
return stmt_expr;