Patchwork [libstdc++] : Avoid the badname __alpha

login
register
mail settings
Submitter Uros Bizjak
Date Sept. 23, 2012, 11:30 a.m.
Message ID <CAFULd4aeBHFGLGPyUbpQoopp+7EmxKCTLNCVWrC9Np-jNBtfSw@mail.gmail.com>
Download mbox | patch
Permalink /patch/186207/
State New
Headers show

Comments

Uros Bizjak - Sept. 23, 2012, 11:30 a.m.
Hello!

__alpha interferes with system define for alpha-unknown-linux-gnu targets.

I have took the same approach as for PR libstdc++/39835 and for
consistency renamed also other greek letters to __letter_val.

2012-09-23  Uros Bizjak  <ubizjak@gmail.com>

	PR libstdc++/54675
	* include/ext/random: Avoid the badname __alpha (and, for
	consistency, __mu, __nu, __sigma and __omega too).
	* include/bits/random.tcc: Likewise.

Tested on alphaev68-unknown-linux-gnu and x86_64-pc-linux-gnu.

Approved by Paolo in the PR, committed to mainline SVN.

Uros.
Paolo Carlini - Sept. 23, 2012, 6:09 p.m.
On 09/23/2012 01:30 PM, Uros Bizjak wrote:
> Approved by Paolo in the PR, committed to mainline SVN.
Thanks Uros!

By the way, I'm wondering if the front-ends couldn't help us about 
this?!? For sure there is the issue that the list of BADNAMES evolves 
over times, but otherwise I don't see why we couldn't have a specific 
warning - which we could enable while building the libraries - checking 
that no BADNAMES appear in the code.

Opinions?!?

Thanks,
Paolo.

Patch

Index: include/ext/random
===================================================================
--- include/ext/random	(revision 191649)
+++ include/ext/random	(working copy)
@@ -932,9 +932,9 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	typedef rice_distribution<result_type> distribution_type;
 
