This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] PR 70501, ICE in verify ctor sanity
- From: Nathan Sidwell <nathan at acm dot org>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 7 Apr 2016 08:18:28 -0700
- Subject: Re: [C++ PATCH] PR 70501, ICE in verify ctor sanity
- Authentication-results: sourceware.org; auth=none
- References: <5702A3C5 dot 20103 at acm dot org> <570414B0 dot 7090703 at redhat dot com> <57042C71 dot 5000205 at acm dot org> <570521EC dot 4070104 at redhat dot com>
On 04/06/16 07:49, Jason Merrill wrote:
Sure, but that also seems unnecessary; vector rvalues don't have object identity
the way class and array rvalues do.
I attach 2 patches.
70501-2.patch fixes the ICE by treating VECTOR_TYPEs thesame as PMFs in
cxx_eval_bare_aggregate).
70501-other.patch stops finish_compound_literal wrapping VECTOR_TYPEs in a
TARGET_EXPR. And also moves the comments around, as I found them a little
confusing. We might want to wait until 7.0 to apply that patch, as it's not a
regression.
For avoidance of doubt I tested the first patch both with and without the second
patch.
ok?
nathan
2016-04-06 Nathan Sidwell <nathan@acm.org>
PR c++/70501
* constexpr.c (cxx_eval_bare_aggregate): Handle VECTOR_TYPE
similarly to PMF.
* g++.dg/init/pr70501.C: New.
Index: cp/constexpr.c
===================================================================
--- cp/constexpr.c (revision 234768)
+++ cp/constexpr.c (working copy)
@@ -2370,10 +2370,10 @@ cxx_eval_bare_aggregate (const constexpr
tree type = TREE_TYPE (t);
constexpr_ctx new_ctx;
- if (TYPE_PTRMEMFUNC_P (type))
+ if (TYPE_PTRMEMFUNC_P (type) || VECTOR_TYPE_P (type))
{
- /* We don't really need the ctx->ctor business for a PMF, but it's
- simpler to use the same code. */
+ /* We don't really need the ctx->ctor business for a PMF or
+ vector, but it's simpler to use the same code. */
new_ctx = *ctx;
new_ctx.ctor = build_constructor (type, NULL);
new_ctx.object = NULL_TREE;
Index: testsuite/g++.dg/init/pr70501.C
===================================================================
--- testsuite/g++.dg/init/pr70501.C (nonexistent)
+++ testsuite/g++.dg/init/pr70501.C (working copy)
@@ -0,0 +1,11 @@
+/* { dg-options "" } Not pedantic */
+
+typedef int v4si __attribute__ ((vector_size (16)));
+
+struct S { v4si v; };
+
+void
+fn2 (int i, int j)
+{
+ struct S s = { .v = i <= j + (v4si){(1, 2)} };
+}
2016-04-06 Nathan Sidwell <nathan@acm.org>
* semantics.c (finish_compound_lteral): Don't wrap VECTOR_TYPEs in a
TARGET_EXPR.
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 234768)
+++ cp/semantics.c (working copy)
@@ -2732,8 +2732,8 @@ finish_compound_literal (tree type, tree
compound_literal = digest_init (type, compound_literal, complain);
if (TREE_CODE (compound_literal) == CONSTRUCTOR)
TREE_HAS_CONSTRUCTOR (compound_literal) = true;
- /* Put static/constant array temporaries in static variables, but always
- represent class temporaries with TARGET_EXPR so we elide copies. */
+
+ /* Put static/constant array temporaries in static variables. */
if ((!at_function_scope_p () || CP_TYPE_CONST_P (type))
&& TREE_CODE (type) == ARRAY_TYPE
&& !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
@@ -2763,8 +2763,13 @@ finish_compound_literal (tree type, tree
return error_mark_node;
return decl;
}
- else
- return get_target_expr_sfinae (compound_literal, complain);
+
+ /* Represent other compound literals with TARGET_EXPR so we produce
+ an lvalue, but can elide copies. */
+ if (!VECTOR_TYPE_P (type))
+ compound_literal = get_target_expr_sfinae (compound_literal, complain);
+
+ return compound_literal;
}
/* Return the declaration for the function-name variable indicated by