Patchwork [google] Remove unqualified lookups which break clang (issue4439085)

login
register
mail settings
Submitter Ollie Wild
Date May 2, 2011, 2:34 p.m.
Message ID <20110502143448.5CBBD5F886@wpgntat-ubiq14.hot.corp.google.com>
Download mbox | patch
Permalink /patch/93669/
State New
Headers show

Comments

Ollie Wild - May 2, 2011, 2:34 p.m.
commit 99835abc5d2a7fd3ae0950c8a16fd6d223d408c9
Author: Ollie Wild <aaw@google.com>
Date:   Fri Apr 29 13:03:57 2011 -0400

    Remove unqualified lookups into dependent template base classes from
    STL headers.  These break clang.
    
    See http://clang.llvm.org/compatibility.html#dep_lookup_bases.

    To be applied to google/main.  Would also like permissiont to submit to
    trunk.

M	libstdc++-v3/include/ext/sso_string_base.h
M	libstdc++-v3/include/ext/vstring.h
M	libstdc++-v3/include/ext/vstring.tcc

Tested:
  Tested via buildit bootstrap and tests.

ChangeLog:

2011-05-02  Ollie Wild  <aaw@google.com>

	* include/ext/sso_string_base.h (__sso_string_base<>::_M_construct):
	Fix unqualified lookup.
	(__sso_string_base<>::_M_construct): Likewise.
	(__sso_string_base<>::_M_construct): Likewise.
	(__sso_string_base<>::_M_assign): Likewise.
	(__sso_string_base<>::_M_reserve): Likewise.
	(__sso_string_base<>::_M_mutate): Likewise.
	(__sso_string_base<>::_M_erase): Likewise.
	* include/ext/vstring.h (__versa_string<>::replace): Likewise.
	(__versa_string<>::compare): Likewise.
	* include/ext/vstring.tcc (__versa_string<>::compare): Likewise.
	(__versa_string<>::compare): Likewise.
	(__versa_string<>::compare): Likewise.
	(__versa_string<>::compare): Likewise.
	(__versa_string<>::compare): Likewise.


--
This patch is available for review at http://codereview.appspot.com/4439085
Diego Novillo - May 2, 2011, 2:37 p.m.
On Mon, May 2, 2011 at 10:34, Ollie Wild <aaw@google.com> wrote:

> 2011-05-02  Ollie Wild  <aaw@google.com>
>
>        * include/ext/sso_string_base.h (__sso_string_base<>::_M_construct):
>        Fix unqualified lookup.
>        (__sso_string_base<>::_M_construct): Likewise.
>        (__sso_string_base<>::_M_construct): Likewise.
>        (__sso_string_base<>::_M_assign): Likewise.
>        (__sso_string_base<>::_M_reserve): Likewise.
>        (__sso_string_base<>::_M_mutate): Likewise.
>        (__sso_string_base<>::_M_erase): Likewise.
>        * include/ext/vstring.h (__versa_string<>::replace): Likewise.
>        (__versa_string<>::compare): Likewise.
>        * include/ext/vstring.tcc (__versa_string<>::compare): Likewise.
>        (__versa_string<>::compare): Likewise.
>        (__versa_string<>::compare): Likewise.
>        (__versa_string<>::compare): Likewise.
>        (__versa_string<>::compare): Likewise.

OK for google/main.


Diego.
Ollie Wild - May 2, 2011, 2:52 p.m.
Submitted to google/main.

Adding libstdc++@gcc.gnu.org for trunk approval.

Ollie

