Skip to content

Commit

Permalink
/cp
Browse files Browse the repository at this point in the history
2014-04-04  Paolo Carlini  <[email protected]>

	PR c++/58207
	* semantics.c (sort_constexpr_mem_initializers): Robustify loop.

/testsuite
2014-04-04  Paolo Carlini  <[email protected]>

	PR c++/58207
	* g++.dg/cpp0x/constexpr-ice15.C: New.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209128 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
paolo committed Apr 4, 2014
1 parent 12b772b commit fb73bd5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
5 changes: 5 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2014-04-04 Paolo Carlini <[email protected]>

PR c++/58207
* semantics.c (sort_constexpr_mem_initializers): Robustify loop.

2014-04-04 Patrick Palka <[email protected]>

PR c++/44613
Expand Down
14 changes: 7 additions & 7 deletions gcc/cp/semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -7720,8 +7720,8 @@ sort_constexpr_mem_initializers (tree type, vec<constructor_elt, va_gc> *v)
{
tree pri = CLASSTYPE_PRIMARY_BINFO (type);
tree field_type;
constructor_elt elt;
int i;
unsigned i;
constructor_elt *ce;

if (pri)
field_type = BINFO_TYPE (pri);
Expand All @@ -7732,14 +7732,14 @@ sort_constexpr_mem_initializers (tree type, vec<constructor_elt, va_gc> *v)

/* Find the element for the primary base or vptr and move it to the
beginning of the vec. */
vec<constructor_elt, va_gc> &vref = *v;
for (i = 0; ; ++i)
if (TREE_TYPE (vref[i].index) == field_type)
for (i = 0; vec_safe_iterate (v, i, &ce); ++i)
if (TREE_TYPE (ce->index) == field_type)
break;

if (i > 0)
if (i > 0 && i < vec_safe_length (v))
{
elt = vref[i];
vec<constructor_elt, va_gc> &vref = *v;
constructor_elt elt = vref[i];
for (; i > 0; --i)
vref[i] = vref[i-1];
vref[0] = elt;
Expand Down
5 changes: 5 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2014-04-04 Paolo Carlini <[email protected]>

PR c++/58207
* g++.dg/cpp0x/constexpr-ice15.C: New.

2014-04-04 Jan Hubicka <[email protected]>

PR ipa/59626
Expand Down
12 changes: 12 additions & 0 deletions gcc/testsuite/g++.dg/cpp0x/constexpr-ice15.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// PR c++/58207
// { dg-do compile { target c++11 } }

struct A
{
virtual bool foo ();
};

struct B : public A
{
constexpr B () : A (&::n) {} // { dg-error "declared" }
};

0 comments on commit fb73bd5

Please sign in to comment.