-	param_type(result_type __nu = result_type(0),
-		   result_type __sigma = result_type(1))
-	: _M_nu(__nu), _M_sigma(__sigma)
+	param_type(result_type __nu_val = result_type(0),
+		   result_type __sigma_val = result_type(1))
+	: _M_nu(__nu_val), _M_sigma(__sigma_val)
 	{
 	  _GLIBCXX_DEBUG_ASSERT(_M_nu >= result_type(0));
 	  _GLIBCXX_DEBUG_ASSERT(_M_sigma > result_type(0));
@@ -964,11 +964,11 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * @brief Constructors.
        */
       explicit
-      rice_distribution(result_type __nu = result_type(0),
-			result_type __sigma = result_type(1))
-      : _M_param(__nu, __sigma),
-	_M_ndx(__nu, __sigma),
-	_M_ndy(result_type(0), __sigma)
+      rice_distribution(result_type __nu_val = result_type(0),
+			result_type __sigma_val = result_type(1))
+      : _M_param(__nu_val, __sigma_val),
+	_M_ndx(__nu_val, __sigma_val),
+	_M_ndy(result_type(0), __sigma_val)
       { }
 
       explicit
@@ -1166,9 +1166,9 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	typedef nakagami_distribution<result_type> distribution_type;
 
-	param_type(result_type __mu = result_type(1),
-		   result_type __omega = result_type(1))
-	: _M_mu(__mu), _M_omega(__omega)
+	param_type(result_type __mu_val = result_type(1),
+		   result_type __omega_val = result_type(1))
+	: _M_mu(__mu_val), _M_omega(__omega_val)
 	{
 	  _GLIBCXX_DEBUG_ASSERT(_M_mu >= result_type(0.5L));
 	  _GLIBCXX_DEBUG_ASSERT(_M_omega > result_type(0));
@@ -1198,10 +1198,10 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * @brief Constructors.
        */
       explicit
-      nakagami_distribution(result_type __mu = result_type(1),
-			    result_type __omega = result_type(1))
-      : _M_param(__mu, __omega),
-	_M_gd(__mu, __omega / __mu)
+      nakagami_distribution(result_type __mu_val = result_type(1),
+			    result_type __omega_val = result_type(1))
+      : _M_param(__mu_val, __omega_val),
+	_M_gd(__mu_val, __omega_val / __mu_val)
       { }
 
       explicit
@@ -1399,9 +1399,9 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	typedef pareto_distribution<result_type> distribution_type;
 
-	param_type(result_type __alpha = result_type(1),
-		   result_type __mu = result_type(1))
-	: _M_alpha(__alpha), _M_mu(__mu)
+	param_type(result_type __alpha_val = result_type(1),
+		   result_type __mu_val = result_type(1))
+	: _M_alpha(__alpha_val), _M_mu(__mu_val)
 	{
 	  _GLIBCXX_DEBUG_ASSERT(_M_alpha > result_type(0));
 	  _GLIBCXX_DEBUG_ASSERT(_M_mu > result_type(0));
@@ -1430,9 +1430,9 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * @brief Constructors.
        */
       explicit
-      pareto_distribution(result_type __alpha = result_type(1),
-			  result_type __mu = result_type(1))
-      : _M_param(__alpha, __mu),
+      pareto_distribution(result_type __alpha_val = result_type(1),
+			  result_type __mu_val = result_type(1))
+      : _M_param(__alpha_val, __mu_val),
 	_M_ud()
       { }
 
Index: include/ext/random.tcc
===================================================================
--- include/ext/random.tcc	(revision 191649)
+++ include/ext/random.tcc	(working copy)
@@ -773,12 +773,12 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const typename __ios_base::fmtflags __flags = __is.flags();
       __is.flags(__ios_base::dec | __ios_base::skipws);
 
-      _RealType __nu, __sigma;
-      __is >> __nu >> __sigma;
+      _RealType __nu_val, __sigma_val;
+      __is >> __nu_val >> __sigma_val;
       __is >> __x._M_ndx;
       __is >> __x._M_ndy;
       __x.param(typename rice_distribution<_RealType>::
-		param_type(__nu, __sigma));
+		param_type(__nu_val, __sigma_val));
 
       __is.flags(__flags);
       return __is;
@@ -838,11 +838,11 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const typename __ios_base::fmtflags __flags = __is.flags();
       __is.flags(__ios_base::dec | __ios_base::skipws);
 
-      _RealType __mu, __omega;
-      __is >> __mu >> __omega;
+      _RealType __mu_val, __omega_val;
+      __is >> __mu_val >> __omega_val;
       __is >> __x._M_gd;
       __x.param(typename nakagami_distribution<_RealType>::
-		param_type(__mu, __omega));
+		param_type(__mu_val, __omega_val));
 
       __is.flags(__flags);
       return __is;
@@ -860,10 +860,10 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
-	result_type __mu = __p.mu();
+	result_type __mu_val = __p.mu();
 	result_type __malphinv = -result_type(1) / __p.alpha();
 	while (__f != __t)
-	  *__f++ = __mu * std::pow(this->_M_ud(__urng), __malphinv);
+	  *__f++ = __mu_val * std::pow(this->_M_ud(__urng), __malphinv);
       }
 
   template<typename _RealType, typename _CharT, typename _Traits>
@@ -902,11 +902,11 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const typename __ios_base::fmtflags __flags = __is.flags();
       __is.flags(__ios_base::dec | __ios_base::skipws);
 
-      _RealType __alpha, __mu;
-      __is >> __alpha >> __mu;
+      _RealType __alpha_val, __mu_val;
+      __is >> __alpha_val >> __mu_val;
       __is >> __x._M_ud;
       __x.param(typename pareto_distribution<_RealType>::
-		param_type(__alpha, __mu));
+		param_type(__alpha_val, __mu_val));
 
       __is.flags(__flags);
       return __is;