On Mon, May 2, 2011 at 9:34 AM, Ollie Wild <aaw@google.com> wrote:
>
> commit 99835abc5d2a7fd3ae0950c8a16fd6d223d408c9
> Author: Ollie Wild <aaw@google.com>
> Date:   Fri Apr 29 13:03:57 2011 -0400
>
>    Remove unqualified lookups into dependent template base classes from
>    STL headers.  These break clang.
>
>    See http://clang.llvm.org/compatibility.html#dep_lookup_bases.
>
>    To be applied to google/main.  Would also like permissiont to submit to
>    trunk.
>
> M       libstdc++-v3/include/ext/sso_string_base.h
> M       libstdc++-v3/include/ext/vstring.h
> M       libstdc++-v3/include/ext/vstring.tcc
>
> Tested:
>  Tested via buildit bootstrap and tests.
>
> ChangeLog:
>
> 2011-05-02  Ollie Wild  <aaw@google.com>
>
>        * include/ext/sso_string_base.h (__sso_string_base<>::_M_construct):
>        Fix unqualified lookup.
>        (__sso_string_base<>::_M_construct): Likewise.
>        (__sso_string_base<>::_M_construct): Likewise.
>        (__sso_string_base<>::_M_assign): Likewise.
>        (__sso_string_base<>::_M_reserve): Likewise.
>        (__sso_string_base<>::_M_mutate): Likewise.
>        (__sso_string_base<>::_M_erase): Likewise.
>        * include/ext/vstring.h (__versa_string<>::replace): Likewise.
>        (__versa_string<>::compare): Likewise.
>        * include/ext/vstring.tcc (__versa_string<>::compare): Likewise.
>        (__versa_string<>::compare): Likewise.
>        (__versa_string<>::compare): Likewise.
>        (__versa_string<>::compare): Likewise.
>        (__versa_string<>::compare): Likewise.
>
> diff --git a/libstdc++-v3/include/ext/sso_string_base.h b/libstdc++-v3/include/ext/sso_string_base.h
> index 638eeba..39a62d6 100644
> --- a/libstdc++-v3/include/ext/sso_string_base.h
> +++ b/libstdc++-v3/include/ext/sso_string_base.h
> @@ -432,7 +432,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>                    // Allocate more space.
>                    __capacity = __len + 1;
>                    _CharT* __another = _M_create(__capacity, __len);
> -                   _S_copy(__another, _M_data(), __len);
> +                   this->_S_copy(__another, _M_data(), __len);
>                    _M_dispose();
>                    _M_data(__another);
>                    _M_capacity(__capacity);
> @@ -472,7 +472,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>
>        // Check for out_of_range and length_error exceptions.
>        __try
> -         { _S_copy_chars(_M_data(), __beg, __end); }
> +         { this->_S_copy_chars(_M_data(), __beg, __end); }
>        __catch(...)
>          {
>            _M_dispose();
> @@ -494,7 +494,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>        }
>
>       if (__n)
> -       _S_assign(_M_data(), __n, __c);
> +       this->_S_assign(_M_data(), __n, __c);
>
>       _M_set_length_no_wipe(__n);
>     }
> @@ -519,7 +519,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>            }
>
>          if (__rsize)
> -           _S_copy(_M_data(), __rcs._M_data(), __rsize);
> +           this->_S_copy(_M_data(), __rcs._M_data(), __rsize);
>
>          _M_set_length(__rsize);
>        }
> @@ -541,14 +541,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>              || __res > size_type(_S_local_capacity))
>            {
>              _CharT* __tmp = _M_create(__res, __capacity);
> -             _S_copy(__tmp, _M_data(), _M_length() + 1);
> +             this->_S_copy(__tmp, _M_data(), _M_length() + 1);
>              _M_dispose();
>              _M_data(__tmp);
>              _M_capacity(__res);
>            }
>          else if (!_M_is_local())
>            {
> -             _S_copy(_M_local_data, _M_data(), _M_length() + 1);
> +             this->_S_copy(_M_local_data, _M_data(), _M_length() + 1);
>              _M_destroy(__capacity);
>              _M_data(_M_local_data);
>            }
> @@ -567,12 +567,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       _CharT* __r = _M_create(__new_capacity, _M_capacity());
>
>       if (__pos)
> -       _S_copy(__r, _M_data(), __pos);
> +       this->_S_copy(__r, _M_data(), __pos);
>       if (__s && __len2)
> -       _S_copy(__r + __pos, __s, __len2);
> +       this->_S_copy(__r + __pos, __s, __len2);
>       if (__how_much)
> -       _S_copy(__r + __pos + __len2,
> -               _M_data() + __pos + __len1, __how_much);
> +       this->_S_copy(__r + __pos + __len2,
> +                     _M_data() + __pos + __len1, __how_much);
>
>       _M_dispose();
>       _M_data(__r);
> @@ -587,8 +587,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       const size_type __how_much = _M_length() - __pos - __n;
>
>       if (__how_much && __n)
> -       _S_move(_M_data() + __pos, _M_data() + __pos + __n,
> -               __how_much);
> +       this->_S_move(_M_data() + __pos, _M_data() + __pos + __n, __how_much);
>
>       _M_set_length(_M_length() - __n);
>     }
> diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
> index 90a5683..57f36a6 100644
> --- a/libstdc++-v3/include/ext/vstring.h
> +++ b/libstdc++-v3/include/ext/vstring.h
> @@ -1374,7 +1374,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>                                   && __i2 <= _M_iend());
>          __glibcxx_requires_valid_range(__k1, __k2);
>          typedef typename std::__is_integer<_InputIterator>::__type _Integral;
> -         return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
> +         return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
>        }
>
>       // Specializations for the common case of pointer and iterator:
> @@ -1929,7 +1929,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>
>        int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
>        if (!__r)
> -         __r = _S_compare(__size, __osize);
> +         __r = this->_S_compare(__size, __osize);
>        return __r;
>       }
>
> diff --git a/libstdc++-v3/include/ext/vstring.tcc b/libstdc++-v3/include/ext/vstring.tcc
> index e36058b..588985b 100644
> --- a/libstdc++-v3/include/ext/vstring.tcc
> +++ b/libstdc++-v3/include/ext/vstring.tcc
> @@ -466,7 +466,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       int __r = traits_type::compare(this->_M_data() + __pos,
>                                     __str.data(), __len);
>       if (!__r)
> -       __r = _S_compare(__n, __osize);
> +       __r = this->_S_compare(__n, __osize);
>       return __r;
>     }
>
> @@ -485,7 +485,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       int __r = traits_type::compare(this->_M_data() + __pos1,
>                                     __str.data() + __pos2, __len);
>       if (!__r)
> -       __r = _S_compare(__n1, __n2);
> +       __r = this->_S_compare(__n1, __n2);
>       return __r;
>     }
>
> @@ -501,7 +501,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       const size_type __len = std::min(__size, __osize);
>       int __r = traits_type::compare(this->_M_data(), __s, __len);
>       if (!__r)
> -       __r = _S_compare(__size, __osize);
> +       __r = this->_S_compare(__size, __osize);
>       return __r;
>     }
>
> @@ -518,7 +518,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       const size_type __len = std::min(__n1, __osize);
>       int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);
>       if (!__r)
> -       __r = _S_compare(__n1, __osize);
> +       __r = this->_S_compare(__n1, __osize);
>       return __r;
>     }
>
> @@ -535,7 +535,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       const size_type __len = std::min(__n1, __n2);
>       int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);
>       if (!__r)
> -       __r = _S_compare(__n1, __n2);
> +       __r = this->_S_compare(__n1, __n2);
>       return __r;
>     }
>
>
> --
> This patch is available for review at http://codereview.appspot.com/4439085
Paolo Carlini - May 2, 2011, 2:58 p.m.
On 05/02/2011 04:52 PM, Ollie Wild wrote:
> Submitted to google/main.
>
> Adding libstdc++@gcc.gnu.org for trunk approval.
This is Ok for mainline and 4_6-branch.

