Patchwork Fix bootstrap failure with clang++ (PR 54484)

login
register
mail settings
Submitter Diego Novillo
Date Sept. 4, 2012, 9:07 p.m.
Message ID <20120904210720.GA11199@google.com>
Download mbox | patch
Permalink /patch/181681/
State New
Headers show

Comments

Diego Novillo - Sept. 4, 2012, 9:07 p.m.
Fix bootstrap failure with clang++.

This patch fixes a bootstrap failure when using clang as the host
compiler.  Default arguments for class template member functions
should be added in the declaration, not the definition.

From Jason:

> 8.3.6 says "Default arguments for a member function of a class template shall
> be specified on the initial declaration of the member function within the
> class template."

2012-09-04  Diego Novillo  <dnovillo@google.com>

	PR bootstrap/54484
	* vec.h (vec_t::embedded_init): Move default argument value
	to function declaration.
Steven Bosscher - Sept. 4, 2012, 9:10 p.m.
On Tue, Sep 4, 2012 at 11:07 PM, Diego Novillo <dnovillo@google.com> wrote:
> Fix bootstrap failure with clang++.
>
> This patch fixes a bootstrap failure when using clang as the host
> compiler.  Default arguments for class template member functions
> should be added in the declaration, not the definition.
>
> From Jason:
>
>> 8.3.6 says "Default arguments for a member function of a class template shall
>> be specified on the initial declaration of the member function within the
>> class template."

If GCC doesn't diagnose this, what is there to avoid this problem in the future?

Ciao!
Steven
Diego Novillo - Sept. 4, 2012, 9:12 p.m.
On 2012-09-04 17:10 , Steven Bosscher wrote:
> On Tue, Sep 4, 2012 at 11:07 PM, Diego Novillo <dnovillo@google.com> wrote:
>> Fix bootstrap failure with clang++.
>>
>> This patch fixes a bootstrap failure when using clang as the host
>> compiler.  Default arguments for class template member functions
>> should be added in the declaration, not the definition.
>>
>>  From Jason:
>>
>>> 8.3.6 says "Default arguments for a member function of a class template shall
>>> be specified on the initial declaration of the member function within the
>>> class template."
>
> If GCC doesn't diagnose this, what is there to avoid this problem in the future?

I'm filing a separate PR for this.


Diego
Diego Novillo - Sept. 4, 2012, 9:28 p.m.
On 2012-09-04 17:10 , Steven Bosscher wrote:
> On Tue, Sep 4, 2012 at 11:07 PM, Diego Novillo <dnovillo@google.com> wrote:
>> Fix bootstrap failure with clang++.
>>
>> This patch fixes a bootstrap failure when using clang as the host
>> compiler.  Default arguments for class template member functions
>> should be added in the declaration, not the definition.
>>
>>  From Jason:
>>
>>> 8.3.6 says "Default arguments for a member function of a class template shall
>>> be specified on the initial declaration of the member function within the
>>> class template."
>
> If GCC doesn't diagnose this, what is there to avoid this problem in the future?

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54485


Diego.

Patch

diff --git a/gcc/vec.h b/gcc/vec.h
index c0f1bb2..441c9b5 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -171,7 +171,7 @@  struct GTY(()) vec_t
   T &last (ALONE_VEC_CHECK_DECL);
   const T &operator[] (unsigned) const;
   T &operator[] (unsigned);
-  void embedded_init (int, int);
+  void embedded_init (int, int = 0);
 
   template<enum vec_allocation_t A>
   vec_t<T> *copy (ALONE_MEM_STAT_DECL);
@@ -599,7 +599,7 @@  vec_t<T>::iterate (const vec_t<T> *vec, unsigned ix, T **ptr)
    final member):
 
    size_t vec_t<T>::embedded_size<T> (int reserve);
-   void v->embedded_init(int reserve, int active = 0);
+   void v->embedded_init(int reserve, int active);
 
    These allow the caller to perform the memory allocation.  */
 
@@ -616,7 +616,7 @@  vec_t<T>::embedded_size (int nelems)
 
 template<typename T>
 void
-vec_t<T>::embedded_init (int nelems, int active = 0)
+vec_t<T>::embedded_init (int nelems, int active)
 {
   prefix_.num_ = active;
   prefix_.alloc_ = nelems;