summaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2012-09-10 14:08:24 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2012-09-10 14:08:24 +0000
commit952fcfec62858c21914af650a7b319f5417990f3 (patch)
treef09bc89964b895bcf2c4423ab885af79b02f0895 /gcc/cp/semantics.c
parent3ee6dc489b8ba6dcc8c8f13cd827185a7d88669d (diff)
downloadgcc-952fcfec62858c21914af650a7b319f5417990f3.tar.gz
* semantics.c (sort_constexpr_mem_initializers): Tweak.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 7cd1468dba5..642e15d553d 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5903,24 +5903,26 @@ check_constexpr_ctor_body (tree last, tree list)
static VEC(constructor_elt,gc) *
sort_constexpr_mem_initializers (tree type, VEC(constructor_elt,gc) *vec)
{
- if (!CLASSTYPE_HAS_PRIMARY_BASE_P (type)
- || (CLASSTYPE_PRIMARY_BINFO (type)
- == BINFO_BASE_BINFO (TYPE_BINFO (type), 0)))
+ tree pri = CLASSTYPE_PRIMARY_BINFO (type);
+ constructor_elt elt;
+ int i;
+
+ if (pri == NULL_TREE
+ || pri == BINFO_BASE_BINFO (TYPE_BINFO (type), 0))
return vec;
/* Find the element for the primary base and move it to the beginning of
the vec. */
- tree pri = BINFO_TYPE (CLASSTYPE_PRIMARY_BINFO (type));
VEC(constructor_elt,gc) &v = *vec;
- int pri_idx;
-
- for (pri_idx = 1; ; ++pri_idx)
- if (TREE_TYPE (v[pri_idx].index) == pri)
+ pri = BINFO_TYPE (pri);
+ for (i = 1; ; ++i)
+ if (TREE_TYPE (v[i].index) == pri)
break;
- constructor_elt pri_elt = v[pri_idx];
- for (int i = 0; i < pri_idx; ++i)
- v[i+1] = v[i];
- v[0] = pri_elt;
+
+ elt = v[i];
+ for (; i > 0; --i)
+ v[i] = v[i-1];
+ v[0] = elt;
return vec;
}