Why nobody noticed so far? Is there a latent C++ front-end bug? Please 
double check (the last time, I took care of filing the corresponding C++ 
front-end issue)

Paolo.
Paolo Carlini - May 2, 2011, 3:19 p.m.
On 05/02/2011 04:58 PM, Paolo Carlini wrote:
> Why nobody noticed so far? Is there a latent C++ front-end bug? Please 
> double check (the last time, I took care of filing the corresponding 
> C++ front-end issue)
-- Jason,

is it known that we accept the below?

Paolo.

//////////////////

template<typename T>
   struct base
   {
     void bar(T) { }
   };

template<typename T>
   struct derived
   : base<T>
   {
     void
     foo(T t)
     { bar(t); }
   };

template class derived<int>;
Paolo Carlini - May 2, 2011, 3:32 p.m.
On 05/02/2011 05:19 PM, Paolo Carlini wrote:
> template<typename T>
>   struct base
>   {
>     void bar(T) { }
>   };
>
> template<typename T>
>   struct derived
>   : base<T>
>   {
>     void
>     foo(T t)
>     { bar(t); }
>   };
>
> template class derived<int>;
Gosh, c++/24163

Paolo.

Patch

diff --git a/libstdc++-v3/include/ext/sso_string_base.h b/libstdc++-v3/include/ext/sso_string_base.h
index 638eeba..39a62d6 100644
--- a/libstdc++-v3/include/ext/sso_string_base.h
+++ b/libstdc++-v3/include/ext/sso_string_base.h
@@ -432,7 +432,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    // Allocate more space.
 		    __capacity = __len + 1;
 		    _CharT* __another = _M_create(__capacity, __len);
-		    _S_copy(__another, _M_data(), __len);
+		    this->_S_copy(__another, _M_data(), __len);
 		    _M_dispose();
 		    _M_data(__another);
 		    _M_capacity(__capacity);
@@ -472,7 +472,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 	// Check for out_of_range and length_error exceptions.
 	__try
