Commit 326280d4 by Diego Novillo Committed by Diego Novillo

This patch works around a parsing problem with g++ 4.3.

This patch works around a parsing problem with g++ 4.3.  The parser is
failing to lookup calls to the template function reserve when called
from other member functions:

vec_t<T>::reserve<A> (...)

The parser thinks that the '<' in reserve<A> is a less-than operation.
This problem does not happen after 4.3.

This code is going to change significantly, so this won't be needed
soon.

Tested on x86_64 with g++ 4.3 and g++ 4.6.

	PR bootstrap/54478
	* vec.h (vec_t::alloc): Remove explicit type specification
	in call to reserve.
	(vec_t::copy): Likewise.
	(vec_t::reserve): Likewise.
	(vec_t::reserve_exact): Likewise.
	(vec_t::safe_splice): Likewise.
	(vec_t::safe_push): Likewise.
	(vec_t::safe_grow): Likewise.
	(vec_t::safe_grow_cleared): Likewise.
	(vec_t::safe_insert): Likewise.

From-SVN: r190943
parent 96672a3e
2012-09-04 Diego Novillo <dnovillo@google.com>
PR bootstrap/54478
* vec.h (vec_t::alloc): Remove explicit type specification
in call to reserve.
(vec_t::copy): Likewise.
(vec_t::reserve): Likewise.
(vec_t::reserve_exact): Likewise.
(vec_t::safe_splice): Likewise.
(vec_t::safe_push): Likewise.
(vec_t::safe_grow): Likewise.
(vec_t::safe_grow_cleared): Likewise.
(vec_t::safe_insert): Likewise.
2012-09-04 Richard Henderson <rth@redhat.com> 2012-09-04 Richard Henderson <rth@redhat.com>
* alias.c (read_dependence): Return true for ALIAS_SET_MEMORY_BARRIER. * alias.c (read_dependence): Return true for ALIAS_SET_MEMORY_BARRIER.
......
...@@ -655,7 +655,7 @@ template<enum vec_allocation_t A> ...@@ -655,7 +655,7 @@ template<enum vec_allocation_t A>
vec_t<T> * vec_t<T> *
vec_t<T>::alloc (int nelems MEM_STAT_DECL) vec_t<T>::alloc (int nelems MEM_STAT_DECL)
{ {
return vec_t<T>::reserve_exact<A> ((vec_t<T> *) NULL, nelems PASS_MEM_STAT); return reserve_exact<A> ((vec_t<T> *) NULL, nelems PASS_MEM_STAT);
} }
template<typename T> template<typename T>
...@@ -699,8 +699,8 @@ vec_t<T>::copy (ALONE_MEM_STAT_DECL) ...@@ -699,8 +699,8 @@ vec_t<T>::copy (ALONE_MEM_STAT_DECL)
if (len) if (len)
{ {
new_vec = vec_t<T>::reserve_exact<A> (static_cast<vec_t<T> *> (NULL), new_vec = reserve_exact<A> (static_cast<vec_t<T> *> (NULL),
len PASS_MEM_STAT); len PASS_MEM_STAT);
new_vec->embedded_init (len, len); new_vec->embedded_init (len, len);
memcpy (new_vec->address (), vec_, sizeof (T) * len); memcpy (new_vec->address (), vec_, sizeof (T) * len);
} }
...@@ -736,7 +736,7 @@ vec_t<T>::reserve (vec_t<T> **vec, int nelems VEC_CHECK_DECL MEM_STAT_DECL) ...@@ -736,7 +736,7 @@ vec_t<T>::reserve (vec_t<T> **vec, int nelems VEC_CHECK_DECL MEM_STAT_DECL)
bool extend = (*vec) ? !(*vec)->space (nelems VEC_CHECK_PASS) : nelems != 0; bool extend = (*vec) ? !(*vec)->space (nelems VEC_CHECK_PASS) : nelems != 0;
if (extend) if (extend)
*vec = vec_t<T>::reserve<A> (*vec, nelems PASS_MEM_STAT); *vec = reserve<A> (*vec, nelems PASS_MEM_STAT);
return extend; return extend;
} }
...@@ -755,7 +755,7 @@ vec_t<T>::reserve_exact (vec_t<T> **vec, int nelems VEC_CHECK_DECL ...@@ -755,7 +755,7 @@ vec_t<T>::reserve_exact (vec_t<T> **vec, int nelems VEC_CHECK_DECL
bool extend = (*vec) ? !(*vec)->space (nelems VEC_CHECK_PASS) : nelems != 0; bool extend = (*vec) ? !(*vec)->space (nelems VEC_CHECK_PASS) : nelems != 0;
if (extend) if (extend)
*vec = vec_t<T>::reserve_exact<A> (*vec, nelems PASS_MEM_STAT); *vec = reserve_exact<A> (*vec, nelems PASS_MEM_STAT);
return extend; return extend;
} }
...@@ -796,8 +796,7 @@ vec_t<T>::safe_splice (vec_t<T> **dst, vec_t<T> *src VEC_CHECK_DECL ...@@ -796,8 +796,7 @@ vec_t<T>::safe_splice (vec_t<T> **dst, vec_t<T> *src VEC_CHECK_DECL
{ {
if (src) if (src)
{ {
vec_t<T>::reserve_exact<A> (dst, VEC_length (T, src) VEC_CHECK_PASS reserve_exact<A> (dst, VEC_length (T, src) VEC_CHECK_PASS MEM_STAT_INFO);
MEM_STAT_INFO);
(*dst)->splice (src VEC_CHECK_PASS); (*dst)->splice (src VEC_CHECK_PASS);
} }
} }
...@@ -843,7 +842,7 @@ template<enum vec_allocation_t A> ...@@ -843,7 +842,7 @@ template<enum vec_allocation_t A>
T & T &
vec_t<T>::safe_push (vec_t<T> **vec, T obj VEC_CHECK_DECL MEM_STAT_DECL) vec_t<T>::safe_push (vec_t<T> **vec, T obj VEC_CHECK_DECL MEM_STAT_DECL)
{ {
vec_t<T>::reserve<A> (vec, 1 VEC_CHECK_PASS PASS_MEM_STAT); reserve<A> (vec, 1 VEC_CHECK_PASS PASS_MEM_STAT);
return (*vec)->quick_push (obj VEC_CHECK_PASS); return (*vec)->quick_push (obj VEC_CHECK_PASS);
} }
...@@ -858,7 +857,7 @@ template<enum vec_allocation_t A> ...@@ -858,7 +857,7 @@ template<enum vec_allocation_t A>
T * T *
vec_t<T>::safe_push (vec_t<T> **vec, const T *ptr VEC_CHECK_DECL MEM_STAT_DECL) vec_t<T>::safe_push (vec_t<T> **vec, const T *ptr VEC_CHECK_DECL MEM_STAT_DECL)
{ {
vec_t<T>::reserve<A> (vec, 1 VEC_CHECK_PASS PASS_MEM_STAT); reserve<A> (vec, 1 VEC_CHECK_PASS PASS_MEM_STAT);
return (*vec)->quick_push (ptr VEC_CHECK_PASS); return (*vec)->quick_push (ptr VEC_CHECK_PASS);
} }
...@@ -898,8 +897,8 @@ vec_t<T>::safe_grow (vec_t<T> **vec, int size VEC_CHECK_DECL MEM_STAT_DECL) ...@@ -898,8 +897,8 @@ vec_t<T>::safe_grow (vec_t<T> **vec, int size VEC_CHECK_DECL MEM_STAT_DECL)
{ {
VEC_ASSERT (size >= 0 && VEC_length (T, *vec) <= (unsigned)size, VEC_ASSERT (size >= 0 && VEC_length (T, *vec) <= (unsigned)size,
"grow", T, A); "grow", T, A);
vec_t<T>::reserve_exact<A> (vec, size - (int)VEC_length (T, *vec) reserve_exact<A> (vec, size - (int)VEC_length (T, *vec)
VEC_CHECK_PASS PASS_MEM_STAT); VEC_CHECK_PASS PASS_MEM_STAT);
(*vec)->prefix_.num_ = size; (*vec)->prefix_.num_ = size;
} }
...@@ -915,7 +914,7 @@ vec_t<T>::safe_grow_cleared (vec_t<T> **vec, int size VEC_CHECK_DECL ...@@ -915,7 +914,7 @@ vec_t<T>::safe_grow_cleared (vec_t<T> **vec, int size VEC_CHECK_DECL
MEM_STAT_DECL) MEM_STAT_DECL)
{ {
int oldsize = VEC_length (T, *vec); int oldsize = VEC_length (T, *vec);
vec_t<T>::safe_grow<A> (vec, size VEC_CHECK_PASS PASS_MEM_STAT); safe_grow<A> (vec, size VEC_CHECK_PASS PASS_MEM_STAT);
memset (&((*vec)->address ()[oldsize]), 0, sizeof (T) * (size - oldsize)); memset (&((*vec)->address ()[oldsize]), 0, sizeof (T) * (size - oldsize));
} }
...@@ -972,7 +971,7 @@ void ...@@ -972,7 +971,7 @@ void
vec_t<T>::safe_insert (vec_t<T> **vec, unsigned ix, T obj VEC_CHECK_DECL vec_t<T>::safe_insert (vec_t<T> **vec, unsigned ix, T obj VEC_CHECK_DECL
MEM_STAT_DECL) MEM_STAT_DECL)
{ {
vec_t<T>::reserve<A> (vec, 1 VEC_CHECK_PASS PASS_MEM_STAT); reserve<A> (vec, 1 VEC_CHECK_PASS PASS_MEM_STAT);
(*vec)->quick_insert (ix, obj VEC_CHECK_PASS); (*vec)->quick_insert (ix, obj VEC_CHECK_PASS);
} }
...@@ -988,7 +987,7 @@ void ...@@ -988,7 +987,7 @@ void
vec_t<T>::safe_insert (vec_t<T> **vec, unsigned ix, T *ptr VEC_CHECK_DECL vec_t<T>::safe_insert (vec_t<T> **vec, unsigned ix, T *ptr VEC_CHECK_DECL
MEM_STAT_DECL) MEM_STAT_DECL)
{ {
vec_t<T>::reserve<A> (vec, 1 VEC_CHECK_PASS PASS_MEM_STAT); reserve<A> (vec, 1 VEC_CHECK_PASS PASS_MEM_STAT);
(*vec)->quick_insert (ix, ptr VEC_CHECK_PASS); (*vec)->quick_insert (ix, ptr VEC_CHECK_PASS);
} }
......
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