-	  { _S_copy_chars(_M_data(), __beg, __end); }
+	  { this->_S_copy_chars(_M_data(), __beg, __end); }
 	__catch(...)
 	  {
 	    _M_dispose();
@@ -494,7 +494,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
 
       if (__n)
-	_S_assign(_M_data(), __n, __c);
+	this->_S_assign(_M_data(), __n, __c);
 
       _M_set_length_no_wipe(__n);
     }
@@ -519,7 +519,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	    }
 
 	  if (__rsize)
-	    _S_copy(_M_data(), __rcs._M_data(), __rsize);
+	    this->_S_copy(_M_data(), __rcs._M_data(), __rsize);
 
 	  _M_set_length(__rsize);
 	}
@@ -541,14 +541,14 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	      || __res > size_type(_S_local_capacity))
 	    {
 	      _CharT* __tmp = _M_create(__res, __capacity);
-	      _S_copy(__tmp, _M_data(), _M_length() + 1);
+	      this->_S_copy(__tmp, _M_data(), _M_length() + 1);
 	      _M_dispose();
 	      _M_data(__tmp);
 	      _M_capacity(__res);
 	    }
 	  else if (!_M_is_local())
 	    {
-	      _S_copy(_M_local_data, _M_data(), _M_length() + 1);
+	      this->_S_copy(_M_local_data, _M_data(), _M_length() + 1);
 	      _M_destroy(__capacity);
 	      _M_data(_M_local_data);
 	    }
@@ -567,12 +567,12 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _CharT* __r = _M_create(__new_capacity, _M_capacity());
 
       if (__pos)
-	_S_copy(__r, _M_data(), __pos);
+	this->_S_copy(__r, _M_data(), __pos);
       if (__s && __len2)
-	_S_copy(__r + __pos, __s, __len2);
+	this->_S_copy(__r + __pos, __s, __len2);
       if (__how_much)
-	_S_copy(__r + __pos + __len2,
-		_M_data() + __pos + __len1, __how_much);
+	this->_S_copy(__r + __pos + __len2,
+		      _M_data() + __pos + __len1, __how_much);
       
       _M_dispose();
       _M_data(__r);
@@ -587,8 +587,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const size_type __how_much = _M_length() - __pos - __n;
 
       if (__how_much && __n)
-	_S_move(_M_data() + __pos, _M_data() + __pos + __n,
-		__how_much);
+	this->_S_move(_M_data() + __pos, _M_data() + __pos + __n, __how_much);
 
       _M_set_length(_M_length() - __n);
     }
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index 90a5683..57f36a6 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -1374,7 +1374,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 				   && __i2 <= _M_iend());
 	  __glibcxx_requires_valid_range(__k1, __k2);
 	  typedef typename std::__is_integer<_InputIterator>::__type _Integral;
-	  return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
+	  return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
 	}
 
       // Specializations for the common case of pointer and iterator:
@@ -1929,7 +1929,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 	int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
 	if (!__r)
-	  __r = _S_compare(__size, __osize);
+	  __r = this->_S_compare(__size, __osize);
 	return __r;
       }
 
diff --git a/libstdc++-v3/include/ext/vstring.tcc b/libstdc++-v3/include/ext/vstring.tcc
index e36058b..588985b 100644
--- a/libstdc++-v3/include/ext/vstring.tcc
+++ b/libstdc++-v3/include/ext/vstring.tcc
@@ -466,7 +466,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       int __r = traits_type::compare(this->_M_data() + __pos,
 				     __str.data(), __len);
       if (!__r)
-	__r = _S_compare(__n, __osize);
+	__r = this->_S_compare(__n, __osize);
       return __r;
     }
 
@@ -485,7 +485,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       int __r = traits_type::compare(this->_M_data() + __pos1,
 				     __str.data() + __pos2, __len);
       if (!__r)
-	__r = _S_compare(__n1, __n2);
+	__r = this->_S_compare(__n1, __n2);
       return __r;
     }
 
@@ -501,7 +501,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const size_type __len = std::min(__size, __osize);
       int __r = traits_type::compare(this->_M_data(), __s, __len);
       if (!__r)
-	__r = _S_compare(__size, __osize);
+	__r = this->_S_compare(__size, __osize);
       return __r;
     }
 
@@ -518,7 +518,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const size_type __len = std::min(__n1, __osize);
       int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);
       if (!__r)
-	__r = _S_compare(__n1, __osize);
+	__r = this->_S_compare(__n1, __osize);
       return __r;
     }
 
@@ -535,7 +535,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const size_type __len = std::min(__n1, __n2);
       int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);
       if (!__r)
-	__r = _S_compare(__n1, __n2);
+	__r = this->_S_compare(__n1, __n2);
       return __r;
     }