Re: regex traits test not testing wchar_t

2013-09-10 Thread Ed Smith-Rowland

On 09/09/2013 06:45 PM, Paolo Carlini wrote:

Hi,

On 09/09/2013 11:54 PM, 3dw...@verizon.net wrote:

All,

I noticed this while prepping an experiment in binary number output.  
I think a test of std::regex_traits was simply copied to the 
wchar_t directory without changing the guts of the test.


Testing (on x86_64-linux) is ongoing but here is the patch and log.  
I wanted to give fold a chance to look it over.

Ok if testing passes.

Thanks,
Paolo.


Passed testing on x86_64-linux.
Committed.

Index: testsuite/28_regex/traits/wchar_t/value.cc
===
--- testsuite/28_regex/traits/wchar_t/value.cc  (revision 202407)
+++ testsuite/28_regex/traits/wchar_t/value.cc  (working copy)
@@ -25,20 +25,20 @@
 #include 
 #include 
 
-// Tests the value() function of the regex_traits class.
+// Tests the value() function of the regex_traits class.
 void test01()
 {
   bool test __attribute__((unused)) = true;
-  std::regex_traits t;
-  VERIFY( t.value('7', 8)  == 7 );
-  VERIFY( t.value('7', 10) == 7 );
-  VERIFY( t.value('7', 16) == 7 );
-  VERIFY( t.value('9', 8)  == -1 );
-  VERIFY( t.value('9', 10) == 9 );
-  VERIFY( t.value('9', 16) == 9 );
-  VERIFY( t.value('d', 8)  == -1 );
-  VERIFY( t.value('d', 10) == -1 );
-  VERIFY( t.value('d', 16) == 13 );
+  std::regex_traits t;
+  VERIFY( t.value(L'7', 8)  == 7 );
+  VERIFY( t.value(L'7', 10) == 7 );
+  VERIFY( t.value(L'7', 16) == 7 );
+  VERIFY( t.value(L'9', 8)  == -1 );
+  VERIFY( t.value(L'9', 10) == 9 );
+  VERIFY( t.value(L'9', 16) == 9 );
+  VERIFY( t.value(L'd', 8)  == -1 );
+  VERIFY( t.value(L'd', 10) == -1 );
+  VERIFY( t.value(L'd', 16) == 13 );
 }
 
 int
2013-09-10  Ed Smith-Rowland  <3dw...@verizon.net>

* testsuite/28_regex/traits/wchar_t/value.cc: Change template args
from char to wchar_t, literals from 'x' to L'x'.


Re: [Patch] match_results::format and regex_replace

2013-09-24 Thread Ed Smith-Rowland

On 09/23/2013 10:09 PM, Tim Shen wrote:

On Sun, Sep 22, 2013 at 4:20 PM, Paolo Carlini  wrote:

If testing goes well patch is Ok to commit.

Tested under -m32 and -m64 and committed :)

I'll learn how locale in glibc works.

Thank you all!



Thank *you*!

 has been dogging us for years.

I, for one, hope you hang around after GSOC.  There are lots of library 
components coming up for C++2014 and other TS. ;-)


Ed



User-define literals for std::complex.

2013-09-26 Thread Ed Smith-Rowland

Greetings,

The complex user-defined literals finally passed (n3779) with the 
resolution to DR1473 allowing the suffix id to touch the quotes (Can't 
find it but I put it in not too long ago).

(http://wiki.edg.com/twiki/pub/Wg21chicago2013/LibraryWorkingGroup/N3779-complex_literals.pdf)

Actually, I think allowing space between quotes and suffix ID was a mistake.

Also it looks like they are *removing* inline from the 'namespace 
literals' so that 'using std;' brings in the literals but that will be a 
later patch for all literals at once.


This has been bootstrapped and regtested on x86_64-linux.

As a general stylistic guide for the library I think I'll put
  operator""abc(...)
with no spaces.  Later.

OK?


2013-09-27  Ed Smith-Rowland  <3dw...@verizon.net>

Implement N3779 - User-defined Literals for std::complex,
part 2 of UDL for Standard Library Types
* include/std/complex: Add complex literal operators.
* testsuite/26_numerics/complex/literals/types.cc: New.
* testsuite/26_numerics/complex/literals/values.cc: New.

Index: include/std/complex
===
--- include/std/complex (revision 202928)
+++ include/std/complex (working copy)
@@ -1924,6 +1924,40 @@
 conj(_Tp __x)
 { return __x; }
 
+#if __cplusplus > 201103L
+
+inline namespace literals {
+inline namespace complex_literals {
+
+  inline constexpr std::complex
+  operator""if(long double __num)
+  { return std::complex{0.0F, static_cast(__num)}; }
+
+  inline constexpr std::complex
+  operator""if(unsigned long long __num)
+  { return std::complex{0.0F, static_cast(__num)}; }
+
+  inline constexpr std::complex
+  operator""i(long double __num)
+  { return std::complex{0.0, static_cast(__num)}; }
+
+  inline constexpr std::complex
+  operator""i(unsigned long long __num)
+  { return std::complex{0.0, static_cast(__num)}; }
+
+  inline constexpr std::complex
+  operator""il(long double __num)
+  { return std::complex{0.0L, __num}; }
+
+  inline constexpr std::complex
+  operator""il(unsigned long long __num)
+  { return std::complex{0.0L, static_cast(__num)}; }
+
+} // inline namespace complex_literals
+} // inline namespace literals
+
+#endif // C++14
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
Index: testsuite/26_numerics/complex/literals/types.cc
===
--- testsuite/26_numerics/complex/literals/types.cc (revision 0)
+++ testsuite/26_numerics/complex/literals/types.cc (working copy)
@@ -0,0 +1,46 @@
+// { dg-options "-std=c++1y" }
+// { dg-do compile }
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include 
+#include 
+
+void
+test02()
+{
+  using namespace std::literals::complex_literals;
+
+  static_assert(std::is_same>::value,
+   "1.0if is std::complex");
+
+  static_assert(std::is_same>::value,
+   "1if is std::complex");
+
+  static_assert(std::is_same>::value,
+   "1.0i is std::complex");
+
+  static_assert(std::is_same>::value,
+   "1i is std::complex");
+
+  static_assert(std::is_same>::value,
+   "1.0il is std::complex");
+
+  static_assert(std::is_same>::value,
+   "1il is std::complex");
+}
Index: testsuite/26_numerics/complex/literals/values.cc
===
--- testsuite/26_numerics/complex/literals/values.cc(revision 0)
+++ testsuite/26_numerics/complex/literals/values.cc(working copy)
@@ -0,0 +1,48 @@
+// { dg-options "-std=gnu++1y" }
+// { dg-do run }
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT A

Re: Add the Hoyt and the arcsine distributions as extensions.

2012-10-12 Thread Ed Smith-Rowland

On 10/12/2012 10:50 AM, Paolo Carlini wrote:

On 10/12/2012 04:19 PM, Ed Smith-Rowland wrote:

These are my last two random distribution extensions for now.

Thanks a lot!
The main on is the Hoyt distribution (AKA the Nakagami-q 
distribution).  It uses the arcsine with specified basis.  The 
arcsine distribution is a specialization of the beta distribution 
except I need this to go from arbitrary (a,b) rather than (0, 1).


Tested on x86_64-linux.

OK?
Looks Ok, yes. Before committing please double check that you are not 
using any C99-only cmath functions (I spotted std::sin and std::sqrt 
which are Ok). This kind of comment:


+// 26.4.8.3.* Class template arcsine_distribution 
[rand.dist.ext.arcsine]


I would do without. Otherwise, I can already see PRs complaining that 
in C++11 there is no rand.dist.ext.arcsine ;) In a couple of years, 
maybe.


Paolo.


Here is the patch committed.

Ed
2012-10-12  Edward Smith-Rowland  <3dw...@verizon.net>

* include/ext/random: Add __gnu_cxx::arcsine_distribution<>
and __gnu_cxx::hoyt_distribution<> classes.
* include/ext/random.tcc: Add out-of-line functions for
__gnu_cxx::arcsine_distribution<> and __gnu_cxx::hoyt_distribution<>.
* testsuite/ext/random/hoyt_distribution/cons/parms.cc: New file.
* testsuite/ext/random/hoyt_distribution/cons/default.cc: New file.
* testsuite/ext/random/hoyt_distribution/requirements/
explicit_instantiation/1.cc: New file.
* testsuite/ext/random/hoyt_distribution/requirements/typedefs.cc:
New file.
* testsuite/ext/random/hoyt_distribution/operators/inequal.cc: New file.
* testsuite/ext/random/hoyt_distribution/operators/equal.cc: New file.
* testsuite/ext/random/hoyt_distribution/operators/serialize.cc:
New file.
* testsuite/ext/random/arcsine_distribution/cons/parms.cc: New file.
* testsuite/ext/random/arcsine_distribution/cons/default.cc: New file.
* testsuite/ext/random/arcsine_distribution/requirements/
explicit_instantiation/1.cc: New file.
* testsuite/ext/random/arcsine_distribution/requirements/typedefs.cc:
New file.
* testsuite/ext/random/arcsine_distribution/operators/inequal.cc:
New file.
* testsuite/ext/random/arcsine_distribution/operators/equal.cc:
New file.
* testsuite/ext/random/arcsine_distribution/operators/serialize.cc:
New file.
Index: include/ext/random
===
--- include/ext/random  (revision 192389)
+++ include/ext/random  (working copy)
@@ -1856,6 +1856,473 @@
   const k_distribution<_RealType>& __d2)
 { return !(__d1 == __d2); }
 
+
+  /**
+   * @brief An arcsine continuous distribution for random numbers.
+   *
+   * The formula for the arcsine probability density function is
+   * @f[
+   * p(x|a,b) = \frac{1}{\pi \sqrt{(x - a)(b - x)}}
+   * @f]
+   * where @f$x >= a@f$ and @f$x <= b@f$.
+   *
+   * 
+   * Distribution Statistics
+   * Mean@f$ (a + b) / 2 @f$
+   * Variance@f$ (b - a)^2 / 8 @f$
+   * Range@f$[a, b]@f$
+   * 
+   */
+  template
+class
+arcsine_distribution
+{
+  static_assert(std::is_floating_point<_RealType>::value,
+   "template argument not a floating point type");
+
+public:
+  /** The type of the range of the distribution. */
+  typedef _RealType result_type;
+  /** Parameter type. */
+  struct param_type
+  {
+   typedef arcsine_distribution distribution_type;
+
+   param_type(result_type __a = result_type(0),
+  result_type __b = result_type(1))
+   : _M_a(__a), _M_b(__b)
+   {
+ _GLIBCXX_DEBUG_ASSERT(_M_a <= _M_b);
+   }
+
+   result_type
+   a() const
+   { return _M_a; }
+
+   result_type
+   b() const
+   { return _M_b; }
+
+   friend bool
+   operator==(const param_type& __p1, const param_type& __p2)
+   { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
+
+  private:
+   void _M_initialize();
+
+   result_type _M_a;
+   result_type _M_b;
+  };
+
+  /**
+   * @brief Constructors.
+   */
+  explicit
+  arcsine_distribution(result_type __a = result_type(0),
+  result_type __b = result_type(1))
+  : _M_param(__a, __b),
+   _M_ud(-1.5707963267948966192313216916397514L,
+ +1.5707963267948966192313216916397514L)
+  { }
+
+  explicit
+  arcsine_distribution(const param_type& __p)
+  : _M_param(__p),
+   _M_ud(-1.5707963267948966192313216916397514L,
+ +1.5707963267948966192313216916397514L)
+  { }
+
+  /**
+   * @brief Resets the distribution state.
+   */
+  void
+  reset()
+  { _M_ud.reset(); }
+
+  /**
+   * @brief Retu

Add C++11 const char* overloads for exception classes.

2012-10-26 Thread Ed Smith-Rowland

Committed.

2012-10-26  Edward Smith-Rowland  <3dw...@verizon.net>

* include/std/system_error (system_error(error_code, const char*),
system_error(int, const error_category&, const char*)): New.
* include/std/stdexcept ( logic_error(const char*),
domain_error(const char*), invalid_argument(const char*),
length_error(const char*), out_of_range(const char*),
runtime_error(const char*), range_error(const char*),
overflow_error(const char*), underflow_error(const char*)): New.
* config/abi/pre/gnu.ver: Add symbols for logic_error const char* ctors.

Index: include/std/system_error
===
--- include/std/system_error(revision 192755)
+++ include/std/system_error(working copy)
@@ -1,6 +1,7 @@
 //  -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007-2012
+// Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -318,17 +319,13 @@
 system_error(error_code __ec, const string& __what)
 : runtime_error(__what + ": " + __ec.message()), _M_code(__ec) { }
 
-/*
- * TODO: Add const char* ctors to all exceptions.
- *
- * system_error(error_code __ec, const char* __what)
- * : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { }
- *
- * system_error(int __v, const error_category& __ecat, const char* __what)
- * : runtime_error(__what + (": " + __ec.message())),
- *   _M_code(error_code(__v, __ecat)) { }
- */
+system_error(error_code __ec, const char* __what)
+: runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { }
 
+system_error(int __v, const error_category& __ecat, const char* __what)
+: runtime_error(__what + (": " + error_code(__v, __ecat).message())),
+  _M_code(__v, __ecat) { }
+
 system_error(int __v, const error_category& __ecat)
 : runtime_error(error_code(__v, __ecat).message()),
   _M_code(__v, __ecat) { }
Index: include/std/stdexcept
===
--- include/std/stdexcept   (revision 192755)
+++ include/std/stdexcept   (working copy)
@@ -1,6 +1,6 @@
 // Standard exception classes  -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2005, 2007, 2009, 2010, 2011
+// Copyright (C) 2001, 2002, 2005, 2007, 2009-2012
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -59,8 +59,11 @@
 
   public:
 /** Takes a character string describing the error.  */
-explicit 
-logic_error(const string& __arg);
+explicit logic_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+explicit logic_error(const char* __arg)
+: logic_error(string(__arg)) { }
+#endif
 
 virtual ~logic_error() _GLIBCXX_USE_NOEXCEPT;
 
@@ -76,6 +79,10 @@
   {
   public:
 explicit domain_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+explicit domain_error(const char* __arg)
+: domain_error(string(__arg)) { }
+#endif
 virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -84,6 +91,10 @@
   {
   public:
 explicit invalid_argument(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+explicit invalid_argument(const char* __arg)
+: invalid_argument(string(__arg)) { }
+#endif
 virtual ~invalid_argument() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -93,6 +104,10 @@
   {
   public:
 explicit length_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+explicit length_error(const char* __arg)
+: length_error(string(__arg)) { }
+#endif
 virtual ~length_error() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -102,6 +117,10 @@
   {
   public:
 explicit out_of_range(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+explicit out_of_range(const char* __arg)
+: out_of_range(string(__arg)) { }
+#endif
 virtual ~out_of_range() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -116,8 +135,11 @@
 
   public:
 /** Takes a character string describing the error.  */
-explicit 
-runtime_error(const string& __arg);
+explicit runtime_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+explicit runtime_error(const char* __arg)
+: runtime_error(string(__arg)) { }
+#endif
 
 virtual ~runtime_error() _GLIBCXX_USE_NOEXCEPT;
 
@@ -132,6 +154,10 @@
   {
   public:
 explicit range_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+explicit range_error(const char* __arg)
+: range_error(string(__arg)) { }
+#endif
 virtual ~range_error() _GLIBCXX_USE_NOEXCEPT;
   };
 
@@ -140,6 +166,10 @@
   {
   public:
 explicit overflow_error(const string& __arg);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+explicit overflow_error(const char* __arg)
+: overflow_error(string(__arg)) { }
+#endif
 

Re: Add C++11 const char* overloads for exception classes.

2012-10-26 Thread Ed Smith-Rowland

On 10/26/2012 10:26 AM, Paolo Carlini wrote:

On 10/26/2012 04:11 PM, Ed Smith-Rowland wrote:

Committed.
I can't find the message actually approving the patch. And personally 
I'm a bit nervous about it.


Paolo.


Sorry, i though it was OK. Do you want me to roll back?  do you want to?

Ed



Re: Add C++11 const char* overloads for exception classes.

2012-10-26 Thread Ed Smith-Rowland

On 10/26/2012 10:26 AM, Paolo Carlini wrote:

On 10/26/2012 04:11 PM, Ed Smith-Rowland wrote:

Committed.
I can't find the message actually approving the patch. And personally 
I'm a bit nervous about it.


Paolo.


Well, the commit had failed anyway... ChangeLog out of date.

So I'll wait.

Ed



PR libstdc++/58729 - tr2::dynamic_bitset::resize fails

2013-10-17 Thread Ed Smith-Rowland

This patch bootstraps and tests clean on x86-64-linux.

Truthfully, dynamic_bitset needs some more love wrt C++11 and a testsuite.
It got put in before it was baked really.
That will be later.


2013-10-16  Edward Smith-Rowland  <3dw...@verizon.net>

PR libstdc++/58729
* include/tr2/dynamic_bitset (_M_resize, resize): Use input value
to set bits; (_M_do_left_shift, _M_do_right_shift, _M_do_to_ulong,
_M_do_to_ullong, _M_do_find_first, _M_do_find_next, _M_copy_from_ptr,
operator>>): Move long methods outline to...
* include/tr2/dynamic_bitset.tcc: New.
* include/Makefile.am: Add dynamic_bitset.tcc.
* include/Makefile.in: Add dynamic_bitset.tcc.
* testsuite/tr2/dynamic_bitset/pr58729.cc: New.
Index: include/tr2/dynamic_bitset
===
--- include/tr2/dynamic_bitset  (revision 203739)
+++ include/tr2/dynamic_bitset  (working copy)
@@ -137,7 +137,12 @@
if (__nbits % _S_bits_per_block > 0)
  ++__sz;
if (__sz != this->_M_w.size())
- this->_M_w.resize(__sz);
+ {
+   block_type __val = 0;
+   if (__value)
+ __val = std::numeric_limits::max();
+   this->_M_w.resize(__sz, __val);
+ }
   }
 
   allocator_type
@@ -246,7 +251,7 @@
   bool
   _M_is_equal(const __dynamic_bitset_base& __x) const
   {
-   if (__x.size() == this->size())
+   if (__x._M_w.size() == this->_M_w.size())
  {
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
  if (this->_M_w[__i] != __x._M_w[__i])
@@ -260,7 +265,7 @@
   bool
   _M_is_less(const __dynamic_bitset_base& __x) const
   {
-   if (__x.size() == this->size())
+   if (__x._M_w.size() == this->_M_w.size())
  {
for (size_t __i = this->_M_w.size(); __i > 0; --__i)
  {
@@ -297,9 +302,9 @@
   bool
   _M_is_subset_of(const __dynamic_bitset_base& __b)
   {
-   if (__b.size() == this->size())
+   if (__b._M_w.size() == this->_M_w.size())
  {
-   for (size_t __i = 0; __i < _M_w.size(); ++__i)
+   for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
  if (this->_M_w[__i] != (this->_M_w[__i] | __b._M_w[__i]))
return false;
return true;
@@ -364,140 +369,6 @@
   }
 };
 
-  // Definitions of non-inline functions from __dynamic_bitset_base.
-  template
-void
-__dynamic_bitset_base<_WordT, _Alloc>::_M_do_left_shift(size_t __shift)
-{
-  if (__builtin_expect(__shift != 0, 1))
-   {
- const size_t __wshift = __shift / _S_bits_per_block;
- const size_t __offset = __shift % _S_bits_per_block;
-
- if (__offset == 0)
-   for (size_t __n = this->_M_w.size() - 1; __n >= __wshift; --__n)
- this->_M_w[__n] = this->_M_w[__n - __wshift];
- else
-   {
- const size_t __sub_offset = _S_bits_per_block - __offset;
- for (size_t __n = _M_w.size() - 1; __n > __wshift; --__n)
-   this->_M_w[__n] = ((this->_M_w[__n - __wshift] << __offset)
-| (this->_M_w[__n - __wshift - 1] >> 
__sub_offset));
- this->_M_w[__wshift] = this->_M_w[0] << __offset;
-   }
-
-  std::fill(this->_M_w.begin(), this->_M_w.begin() + __wshift,
-   static_cast<_WordT>(0));
-   }
-}
-
-  template
-void
-__dynamic_bitset_base<_WordT, _Alloc>::_M_do_right_shift(size_t __shift)
-{
-  if (__builtin_expect(__shift != 0, 1))
-   {
- const size_t __wshift = __shift / _S_bits_per_block;
- const size_t __offset = __shift % _S_bits_per_block;
- const size_t __limit = this->_M_w.size() - __wshift - 1;
-
- if (__offset == 0)
-   for (size_t __n = 0; __n <= __limit; ++__n)
- this->_M_w[__n] = this->_M_w[__n + __wshift];
- else
-   {
- const size_t __sub_offset = (_S_bits_per_block
-  - __offset);
- for (size_t __n = 0; __n < __limit; ++__n)
-   this->_M_w[__n] = ((this->_M_w[__n + __wshift] >> __offset)
-| (this->_M_w[__n + __wshift + 1] << 
__sub_offset));
- this->_M_w[__limit] = this->_M_w[_M_w.size()-1] >> __offset;
-   }
-
- std::fill(this->_M_w.begin() + __limit + 1, this->_M_w.end(),
-   static_cast<_WordT>(0));
-   }
-}
-
-  template
-unsigned long
-__dynamic_bitset_base<_WordT, _Alloc>::_M_do_to_ulong() const
-{
-  size_t __n = sizeof(unsigned long) / sizeof(block_type);
-  for (size_t __i = __n; __i < this->_M_w.size(); ++__i)
-   if (this->_M_w[__i])
- __throw_overflow_error(__N("__dynamic_bitset_base::_M_do_to_ulong"));
-  unsigned long __res = 0UL;
-  for 

PR C++/58708 - string literal operator templates broken

2013-10-17 Thread Ed Smith-Rowland
Here is a patch to correct the char type and the type, number of nontype 
parameter pack for user defined strng literal operator templates.


Bootstrapped and tested on x86_64-linux.

OK?


gcc/cp:

2013-10-17  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58708
* parser.c (make_string_pack): Discover non-const type and size
of character and build parm pack with correct type and chars.

gcc/testsuite:

2013-10-17  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58708
*g++.dg/cpp1y/pr58708.C : New.

Index: cp/parser.c
===
--- cp/parser.c (revision 203739)
+++ cp/parser.c (working copy)
@@ -3792,22 +3792,39 @@
   tree charvec;
   tree argpack = make_node (NONTYPE_ARGUMENT_PACK);
   const char *str = TREE_STRING_POINTER (value);
-  int i, len = TREE_STRING_LENGTH (value) - 1;
+  int sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (value;
+  int len = TREE_STRING_LENGTH (value) / sz - 1;
   tree argvec = make_tree_vec (2);
 
-  tree string_char_type_node = TREE_TYPE (TREE_TYPE (value));
+  tree str_char_type_node = TREE_TYPE (TREE_TYPE (value));
+  str_char_type_node = TYPE_MAIN_VARIANT (str_char_type_node);
 
   /* First template parm is character type.  */
-  TREE_VEC_ELT (argvec, 0) = string_char_type_node;
+  TREE_VEC_ELT (argvec, 0) = str_char_type_node;
 
   /* Fill in CHARVEC with all of the parameters.  */
   charvec = make_tree_vec (len);
-  for (i = 0; i < len; ++i)
-TREE_VEC_ELT (charvec, i) = build_int_cst (string_char_type_node, str[i]);
+  if (sz == 1)
+{
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, str[i]);
+}
+  else if (sz == 2)
+{
+  const uint16_t *num = (const uint16_t *)str;
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
+}
+  else if (sz == 4)
+{
+  const uint32_t *num = (const uint32_t *)str;
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
+}
 
   /* Build the argument packs.  */
   SET_ARGUMENT_PACK_ARGS (argpack, charvec);
-  TREE_TYPE (argpack) = string_char_type_node;
+  TREE_TYPE (argpack) = str_char_type_node;
 
   TREE_VEC_ELT (argvec, 1) = argpack;
 
@@ -21425,6 +21442,9 @@
   /* C++11 noreturn attribute is equivalent to GNU's.  */
   if (is_attribute_p ("noreturn", attr_id))
TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
+  /* C++14 deprecated attribute is equivalent to GNU's.  */
+  else if (cxx_dialect >= cxx1y && is_attribute_p ("deprecated", attr_id))
+   TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
 }
 
   /* Now parse the optional argument clause of the attribute.  */
Index: testsuite/g++.dg/cpp1y/pr58708.C
===
--- testsuite/g++.dg/cpp1y/pr58708.C(revision 0)
+++ testsuite/g++.dg/cpp1y/pr58708.C(working copy)
@@ -0,0 +1,70 @@
+// { dg-options -std=c++1y }
+
+#include 
+#include 
+#include 
+#include 
+
+struct Foo
+{
+  std::array type;
+  std::array const_type;
+  std::vector chars;
+};
+
+template
+Foo
+operator""_foo()
+{
+  CharT arr[]{str...};
+
+  Foo foo;
+
+  foo.type[0] = std::is_same::value;
+  foo.type[1] = std::is_same::value;
+  foo.type[2] = std::is_same::value;
+  foo.type[3] = std::is_same::value;
+  foo.const_type[0] = std::is_same::value;
+  foo.const_type[1] = std::is_same::value;
+  foo.const_type[2] = std::is_same::value;
+  foo.const_type[3] = std::is_same::value;
+
+  for(CharT c : arr)
+foo.chars.push_back((int)c);
+
+  return foo;
+}
+
+int
+main()
+{
+  Foo foo;
+
+  foo = U"\x1\x10001\x10002"_foo;
+  VERIFY (foo.type[3] == true);
+  VERIFY (foo.chars.size() == 3);
+  VERIFY (foo.chars[0] == 65536);
+  VERIFY (foo.chars[1] == 65537);
+  VERIFY (foo.chars[2] == 65538);
+
+  foo = "\x61\x62\x63"_foo;
+  VERIFY (foo.type[0] == true);
+  VERIFY (foo.chars.size() == 3);
+  VERIFY (foo.chars[0] == 97);
+  VERIFY (foo.chars[1] == 98);
+  VERIFY (foo.chars[2] == 99);
+
+  foo = L"\x01020304\x05060708"_foo;
+  VERIFY (foo.type[1] == true);
+  VERIFY (foo.chars.size() == 2);
+  VERIFY (foo.chars[0] == 16909060);
+  VERIFY (foo.chars[1] == 84281096);
+
+  foo = u"\x0102\x0304\x0506\x0708"_foo;
+  VERIFY (foo.type[2] == true);
+  VERIFY (foo.chars.size() == 4);
+  VERIFY (foo.chars[0] == 258);
+  VERIFY (foo.chars[1] == 772);
+  VERIFY (foo.chars[2] == 1286);
+  VERIFY (foo.chars[3] == 1800);
+}


Re: User-define literals for std::complex.

2013-10-20 Thread Ed Smith-Rowland

On 09/27/2013 05:39 AM, Jonathan Wakely wrote:

On 27 September 2013 05:17, Ed Smith-Rowland wrote:

The complex user-defined literals finally passed (n3779) with the resolution
to DR1473 allowing the suffix id to touch the quotes (Can't find it but I
put it in not too long ago).

I think it's been approved by the LWG and looks like it will go to a
vote by the full committee, but let's wait for that to pass before
making any changes.



Now that this is in the working paper can we go ahead?




[PR libstdc++/58804][PR libstdc++/58729] tr2/dynamic_bitset issues.

2013-10-20 Thread Ed Smith-Rowland

Greetings.

Here is a patch to correct tr2/dynamic_bitset to use __builtin_xxxll for 
long long instead of the long versions.


Relevant bugs:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58804
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58729

Builds and *really* tests clean on x86_64-linux.

OK?

Index: include/tr2/dynamic_bitset
===
--- include/tr2/dynamic_bitset  (revision 203841)
+++ include/tr2/dynamic_bitset  (working copy)
@@ -287,7 +287,7 @@
  if (_M_w[__i] != ~static_cast(0))
return 0;
return ((this->_M_w.size() - 1) * _S_bits_per_block
-   + __builtin_popcountl(this->_M_hiword()));
+   + __builtin_popcountll(this->_M_hiword()));
   }
 
   bool
@@ -332,7 +332,7 @@
   {
size_t __result = 0;
for (size_t __i = 0; __i < this->_M_w.size(); ++__i)
- __result += __builtin_popcountl(this->_M_w[__i]);
+ __result += __builtin_popcountll(this->_M_w[__i]);
return __result;
   }
 
Index: include/tr2/dynamic_bitset.tcc
===
--- include/tr2/dynamic_bitset.tcc  (revision 203841)
+++ include/tr2/dynamic_bitset.tcc  (working copy)
@@ -131,7 +131,7 @@
  _WordT __thisword = this->_M_w[__i];
  if (__thisword != static_cast<_WordT>(0))
return (__i * _S_bits_per_block
-   + __builtin_ctzl(__thisword));
+   + __builtin_ctzll(__thisword));
}
   // not found, so return an indication of failure.
   return __not_found;
@@ -158,7 +158,7 @@
 
   if (__thisword != static_cast<_WordT>(0))
return (__i * _S_bits_per_block
-   + __builtin_ctzl(__thisword));
+   + __builtin_ctzll(__thisword));
 
   // check subsequent words
   for (++__i; __i < this->_M_w.size(); ++__i)
@@ -166,7 +166,7 @@
  __thisword = this->_M_w[__i];
  if (__thisword != static_cast<_WordT>(0))
return (__i * _S_bits_per_block
-   + __builtin_ctzl(__thisword));
+   + __builtin_ctzll(__thisword));
}
   // not found, so return an indication of failure.
   return __not_found;
2013-10-20  Edward Smith-Rowland  <3dw...@verizon.net>

PR libstdc++/58804
PR libstdc++/58729
* include/tr2/dynamic_bitset
(__dynamic_bitset_base<_WordT, _Alloc>::_M_are_all_aux,
__dynamic_bitset_base<_WordT, _Alloc>::_M_do_count):
Use __builtin_popcountll() instead of __builtin_popcountl().
* include/tr2/dynamic_bitset.tcc
(__dynamic_bitset_base<_WordT, _Alloc>::_M_do_find_first,
__dynamic_bitset_base<_WordT, _Alloc>::_M_do_find_next):
Use __builtin_ctzll() instead of __builtin_ctzl().


[C++14] implement [[deprecated]].

2013-10-22 Thread Ed Smith-Rowland

I think this is pretty easy - gnu::deprecated has the same semantics.

Bootstrapped and tested on x86_64-linux.

OK?


gcc/cp:

2013-10-22  Edward Smith-Rowland  <3dw...@verizon.net>

* parser.c (cp_parser_std_attribute): Interpret [[deprecated]]
as [[gnu::deprecated]].

gcc/testsuite:

2013-10-22  Edward Smith-Rowland  <3dw...@verizon.net>

* g++.dg/cpp1y/attr-deprecated.C: New.
* g++.dg/cpp1y/attr-deprecated-neg.C: New.

Index: cp/parser.c
===
--- cp/parser.c (revision 203915)
+++ cp/parser.c (working copy)
@@ -21426,6 +21443,9 @@
   /* C++11 noreturn attribute is equivalent to GNU's.  */
   if (is_attribute_p ("noreturn", attr_id))
TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
+  /* C++14 deprecated attribute is equivalent to GNU's.  */
+  else if (cxx_dialect >= cxx1y && is_attribute_p ("deprecated", attr_id))
+   TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
 }
 
   /* Now parse the optional argument clause of the attribute.  */
Index: testsuite/g++.dg/cpp1y/attr-deprecated.C
===
--- testsuite/g++.dg/cpp1y/attr-deprecated.C(revision 0)
+++ testsuite/g++.dg/cpp1y/attr-deprecated.C(working copy)
@@ -0,0 +1,59 @@
+// { dg-do compile }
+// { dg-options -std=c++1y }
+
+class [[deprecated]] A
+{
+};
+
+[[deprecated]]
+int
+foo(int n)
+{
+  return 42 + n;
+}
+
+class [[deprecated("B has been superceded by C")]] B
+{
+};
+
+[[deprecated("bar is unsafe; use foobar instead")]]
+int
+bar(int n)
+{
+  return 42 + n - 1;
+}
+
+#if __cplusplus > 201103L
+
+//  Deprecate C for C++14 onwards.
+class [[deprecated]] C;
+
+//  Deprecate foobar for C++14 onwards.
+[[deprecated]]
+int
+foobar(int n);
+
+#endif
+
+class C
+{
+};
+
+int
+foobar(int n)
+{
+  return 43 + n - 1;
+}
+
+int
+main()
+{
+  A aaa; // { dg-warning "is deprecated" }
+  int n = foo(12); // { dg-warning "is deprecated" }
+
+  B bbb; // { dg-warning "is deprecated" "B has been superceded by C" }
+  int m = bar(666); // { dg-warning "is deprecated" "bar is unsafe; use foobar 
instead" }
+
+  C ccc; // { dg-warning "is deprecated" }
+  int l = foobar(8); // { dg-warning "is deprecated" }
+}
Index: testsuite/g++.dg/cpp1y/attr-deprecated-neg.C
===
--- testsuite/g++.dg/cpp1y/attr-deprecated-neg.C(revision 0)
+++ testsuite/g++.dg/cpp1y/attr-deprecated-neg.C(working copy)
@@ -0,0 +1,59 @@
+// { dg-do compile }
+// { dg-options -std=c++11 }
+
+class [[deprecated]] A // { dg-warning "attribute directive ignored" }
+{
+};
+
+[[deprecated]]
+int
+foo(int n) // { dg-warning "attribute directive ignored" }
+{
+  return 42 + n;
+}
+
+class [[deprecated("B has been superceded by C")]] B // { dg-warning 
"attribute directive ignored" }
+{
+};
+
+[[deprecated("bar is unsafe; use foobar instead")]]
+int
+bar(int n) // { dg-warning "attribute directive ignored" }
+{
+  return 42 + n - 1;
+}
+
+#if __cplusplus > 201103L
+
+//  Deprecate C for C++14 onwards.
+class [[deprecated]] C;
+
+//  Deprecate foobar for C++14 onwards.
+[[deprecated]]
+int
+foobar(int n);
+
+#endif
+
+class C
+{
+};
+
+int
+foobar(int n)
+{
+  return 43 + n - 1;
+}
+
+int
+main()
+{
+  A aaa;
+  int n = foo(12);
+
+  B bbb;
+  int m = bar(666);
+
+  C ccc;
+  int l = foobar(8);
+}


Re: [C++14] implement [[deprecated]].

2013-10-22 Thread Ed Smith-Rowland

On 10/22/2013 08:37 AM, Paolo Carlini wrote:

On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:

I think this is pretty easy - gnu::deprecated has the same semantics.
Unfortunately however, gnu::deprecated has a number of long standing 
issues (just search Bugzilla), personally I'm not sure we want to say 
everybody that we have got [[deprecated]] implemented, until those are 
solved. Just my personal opinion.


Paolo.


I'll check bugzilla.  We'll hold...



Re: [C++14] implement [[deprecated]].

2013-10-22 Thread Ed Smith-Rowland

On 10/22/2013 12:00 PM, Jason Merrill wrote:

OK.

Jason

There is discussion about several bugs in gnu::deprecated upon which 
this is based over on the libstdc++ list.
I could see where we are with those bugs in a week or two.  Or just wait 
until they are fixed.
OTOH, I don't think my patch would change one way or the other.  I can't 
see a reason we'd want [[gnu::deprecated]] and [[deprecated]] to differ.
It's just that [[deprecated]] wouldn't quite work the way it should 
until the bugs are fixed.


What do you think?

Ed



[c++-concepts] small tidbits to get it to build

2013-10-22 Thread Ed Smith-Rowland

I had to get past two small bugs to get c++-concepts to build.
Take a good look because I'm not sure if they're right.  The solutions 
should be harmless though.


Ed


2013-10-23  Edward Smith-Rowland  <3dw...@verizon.net>

make concepts build.
* constraint.cc (make_constraints): Change variable assume to
assumption.  Is assume a new keyword?
* typeck.c (cp_build_function_call_vec): Use unused variable loc.
Index: constraint.cc
===
--- constraint.cc   (revision 203944)
+++ constraint.cc   (working copy)
@@ -522,16 +522,15 @@
   if (expr == error_mark_node)
 return error_mark_node;
 
-  // Decompose those expressions into lists of lists of atomic
-  // propositions.
-  tree assume = decompose_assumptions (expr);
+  // Decompose those expressions into lists of lists of atomic propositions.
+  tree assumption = decompose_assumptions (expr);
 
   // Build the constraint info.
   tree_constraint_info *cinfo = 
 (tree_constraint_info *)make_node (CONSTRAINT_INFO);
   cinfo->spelling = reqs;
   cinfo->requirements = expr;
-  cinfo->assumptions = assume;
+  cinfo->assumptions = assumption;
   return (tree)cinfo;
 }
 
@@ -1380,7 +1379,7 @@
   // Print the header for the requires expression.
   tree parms = TREE_OPERAND (subst, 0);
   if (!VOID_TYPE_P (TREE_VALUE (parms)))
-inform (loc, "  requiring syntax with values %Z", TREE_OPERAND (subst, 0));
+inform (loc, "  requiring syntax with values %qE", TREE_OPERAND (subst, 
0));/*%Z*/
 
   // Create a new local specialization binding for the arguments. 
   // This lets us instantiate sub-expressions separately from the 
Index: typeck.c
===
--- typeck.c(revision 203944)
+++ typeck.c(working copy)
@@ -3445,7 +3445,7 @@
 {
   location_t loc = DECL_SOURCE_LOCATION (function);
   error ("%qD is not a viable candidate", function);
-  diagnose_constraints (input_location, tmpl, args);
+  diagnose_constraints (loc, tmpl, args);/*input_location*/
   return error_mark_node;
 }
 }


Re: [c++-concepts] small tidbits to get it to build

2013-10-23 Thread Ed Smith-Rowland

On 10/23/2013 08:36 AM, Andrew Sutton wrote:

Hi Ed,

It looks like we did reserve "assume" as a keyword, but it's not being
used... By any chance, did you configure without --disable-bootstrap?

I think it would be a better solution to remove the unused keywords --
there were a couple of others that we grabbed for some other
concepts-related work, but which aren't included in Concepts Lite.

I'll apply the typeck fix.

Andrew Sutton


On Tue, Oct 22, 2013 at 10:02 PM, Ed Smith-Rowland <3dw...@verizon.net> wrote:

I had to get past two small bugs to get c++-concepts to build.
Take a good look because I'm not sure if they're right.  The solutions
should be harmless though.

Ed


I did this:
$ ../gcc_concepts/configure --prefix=/home/ed/bin_concepts 
--enable-languages=c,c++,lto


This is pretty base bones - no special treatment configure and the 
branch worked pretty well.


Ed



Re: PR C++/58708 - string literal operator templates broken

2013-10-25 Thread Ed Smith-Rowland

On 10/25/2013 06:08 AM, Paolo Carlini wrote:

Hi,

On 10/18/2013 04:42 AM, Ed Smith-Rowland wrote:

--- testsuite/g++.dg/cpp1y/pr58708.C (revision 0)
+++ testsuite/g++.dg/cpp1y/pr58708.C(working copy)
@@ -0,0 +1,70 @@
+// { dg-options -std=c++1y }
+
+#include 
+#include 
+#include 
+#include 
are you sure you want these includes in a C++ front-end testcase? Even 
 instead of ? What about something more 
minimal, not including large headers like , for the C++ 
front-end + a library testcase (first blush, the above would be 
perfectly fine)


Thanks,
Paolo.


You're right.  I'll send something slimmer later tonight.
The rest of the tests in the cpp1y directory use __builtin_abort.
So, you also want a library testcase?



Re: PR C++/58708 - string literal operator templates broken

2013-10-25 Thread Ed Smith-Rowland

On 10/25/2013 07:54 AM, Paolo Carlini wrote:

On 10/25/2013 01:38 PM, Ed Smith-Rowland wrote:

So, you also want a library testcase?
Up to you: if you feel it would test something that the c++ front-end 
testcase doesn't, why not.


Paolo.

I think this patch should be sufficient - no containers, it just follows 
the pattern of the other tests in the cpp1y directory.

I builds and tests of x86_64-linux.

OK?

Later we can think of library tools that could help authors of literals 
operators.

The bits/bits/parse_numbers.h is a start on this.

Ed

Index: cp/parser.c
===
--- cp/parser.c (revision 203997)
+++ cp/parser.c (working copy)
@@ -3793,22 +3793,39 @@
   tree charvec;
   tree argpack = make_node (NONTYPE_ARGUMENT_PACK);
   const char *str = TREE_STRING_POINTER (value);
-  int i, len = TREE_STRING_LENGTH (value) - 1;
+  int sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (value;
+  int len = TREE_STRING_LENGTH (value) / sz - 1;
   tree argvec = make_tree_vec (2);
 
-  tree string_char_type_node = TREE_TYPE (TREE_TYPE (value));
+  tree str_char_type_node = TREE_TYPE (TREE_TYPE (value));
+  str_char_type_node = TYPE_MAIN_VARIANT (str_char_type_node);
 
   /* First template parm is character type.  */
-  TREE_VEC_ELT (argvec, 0) = string_char_type_node;
+  TREE_VEC_ELT (argvec, 0) = str_char_type_node;
 
   /* Fill in CHARVEC with all of the parameters.  */
   charvec = make_tree_vec (len);
-  for (i = 0; i < len; ++i)
-TREE_VEC_ELT (charvec, i) = build_int_cst (string_char_type_node, str[i]);
+  if (sz == 1)
+{
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, str[i]);
+}
+  else if (sz == 2)
+{
+  const uint16_t *num = (const uint16_t *)str;
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
+}
+  else if (sz == 4)
+{
+  const uint32_t *num = (const uint32_t *)str;
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
+}
 
   /* Build the argument packs.  */
   SET_ARGUMENT_PACK_ARGS (argpack, charvec);
-  TREE_TYPE (argpack) = string_char_type_node;
+  TREE_TYPE (argpack) = str_char_type_node;
 
   TREE_VEC_ELT (argvec, 1) = argpack;
 
Index: testsuite/g++.dg/cpp1y/pr58708.C
===
--- testsuite/g++.dg/cpp1y/pr58708.C(revision 0)
+++ testsuite/g++.dg/cpp1y/pr58708.C(working copy)
@@ -0,0 +1,68 @@
+// { dg-options -std=c++1y }
+// { dg-do run }
+
+#include 
+
+struct Foo
+{
+  bool type[4];
+  bool const_type[4];
+  int chars[10];
+};
+
+template
+Foo
+operator""_foo()
+{
+  CharT arr[]{str...};
+
+  Foo foo;
+
+  foo.type[0] = std::is_same::value;
+  foo.type[1] = std::is_same::value;
+  foo.type[2] = std::is_same::value;
+  foo.type[3] = std::is_same::value;
+  foo.const_type[0] = std::is_same::value;
+  foo.const_type[1] = std::is_same::value;
+  foo.const_type[2] = std::is_same::value;
+  foo.const_type[3] = std::is_same::value;
+
+  for(int i; i < sizeof(arr)/sizeof(CharT) - 1; ++i)
+foo.chars[i] = (int)arr[i];
+
+  return foo;
+}
+
+int
+main()
+{
+  Foo foo;
+
+  foo = U"\x1\x10001\x10002"_foo;
+  if (foo.type[3] != true) __builtin_abort();
+  if (sizeof(foo.chars)/sizeof(char32_t)-1 != 3) __builtin_abort();
+  if (foo.chars[0] != 65536) __builtin_abort();
+  if (foo.chars[1] != 65537) __builtin_abort();
+  if (foo.chars[2] != 65538) __builtin_abort();
+
+  foo = "\x61\x62\x63"_foo;
+  if (foo.type[0] != true) __builtin_abort();
+  if (sizeof(foo.chars)/sizeof(char)-1 != 3) __builtin_abort();
+  if (foo.chars[0] != 97) __builtin_abort();
+  if (foo.chars[1] != 98) __builtin_abort();
+  if (foo.chars[2] != 99) __builtin_abort();
+
+  foo = L"\x01020304\x05060708"_foo;
+  if (foo.type[1] != true) __builtin_abort();
+  if (sizeof(foo.chars)/sizeof(wchar_t)-1 != 2) __builtin_abort();
+  if (foo.chars[0] != 16909060) __builtin_abort();
+  if (foo.chars[1] != 84281096) __builtin_abort();
+
+  foo = u"\x0102\x0304\x0506\x0708"_foo;
+  if (foo.type[2] != true) __builtin_abort();
+  if (sizeof(foo.chars)/sizeof(char16_t)-1 != 4) __builtin_abort();
+  if (foo.chars[0] != 258) __builtin_abort();
+  if (foo.chars[1] != 772) __builtin_abort();
+  if (foo.chars[2] != 1286) __builtin_abort();
+  if (foo.chars[3] != 1800) __builtin_abort();
+}

gcc/cp:

2013-10-25  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58708
* parser.c (make_string_pack): Discover non-const type and size
of character and build parm pack with correct type and chars.

gcc/testsuite:

2013-10-25  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58708
*g++.dg/cpp1y/pr58708.C : New.



Re: PR C++/58708 - string literal operator templates broken

2013-10-25 Thread Ed Smith-Rowland

On 10/25/2013 10:01 AM, Paolo Carlini wrote:

On 10/25/2013 03:46 PM, Ed Smith-Rowland wrote:

On 10/25/2013 07:54 AM, Paolo Carlini wrote:

On 10/25/2013 01:38 PM, Ed Smith-Rowland wrote:

So, you also want a library testcase?
Up to you: if you feel it would test something that the c++ 
front-end testcase doesn't, why not.


Paolo.

I think this patch should be sufficient - no containers, it just 
follows the pattern of the other tests in the cpp1y directory.
Note, however, that  isn't small at all, and apparently 
you are only using std::is_same which is just a one line template + a 
one line specialization (just grep in testsuite/g++.dg)


Paolo.


Here is one with necessary tools inlined.
Ok?


gcc/cp:

2013-10-25  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58708
* parser.c (make_string_pack): Discover non-const type and size
of character and build parm pack with correct type and chars.

gcc/testsuite:

2013-10-25  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58708
*g++.dg/cpp1y/pr58708.C : New.

Index: cp/parser.c
===
--- cp/parser.c (revision 203997)
+++ cp/parser.c (working copy)
@@ -3793,22 +3793,39 @@
   tree charvec;
   tree argpack = make_node (NONTYPE_ARGUMENT_PACK);
   const char *str = TREE_STRING_POINTER (value);
-  int i, len = TREE_STRING_LENGTH (value) - 1;
+  int sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (value;
+  int len = TREE_STRING_LENGTH (value) / sz - 1;
   tree argvec = make_tree_vec (2);
 
-  tree string_char_type_node = TREE_TYPE (TREE_TYPE (value));
+  tree str_char_type_node = TREE_TYPE (TREE_TYPE (value));
+  str_char_type_node = TYPE_MAIN_VARIANT (str_char_type_node);
 
   /* First template parm is character type.  */
-  TREE_VEC_ELT (argvec, 0) = string_char_type_node;
+  TREE_VEC_ELT (argvec, 0) = str_char_type_node;
 
   /* Fill in CHARVEC with all of the parameters.  */
   charvec = make_tree_vec (len);
-  for (i = 0; i < len; ++i)
-TREE_VEC_ELT (charvec, i) = build_int_cst (string_char_type_node, str[i]);
+  if (sz == 1)
+{
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, str[i]);
+}
+  else if (sz == 2)
+{
+  const uint16_t *num = (const uint16_t *)str;
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
+}
+  else if (sz == 4)
+{
+  const uint32_t *num = (const uint32_t *)str;
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
+}
 
   /* Build the argument packs.  */
   SET_ARGUMENT_PACK_ARGS (argpack, charvec);
-  TREE_TYPE (argpack) = string_char_type_node;
+  TREE_TYPE (argpack) = str_char_type_node;
 
   TREE_VEC_ELT (argvec, 1) = argpack;
 
Index: testsuite/g++.dg/cpp1y/pr58708.C
===
--- testsuite/g++.dg/cpp1y/pr58708.C(revision 0)
+++ testsuite/g++.dg/cpp1y/pr58708.C(working copy)
@@ -0,0 +1,91 @@
+// { dg-options -std=c++1y }
+// { dg-do run }
+
+template
+  struct integral_constant
+  {
+static constexpr _Tp  value = __v;
+typedef _Tp   value_type;
+typedef integral_constant<_Tp, __v>   type;
+constexpr operator value_type() const { return value; }
+constexpr value_type operator()() const { return value; }
+  };
+
+template
+  constexpr _Tp integral_constant<_Tp, __v>::value;
+
+typedef integral_constant true_type;
+
+typedef integral_constantfalse_type;
+
+template
+  struct is_same
+  : public false_type { };
+
+template
+  struct is_same<_Tp, _Tp>
+  : public true_type { };
+
+struct Foo
+{
+  bool type[4];
+  bool const_type[4];
+  int chars[10];
+};
+
+template
+Foo
+operator""_foo()
+{
+  CharT arr[]{str...};
+
+  Foo foo;
+
+  foo.type[0] = is_same::value;
+  foo.type[1] = is_same::value;
+  foo.type[2] = is_same::value;
+  foo.type[3] = is_same::value;
+  foo.const_type[0] = is_same::value;
+  foo.const_type[1] = is_same::value;
+  foo.const_type[2] = is_same::value;
+  foo.const_type[3] = is_same::value;
+
+  for(int i; i < sizeof(arr)/sizeof(CharT) - 1; ++i)
+foo.chars[i] = (int)arr[i];
+
+  return foo;
+}
+
+int
+main()
+{
+  Foo foo;
+
+  foo = U"\x1\x10001\x10002"_foo;
+  if (foo.type[3] != true) __builtin_abort();
+  if (sizeof(foo.chars)/sizeof(char32_t)-1 != 3) __builtin_abort();
+  if (foo.chars[0] != 65536) __builtin_abort();
+  if (foo.chars[1] != 65537) __builtin_abort();
+  if (foo.chars[2] != 65538) __builtin_abort();
+
+  foo = "\x61\x62\x63"_foo;
+  if (foo.type[0] != true) __builtin_abort();
+  if (sizeof(foo.chars)/sizeof(char)-1 != 3) __builtin_abort();
+  if (foo.chars[0] != 97) __builtin_abort();
+  if (foo.chars[1] != 98) __builtin_abort();

Re: PR C++/58708 - string literal operator templates broken

2013-10-25 Thread Ed Smith-Rowland

On 10/25/2013 10:01 AM, Paolo Carlini wrote:

On 10/25/2013 03:46 PM, Ed Smith-Rowland wrote:

On 10/25/2013 07:54 AM, Paolo Carlini wrote:

On 10/25/2013 01:38 PM, Ed Smith-Rowland wrote:

So, you also want a library testcase?
Up to you: if you feel it would test something that the c++ 
front-end testcase doesn't, why not.


Paolo.

I think this patch should be sufficient - no containers, it just 
follows the pattern of the other tests in the cpp1y directory.
Note, however, that  isn't small at all, and apparently 
you are only using std::is_same which is just a one line template + a 
one line specialization (just grep in testsuite/g++.dg)


Paolo.


Hold up.  something didn't work.
I'll be back later.
Ed



C++14 digit separators..

2013-10-27 Thread Ed Smith-Rowland

Here is an implementation for C++14 digit separators (single quote).

It's still testing on x86_64-linux but I wanted to give folks a chance 
to check it out.


Ed

libcpp:

2013-10-28  Edward Smith-Rowland  <3dw...@verizon.net>

implement C++14 digit separators.
* include/cpplib.h (cpp_options): Add digit_separators flag.
* internal.h (DIGIT_SEP(c)): New macro.
* expr.c (cpp_classify_number): Check improper placement of digit sep;
(cpp_interpret_integer): Skip over digit separators.
* init.c (lang_flags): Add digit_separators flag; (lang_defaults): Add
digit separator flags per language; (cpp_set_lang): Set
digit_separators
* lex.c (lex_number): Add digits separator to allowable characters for
C++14.


gcc/c-family:

2013-10-28  Edward Smith-Rowland  <3dw...@verizon.net>

* c-lex.c (interpret_float): Remove digit separators from scratch string
before building real literal.


gcc/testsuite:

2013-10-28  Edward Smith-Rowland  <3dw...@verizon.net>

* g++.dg/cpp1y/digit-sep.C: New.
* g++.dg/cpp1y/digit-sep-neg.C: New.


libstdc++-v3:

2013-10-28  Edward Smith-Rowland  <3dw...@verizon.net>

implement C++14 digit separators.
* include/include/bits/parse_numbers.h: Change struct _Digit<_Base, '`'>
to struct _Digit<_Base, '\''>.

Index: libcpp/include/cpplib.h
===
--- libcpp/include/cpplib.h (revision 204043)
+++ libcpp/include/cpplib.h (working copy)
@@ -437,6 +437,9 @@
   /* Nonzero for C++ 2014 Standard binary constants.  */
   unsigned char binary_constants;
 
+  /* Nonzero for C++ 2014 Standard digit separators.  */
+  unsigned char digit_separators;
+
   /* Holds the name of the target (execution) character set.  */
   const char *narrow_charset;
 
Index: libcpp/internal.h
===
--- libcpp/internal.h   (revision 204043)
+++ libcpp/internal.h   (working copy)
@@ -59,6 +59,8 @@
 || (((prevc) == 'p' || (prevc) == 'P') \
 && CPP_OPTION (pfile, extended_numbers
 
+#define DIGIT_SEP(c) ((c) == '\'' && CPP_OPTION (pfile, digit_separators))
+
 #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
 #define CPP_BUFFER(PFILE) ((PFILE)->buffer)
 #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base)
Index: libcpp/expr.c
===
--- libcpp/expr.c   (revision 204043)
+++ libcpp/expr.c   (working copy)
@@ -394,6 +394,7 @@
   unsigned int max_digit, result, radix;
   enum {NOT_FLOAT = 0, AFTER_POINT, AFTER_EXPON} float_flag;
   bool seen_digit;
+  bool seen_digit_sep;
 
   if (ud_suffix)
 *ud_suffix = NULL;
@@ -408,6 +409,7 @@
   max_digit = 0;
   radix = 10;
   seen_digit = false;
+  seen_digit_sep = false;
 
   /* First, interpret the radix.  */
   if (*str == '0')
@@ -436,13 +438,24 @@
 
   if (ISDIGIT (c) || (ISXDIGIT (c) && radix == 16))
{
+ seen_digit_sep = false;
  seen_digit = true;
  c = hex_value (c);
  if (c > max_digit)
max_digit = c;
}
+  else if (DIGIT_SEP (c))
+   {
+ if (seen_digit_sep)
+   SYNTAX_ERROR_AT (virtual_location, "adjacent digit separators");
+ seen_digit_sep = true;
+   }
   else if (c == '.')
{
+ if (seen_digit_sep)
+   SYNTAX_ERROR_AT (virtual_location,
+"digit separator adjacent to decimal point");
+ seen_digit_sep = false;
  if (float_flag == NOT_FLOAT)
float_flag = AFTER_POINT;
  else
@@ -452,6 +465,10 @@
   else if ((radix <= 10 && (c == 'e' || c == 'E'))
   || (radix == 16 && (c == 'p' || c == 'P')))
{
+ if (seen_digit_sep)
+   SYNTAX_ERROR_AT (virtual_location,
+"digit separator adjacent to exponent");
+ seen_digit_sep = false;
  float_flag = AFTER_EXPON;
  break;
}
@@ -463,6 +480,10 @@
}
 }
 
+  if (DIGIT_SEP (*str))
+SYNTAX_ERROR_AT (virtual_location,
+"digit separator outside digit sequence");
+
   /* The suffix may be for decimal fixed-point constants without exponent.  */
   if (radix != 16 && float_flag == NOT_FLOAT)
 {
@@ -520,8 +541,13 @@
 
  /* Exponent is decimal, even if string is a hex float.  */
  if (!ISDIGIT (*str))
-   SYNTAX_ERROR_AT (virtual_location, "exponent has no digits");
-
+   {
+ if (DIGIT_SEP (*str))
+   SYNTAX_ERROR_AT (virtual_location,
+"digit separator adjacent to exponent");
+ else
+   SYNTAX_ERROR_AT (virtual_location, "exponent has no digits");
+   }
  do
str++;
  while (ISDIGIT (*str));
@@ -530,6 +556,10 @@
SYNTAX

Re: C++14 digit separators..

2013-10-30 Thread Ed Smith-Rowland

On 10/28/2013 09:44 AM, Jason Merrill wrote:

On 10/28/2013 09:10 AM, Joseph S. Myers wrote:

On Sun, 27 Oct 2013, Ed Smith-Rowland wrote:


Here is an implementation for C++14 digit separators (single quote).


I tend to think that such features should come with a test that the
feature is not enabled for language / standard versions for which it
shouldn't be.  That is, something like

#define m(x) 0
int i = m(1'2)+(3'4);


Good idea.  Other than that, the patch looks good to me.

Jason



OK,

I had to add some more checks in libcpp.
After reading the standard a few times i figured out the magic words are 
"digit separators" - must have digit on both sides.

I also put in the suggested check above.

bootstrapped and fully tested on x86_64-linux.

Still OK?

Ed

Index: libcpp/include/cpplib.h
===
--- libcpp/include/cpplib.h (revision 204189)
+++ libcpp/include/cpplib.h (working copy)
@@ -437,6 +437,9 @@
   /* Nonzero for C++ 2014 Standard binary constants.  */
   unsigned char binary_constants;
 
+  /* Nonzero for C++ 2014 Standard digit separators.  */
+  unsigned char digit_separators;
+
   /* Holds the name of the target (execution) character set.  */
   const char *narrow_charset;
 
Index: libcpp/internal.h
===
--- libcpp/internal.h   (revision 204189)
+++ libcpp/internal.h   (working copy)
@@ -59,6 +59,8 @@
 || (((prevc) == 'p' || (prevc) == 'P') \
 && CPP_OPTION (pfile, extended_numbers
 
+#define DIGIT_SEP(c) ((c) == '\'' && CPP_OPTION (pfile, digit_separators))
+
 #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
 #define CPP_BUFFER(PFILE) ((PFILE)->buffer)
 #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base)
Index: libcpp/expr.c
===
--- libcpp/expr.c   (revision 204189)
+++ libcpp/expr.c   (working copy)
@@ -394,6 +394,7 @@
   unsigned int max_digit, result, radix;
   enum {NOT_FLOAT = 0, AFTER_POINT, AFTER_EXPON} float_flag;
   bool seen_digit;
+  bool seen_digit_sep;
 
   if (ud_suffix)
 *ud_suffix = NULL;
@@ -408,6 +409,7 @@
   max_digit = 0;
   radix = 10;
   seen_digit = false;
+  seen_digit_sep = false;
 
   /* First, interpret the radix.  */
   if (*str == '0')
@@ -416,16 +418,27 @@
   str++;
 
   /* Require at least one hex digit to classify it as hex.  */
-  if ((*str == 'x' || *str == 'X')
- && (str[1] == '.' || ISXDIGIT (str[1])))
+  if (*str == 'x' || *str == 'X')
{
- radix = 16;
- str++;
+ if (str[1] == '.' || ISXDIGIT (str[1]))
+   {
+ radix = 16;
+ str++;
+   }
+ else if (DIGIT_SEP (str[1]))
+   SYNTAX_ERROR_AT (virtual_location,
+"digit separator after base indicator");
}
-  else if ((*str == 'b' || *str == 'B') && (str[1] == '0' || str[1] == 
'1'))
+  else if (*str == 'b' || *str == 'B')
{
- radix = 2;
- str++;
+ if (str[1] == '0' || str[1] == '1')
+   {
+ radix = 2;
+ str++;
+   }
+ else if (DIGIT_SEP (str[1]))
+   SYNTAX_ERROR_AT (virtual_location,
+"digit separator after base indicator");
}
 }
 
@@ -436,13 +449,24 @@
 
   if (ISDIGIT (c) || (ISXDIGIT (c) && radix == 16))
{
+ seen_digit_sep = false;
  seen_digit = true;
  c = hex_value (c);
  if (c > max_digit)
max_digit = c;
}
+  else if (DIGIT_SEP (c))
+   {
+ if (seen_digit_sep)
+   SYNTAX_ERROR_AT (virtual_location, "adjacent digit separators");
+ seen_digit_sep = true;
+   }
   else if (c == '.')
{
+ if (seen_digit_sep || DIGIT_SEP (*str))
+   SYNTAX_ERROR_AT (virtual_location,
+"digit separator adjacent to decimal point");
+ seen_digit_sep = false;
  if (float_flag == NOT_FLOAT)
float_flag = AFTER_POINT;
  else
@@ -452,6 +476,9 @@
   else if ((radix <= 10 && (c == 'e' || c == 'E'))
   || (radix == 16 && (c == 'p' || c == 'P')))
{
+ if (seen_digit_sep || DIGIT_SEP (*str))
+   SYNTAX_ERROR_AT (virtual_location,
+"digit separator adjacent to exponent");
  float_flag = AFTER_EXPON;
  break;
}
@@ -463,6 +490,10 @@
}
 }
 
+  if (seen_digi

Re: PR C++/58708 - string literal operator templates broken

2013-10-31 Thread Ed Smith-Rowland

On 10/25/2013 10:40 AM, Jakub Jelinek wrote:

On Fri, Oct 25, 2013 at 10:29:41AM -0400, Ed Smith-Rowland wrote:

2013-10-25  Edward Smith-Rowland  <3dw...@verizon.net>

 PR c++/58708
* parser.c (make_string_pack): Discover non-const type and size
of character and build parm pack with correct type and chars.

gcc/testsuite:

2013-10-25  Edward Smith-Rowland  <3dw...@verizon.net>

 PR c++/58708
*g++.dg/cpp1y/pr58708.C : New.
--- testsuite/g++.dg/cpp1y/pr58708.C(revision 0)
+++ testsuite/g++.dg/cpp1y/pr58708.C(working copy)
@@ -0,0 +1,91 @@
+// { dg-options -std=c++1y }
+// { dg-do run }
+
+template
+  struct integral_constant
+  {
+static constexpr _Tp  value = __v;
+typedef _Tp   value_type;
+typedef integral_constant<_Tp, __v>   type;
+constexpr operator value_type() const { return value; }
+constexpr value_type operator()() const { return value; }
+  };
+
+template
+  constexpr _Tp integral_constant<_Tp, __v>::value;
+
+typedef integral_constant true_type;
+
+typedef integral_constantfalse_type;
+
+template
+  struct is_same
+  : public false_type { };
+
+template
+  struct is_same<_Tp, _Tp>
+  : public true_type { };

Why not just the minimal:
template< class T, class U >
struct is_same {
   static constexpr bool value = false;
};

template< class T >
struct is_same {
   static constexpr bool value = true;
};
other tests are using?

Jakub


All,

Here is a new patch.  It's the same patch but a lighter testcase.

Built and tested on x86_64-linux.

OK?

Ed


gcc/cp:

2013-10-31  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58708
* parser.c (make_string_pack): Discover non-const type and size
of character and build parm pack with correct type and chars.

gcc/testsuite:

2013-10-31  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58708
*g++.dg/cpp1y/pr58708.C : New.

Index: cp/parser.c
===
--- cp/parser.c (revision 203997)
+++ cp/parser.c (working copy)
@@ -3793,22 +3793,39 @@
   tree charvec;
   tree argpack = make_node (NONTYPE_ARGUMENT_PACK);
   const char *str = TREE_STRING_POINTER (value);
-  int i, len = TREE_STRING_LENGTH (value) - 1;
+  int sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (value;
+  int len = TREE_STRING_LENGTH (value) / sz - 1;
   tree argvec = make_tree_vec (2);
 
-  tree string_char_type_node = TREE_TYPE (TREE_TYPE (value));
+  tree str_char_type_node = TREE_TYPE (TREE_TYPE (value));
+  str_char_type_node = TYPE_MAIN_VARIANT (str_char_type_node);
 
   /* First template parm is character type.  */
-  TREE_VEC_ELT (argvec, 0) = string_char_type_node;
+  TREE_VEC_ELT (argvec, 0) = str_char_type_node;
 
   /* Fill in CHARVEC with all of the parameters.  */
   charvec = make_tree_vec (len);
-  for (i = 0; i < len; ++i)
-TREE_VEC_ELT (charvec, i) = build_int_cst (string_char_type_node, str[i]);
+  if (sz == 1)
+{
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, str[i]);
+}
+  else if (sz == 2)
+{
+  const uint16_t *num = (const uint16_t *)str;
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
+}
+  else if (sz == 4)
+{
+  const uint32_t *num = (const uint32_t *)str;
+  for (int i = 0; i < len; ++i)
+   TREE_VEC_ELT (charvec, i) = build_int_cst (str_char_type_node, num[i]);
+}
 
   /* Build the argument packs.  */
   SET_ARGUMENT_PACK_ARGS (argpack, charvec);
-  TREE_TYPE (argpack) = string_char_type_node;
+  TREE_TYPE (argpack) = str_char_type_node;
 
   TREE_VEC_ELT (argvec, 1) = argpack;
 
Index: testsuite/g++.dg/cpp1y/pr58708.C
===
--- testsuite/g++.dg/cpp1y/pr58708.C(revision 0)
+++ testsuite/g++.dg/cpp1y/pr58708.C(working copy)
@@ -0,0 +1,60 @@
+// { dg-options -std=c++1y }
+// { dg-do run }
+
+template
+  struct is_same
+  {
+static constexpr bool value = false;
+  };
+
+template
+  struct is_same<_Tp, _Tp>
+  {
+static constexpr bool value = true;
+  };
+
+template
+  struct Foo
+  {
+using char_type = CharT;
+char_type chars[sizeof...(Str)]{Str...};
+  };
+
+template
+  Foo
+  operator""_foo()
+  {
+return Foo();
+  }
+
+int
+main()
+{
+  auto fooU = U"\x1\x10001\x10002"_foo;
+  if (is_same::value != true) 
__builtin_abort();
+  if (sizeof(fooU.chars)/sizeof(char32_t) != 3) __builtin_abort();
+  if (fooU.chars[0] != 65536) __builtin_abort();
+  if (fooU.chars[1] != 65537) __builtin_abort();
+  if (fooU.chars[2] != 65538) __builtin_abort();
+
+  auto foo = "\x61\x62\x63"_foo;
+  if (is_same::value != true) 
__builtin_abort();
+  if (sizeof(foo.chars)/si

TR29124 C++ Special Maths - Make pull functions into global namespace.

2016-01-20 Thread Ed Smith-Rowland
Now that libstdc++ installs a proper math.h we can piggyback on that to 
put in the last bit of TR29124.


This patch adds the math special functions to c_compatibility/math.h in 
the global namespace.

I remove the XFAILs from the compile_2.cc tests.

This converts 21 XFAILs into 21 PASSes.

Tested on x86_64-linux.

I understand if this is too late.
I'll put it up on trunk and backport after stage 1 reopens.

Meanwhile I'll commit this to the tr29124 branch.

Ed

2016-01-20  Edward Smith-Rowland  <3dw...@verizon.net>

TR29124 C++ Special Math -  pulls funcs into global namespace.
* include/c_compatibility/math.h: Import the TR29124 functions
into the global namespace.
* testsuite/special_functions/01_assoc_laguerre/compile_2.cc: Remove
xfail and make compile-only.
* testsuite/special_functions/02_assoc_legendre/compile_2.cc: Ditto.
* testsuite/special_functions/03_beta/compile_2.cc: Ditto.
* testsuite/special_functions/04_comp_ellint_1/compile_2.cc: Ditto.
* testsuite/special_functions/05_comp_ellint_2/compile_2.cc: Ditto.
* testsuite/special_functions/06_comp_ellint_3/compile_2.cc: Ditto.
* testsuite/special_functions/07_cyl_bessel_i/compile_2.cc: Ditto.
* testsuite/special_functions/08_cyl_bessel_j/compile_2.cc: Ditto.
* testsuite/special_functions/09_cyl_bessel_k/compile_2.cc: Ditto.
* testsuite/special_functions/10_cyl_neumann/compile_2.cc: Ditto.
* testsuite/special_functions/11_ellint_1/compile_2.cc: Ditto.
* testsuite/special_functions/12_ellint_2/compile_2.cc: Ditto.
* testsuite/special_functions/13_ellint_3/compile_2.cc: Ditto.
* testsuite/special_functions/14_expint/compile_2.cc: Ditto.
* testsuite/special_functions/15_hermite/compile_2.cc: Ditto.
* testsuite/special_functions/16_laguerre/compile_2.cc: Ditto.
* testsuite/special_functions/17_legendre/compile_2.cc: Ditto.
* testsuite/special_functions/18_riemann_zeta/compile_2.cc: Ditto.
* testsuite/special_functions/19_sph_bessel/compile_2.cc: Ditto.
* testsuite/special_functions/20_sph_legendre/compile_2.cc: Ditto.
* testsuite/special_functions/21_sph_neumann/compile_2.cc: Ditto.
Index: include/c_compatibility/math.h
===
--- include/c_compatibility/math.h  (revision 232610)
+++ include/c_compatibility/math.h  (working copy)
@@ -75,70 +75,71 @@
 #endif
 
 #if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1
-using std::assoc_laguerref
-using std::assoc_laguerrel
-using std::assoc_laguerre
-using std::assoc_legendref
-using std::assoc_legendrel
-using std::assoc_legendre
-using std::betaf
-using std::betal
-using std::beta
-using std::comp_ellint_1f
-using std::comp_ellint_1l
-using std::comp_ellint_1
-using std::comp_ellint_2f
-using std::comp_ellint_2l
-using std::comp_ellint_2
-using std::comp_ellint_3f
-using std::comp_ellint_3l
-using std::comp_ellint_3
-using std::cyl_bessel_if
-using std::cyl_bessel_il
-using std::cyl_bessel_i
-using std::cyl_bessel_jf
-using std::cyl_bessel_jl
-using std::cyl_bessel_j
-using std::cyl_bessel_kf
-using std::cyl_bessel_kl
-using std::cyl_bessel_k
-using std::cyl_neumannf
-using std::cyl_neumannl
-using std::cyl_neumann
-using std::ellint_1f
-using std::ellint_1l
-using std::ellint_1
-using std::ellint_2f
-using std::ellint_2l
-using std::ellint_2
-using std::ellint_3f
-using std::ellint_3l
-using std::ellint_3
-using std::expintf
-using std::expintl
-using std::expint
-using std::hermitef
-using std::hermitel
-using std::hermite
-using std::laguerref
-using std::laguerrel
-using std::laguerre
-using std::legendref
-using std::legendrel
-using std::legendre
-using std::riemann_zetaf
-using std::riemann_zetal
-using std::riemann_zeta
-using std::sph_besself
-using std::sph_bessell
-using std::sph_bessel
-using std::sph_legendref
-using std::sph_legendrel
-using std::sph_legendre
-using std::sph_neumannf
-using std::sph_neumannl
-using std::sph_neumann
-#endif
-#endif
+using std::assoc_laguerref;
+using std::assoc_laguerrel;
+using std::assoc_laguerre;
+using std::assoc_legendref;
+using std::assoc_legendrel;
+using std::assoc_legendre;
+using std::betaf;
+using std::betal;
+using std::beta;
+using std::comp_ellint_1f;
+using std::comp_ellint_1l;
+using std::comp_ellint_1;
+using std::comp_ellint_2f;
+using std::comp_ellint_2l;
+using std::comp_ellint_2;
+using std::comp_ellint_3f;
+using std::comp_ellint_3l;
+using std::comp_ellint_3;
+using std::cyl_bessel_if;
+using std::cyl_bessel_il;
+using std::cyl_bessel_i;
+using std::cyl_bessel_jf;
+using std::cyl_bessel_jl;
+using std::cyl_bessel_j;
+using std::cyl_bessel_kf;
+using std::cyl_bessel_kl;
+using std::cyl_bessel_k;
+using std::cyl_neumannf;
+using std::cyl_neumannl;
+using std::cyl_neumann;
+using std::ellint_1f;
+using std::ellint_1l;
+using std::ellint_1;
+using std::ellint_2f;
+using std::ellint_2

Re: TR29124 C++ Special Maths - Make pull functions into global namespace.

2016-01-21 Thread Ed Smith-Rowland

On 01/21/2016 07:29 AM, Jonathan Wakely wrote:

On 20/01/16 20:30 -0500, Ed Smith-Rowland wrote:
Now that libstdc++ installs a proper math.h we can piggyback on that 
to put in the last bit of TR29124.


This patch adds the math special functions to c_compatibility/math.h 
in the global namespace.

I remove the XFAILs from the compile_2.cc tests.

This converts 21 XFAILs into 21 PASSes.

Tested on x86_64-linux.

I understand if this is too late.
I'll put it up on trunk and backport after stage 1 reopens.

Meanwhile I'll commit this to the tr29124 branch.


I'm inclined to say the change is OK for trunk now. We've added math.h
and we've added the special functions, it would be good if the two new
things work together.

However ...


Index: include/c_compatibility/math.h
===
--- include/c_compatibility/math.h(revision 232610)
+++ include/c_compatibility/math.h(working copy)
@@ -75,70 +75,71 @@
#endif

#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1
-using std::assoc_laguerref


This doesn't look like the right patch, because these lines aren't in
the version on trunk.


I must have given you a negative patch relative to the tr29124 
branch...  Sigh.

I'll make a new one.
Those lines have to be *added*.
Sorry.



Re: TR29124 C++ Special Maths - Make pull functions into global namespace.

2016-01-22 Thread Ed Smith-Rowland

On 01/22/2016 05:39 AM, Jonathan Wakely wrote:

On 21/01/16 19:07 -0500, Ed Smith-Rowland wrote:

On 01/21/2016 07:29 AM, Jonathan Wakely wrote:

On 20/01/16 20:30 -0500, Ed Smith-Rowland wrote:
Now that libstdc++ installs a proper math.h we can piggyback on 
that to put in the last bit of TR29124.


This patch adds the math special functions to 
c_compatibility/math.h in the global namespace.

I remove the XFAILs from the compile_2.cc tests.

This converts 21 XFAILs into 21 PASSes.

Tested on x86_64-linux.

I understand if this is too late.
I'll put it up on trunk and backport after stage 1 reopens.

Meanwhile I'll commit this to the tr29124 branch.


I'm inclined to say the change is OK for trunk now. We've added math.h
and we've added the special functions, it would be good if the two new
things work together.

However ...


Index: include/c_compatibility/math.h
===
--- include/c_compatibility/math.h(revision 232610)
+++ include/c_compatibility/math.h(working copy)
@@ -75,70 +75,71 @@
#endif

#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1
-using std::assoc_laguerref


This doesn't look like the right patch, because these lines aren't in
the version on trunk.


I must have given you a negative patch relative to the tr29124 
branch...  Sigh.

I'll make a new one.
Those lines have to be *added*.
Sorry.


No problem. It looks like it was a partial patch, adding semi-colons
to the using declarations, so you just need to diff against the
previous revision instead.



Here are the correct patches.

Retested on x86-64-linux.

Committed as revision 232755.

Ed

2016-01-22  Edward Smith-Rowland  <3dw...@verizon.net>

TR29124 C++ Special Math -  pulls funcs into global namespace.
* include/c_compatibility/math.h: Import the TR29124 functions
into the global namespace.
* testsuite/special_functions/01_assoc_laguerre/compile_2.cc: Remove
xfail and make compile-only.
* testsuite/special_functions/02_assoc_legendre/compile_2.cc: Ditto.
* testsuite/special_functions/03_beta/compile_2.cc: Ditto.
* testsuite/special_functions/04_comp_ellint_1/compile_2.cc: Ditto.
* testsuite/special_functions/05_comp_ellint_2/compile_2.cc: Ditto.
* testsuite/special_functions/06_comp_ellint_3/compile_2.cc: Ditto.
* testsuite/special_functions/07_cyl_bessel_i/compile_2.cc: Ditto.
* testsuite/special_functions/08_cyl_bessel_j/compile_2.cc: Ditto.
* testsuite/special_functions/09_cyl_bessel_k/compile_2.cc: Ditto.
* testsuite/special_functions/10_cyl_neumann/compile_2.cc: Ditto.
* testsuite/special_functions/11_ellint_1/compile_2.cc: Ditto.
* testsuite/special_functions/12_ellint_2/compile_2.cc: Ditto.
* testsuite/special_functions/13_ellint_3/compile_2.cc: Ditto.
* testsuite/special_functions/14_expint/compile_2.cc: Ditto.
* testsuite/special_functions/15_hermite/compile_2.cc: Ditto.
* testsuite/special_functions/16_laguerre/compile_2.cc: Ditto.
* testsuite/special_functions/17_legendre/compile_2.cc: Ditto.
* testsuite/special_functions/18_riemann_zeta/compile_2.cc: Ditto.
* testsuite/special_functions/19_sph_bessel/compile_2.cc: Ditto.
* testsuite/special_functions/20_sph_legendre/compile_2.cc: Ditto.
* testsuite/special_functions/21_sph_neumann/compile_2.cc: Ditto.

Index: include/c_compatibility/math.h
===
--- include/c_compatibility/math.h  (revision 232742)
+++ include/c_compatibility/math.h  (working copy)
@@ -111,5 +111,73 @@
 using std::trunc;
 #endif // C++11 && _GLIBCXX_USE_C99_MATH_TR1
 
-#endif
-#endif
+#if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 1
+using std::assoc_laguerref;
+using std::assoc_laguerrel;
+using std::assoc_laguerre;
+using std::assoc_legendref;
+using std::assoc_legendrel;
+using std::assoc_legendre;
+using std::betaf;
+using std::betal;
+using std::beta;
+using std::comp_ellint_1f;
+using std::comp_ellint_1l;
+using std::comp_ellint_1;
+using std::comp_ellint_2f;
+using std::comp_ellint_2l;
+using std::comp_ellint_2;
+using std::comp_ellint_3f;
+using std::comp_ellint_3l;
+using std::comp_ellint_3;
+using std::cyl_bessel_if;
+using std::cyl_bessel_il;
+using std::cyl_bessel_i;
+using std::cyl_bessel_jf;
+using std::cyl_bessel_jl;
+using std::cyl_bessel_j;
+using std::cyl_bessel_kf;
+using std::cyl_bessel_kl;
+using std::cyl_bessel_k;
+using std::cyl_neumannf;
+using std::cyl_neumannl;
+using std::cyl_neumann;
+using std::ellint_1f;
+using std::ellint_1l;
+using std::ellint_1;
+using std::ellint_2f;
+using std::ellint_2l;
+using std::ellint_2;
+using std::ellint_3f;
+using std::ellint_3l;
+using std::ellint_3;
+using std::expintf;
+using std::expintl;
+using std::expint;
+using std::hermitef;
+using std::hermitel;
+using std:

Re: [patch] Remove empty directories

2013-11-29 Thread Ed Smith-Rowland

On 11/29/2013 08:38 AM, Matthias Klose wrote:

trunk has some empty directories. ok to remove?

gcc/testsuite/go.test/test/fixedbugs/bug478.dir
libstdc++-v3/testsuite/experimental/string_view/requirements/exception
libstdc++-v3/testsuite/experimental/string_view/capacity/wchar_t
libstdc++-v3/testsuite/experimental/string_view/capacity/char


Yes, please.  Sorry I left them.



[C++11] DR1479 - Literal operators and default arguments

2013-12-05 Thread Ed Smith-Rowland
This patch rejects literal operators with defaulted arguments with an extra 
note to that effect.  Not a big deal but it responds to  a "malformed program" 
statement in the draft.

Builds and tests clean on x86_64-linux.  OK?

Ed




CL_udlit_nodefault
Description: Binary data


patch_udlit_nodefault
Description: Binary data


Re: TR1 Special Math

2015-10-25 Thread Ed Smith-Rowland

On 10/24/2015 11:38 PM, Jonathan Wakely wrote:

On 8 May 2015 at 15:05, Ed Smith-Rowland <3dw...@verizon.net> wrote:

On 05/07/2015 12:06 PM, Jonathan Wakely wrote:

Hi Ed,

The C++ committee is considering the
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4437.pdf
proposal to make C++17 include the contents of ISO 29124:2010 (the
special math functions from TR1 that went into a separate standard,
not into C++11).

What is the status of our TR1 implementation? Is it complete? Good
enough quality to move out of the tr1 sub-dir?

Even if N4437 isn't accepted for C++17 we could move things around to
turn the TR1 code into an iso29124 implementation, do you think that
would make sense?


That would make absolute sense.
I actually have a tree where I've done that.
All the functions are in there (29124 removed the hypergeometric functions.
I'd like to keep those as extensions.
I have some bugfixes also.

I have a better version of the Carlson elliptic functions (which are used in
the 29124 elliptic functions).

Ed


Hi Ed, Florian,

Here's a patch to re-use the TR1 math functions to implement IS 29124,
what do you think of this approach? Ed, were you just going to copy
the files and have duplicated code?

We should probably uglify the names of the hypergeometric functions if
they are not in the final standard.

This doesn't include Florian's patch, which should be applied.

(I want to get this done before stage 1 ends in a couple of weeks, so
am posting this for review now, but I'll be unavailable for the next
week or two and might not be able to actually commit anything until
stage 3).

Hi all!

I am actually very aware of the stage 1 deadline and am working furiously!

This patch adds the hypergeometric and confluent hypergeometric 
functions that were actually stricken fromTR29124.
I actually had a mind to add those back especially since the confluent 
one is actually pretty stable in it's realm and is used in some 
statistics tests.
I expect that some people have ventures to use both and so TR29129 would 
not be a full replacement for TR1 without them.


I intend to post within the next few days.  I have to realize that some 
of my hopes and dreams would be better done with these in tree! ;-)


Thank you for lighting a fire Jonathan!

Ed



Re: TR1 Special Math

2015-11-13 Thread Ed Smith-Rowland

On 11/13/2015 10:32 AM, Jonathan Wakely wrote:

On 25 October 2015 at 20:48, Jonathan Wakely  wrote:

On 25 October 2015 at 17:46, Ed Smith-Rowland <3dw...@verizon.net> wrote:

On 10/24/2015 11:38 PM, Jonathan Wakely wrote:

On 8 May 2015 at 15:05, Ed Smith-Rowland <3dw...@verizon.net> wrote:

On 05/07/2015 12:06 PM, Jonathan Wakely wrote:

Hi Ed,

The C++ committee is considering the
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4437.pdf
proposal to make C++17 include the contents of ISO 29124:2010 (the
special math functions from TR1 that went into a separate standard,
not into C++11).

What is the status of our TR1 implementation? Is it complete? Good
enough quality to move out of the tr1 sub-dir?

Even if N4437 isn't accepted for C++17 we could move things around to
turn the TR1 code into an iso29124 implementation, do you think that
would make sense?


That would make absolute sense.
I actually have a tree where I've done that.
All the functions are in there (29124 removed the hypergeometric
functions.
I'd like to keep those as extensions.
I have some bugfixes also.

I have a better version of the Carlson elliptic functions (which are used
in
the 29124 elliptic functions).

Ed


Hi Ed, Florian,

Here's a patch to re-use the TR1 math functions to implement IS 29124,
what do you think of this approach? Ed, were you just going to copy
the files and have duplicated code?

We should probably uglify the names of the hypergeometric functions if
they are not in the final standard.

This doesn't include Florian's patch, which should be applied.

(I want to get this done before stage 1 ends in a couple of weeks, so
am posting this for review now, but I'll be unavailable for the next
week or two and might not be able to actually commit anything until
stage 3).

Hi all!

I am actually very aware of the stage 1 deadline and am working furiously!

This patch adds the hypergeometric and confluent hypergeometric functions
that were actually stricken fromTR29124.
I actually had a mind to add those back especially since the confluent one
is actually pretty stable in it's realm and is used in some statistics
tests.
I expect that some people have ventures to use both and so TR29129 would not
be a full replacement for TR1 without them.

I intend to post within the next few days.  I have to realize that some of
my hopes and dreams would be better done with these in tree! ;-)

Thank you for lighting a fire Jonathan!

Excellent, glad to hear you're on this, as you know the code and the
specs, whereas I'm poking around blindly :-)

Hi Ed,

Have you been able to find enough time to work on this?

Will you be able to make the stage 1 deadline tomorrow, and if not, do
you think I should apply my patch to re-use the TR1 stuff?  (We can
apply Florian's bug fix to that as well).


I'm going to post something in a few hours.



Re: Aw: Re: TR1 Special Math

2015-11-16 Thread Ed Smith-Rowland

On 11/16/2015 07:28 PM, Florian Goth wrote:

Hi all,
just a quick note that I'm still around...
Any particular pointers how I can help in improving the implementation?
Cheers,
Florian.


Gesendet: Samstag, 14. November 2015 um 21:40 Uhr
Von: "Ed Smith-Rowland" <3dw...@verizon.net>
An: "Jonathan Wakely" 
Cc: libstdc++ , gcc-patches , "Florian 
Goth" 
Betreff: Re: TR1 Special Math

On 11/14/2015 03:28 PM, Ed Smith-Rowland wrote:

On 11/13/2015 11:20 AM, Ed Smith-Rowland wrote:

On 11/13/2015 10:32 AM, Jonathan Wakely wrote:

On 25 October 2015 at 20:48, Jonathan Wakely 
wrote:

On 25 October 2015 at 17:46, Ed Smith-Rowland <3dw...@verizon.net>
wrote:

On 10/24/2015 11:38 PM, Jonathan Wakely wrote:

On 8 May 2015 at 15:05, Ed Smith-Rowland <3dw...@verizon.net> wrote:

On 05/07/2015 12:06 PM, Jonathan Wakely wrote:

Hi Ed,

The C++ committee is considering the
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4437.pdf
proposal to make C++17 include the contents of ISO 29124:2010 (the
special math functions from TR1 that went into a separate
standard,
not into C++11).

What is the status of our TR1 implementation? Is it complete? Good
enough quality to move out of the tr1 sub-dir?

Even if N4437 isn't accepted for C++17 we could move things
around to
turn the TR1 code into an iso29124 implementation, do you think
that
would make sense?


That would make absolute sense.
I actually have a tree where I've done that.
All the functions are in there (29124 removed the hypergeometric
functions.
I'd like to keep those as extensions.
I have some bugfixes also.

I have a better version of the Carlson elliptic functions (which
are used
in
the 29124 elliptic functions).

Ed


Hi Ed, Florian,

Here's a patch to re-use the TR1 math functions to implement IS
29124,
what do you think of this approach? Ed, were you just going to copy
the files and have duplicated code?

We should probably uglify the names of the hypergeometric
functions if
they are not in the final standard.

This doesn't include Florian's patch, which should be applied.

(I want to get this done before stage 1 ends in a couple of
weeks, so
am posting this for review now, but I'll be unavailable for the next
week or two and might not be able to actually commit anything until
stage 3).

Hi all!

I am actually very aware of the stage 1 deadline and am working
furiously!

This patch adds the hypergeometric and confluent hypergeometric
functions
that were actually stricken fromTR29124.
I actually had a mind to add those back especially since the
confluent one
is actually pretty stable in it's realm and is used in some
statistics
tests.
I expect that some people have ventures to use both and so TR29129
would not
be a full replacement for TR1 without them.

I intend to post within the next few days.  I have to realize that
some of
my hopes and dreams would be better done with these in tree! ;-)

Thank you for lighting a fire Jonathan!

Excellent, glad to hear you're on this, as you know the code and the
specs, whereas I'm poking around blindly :-)

Hi Ed,

Have you been able to find enough time to work on this?

Will you be able to make the stage 1 deadline tomorrow, and if not, do
you think I should apply my patch to re-use the TR1 stuff? (We can
apply Florian's bug fix to that as well).


I'm going to post something in a few hours.



OK,

this is still testing but I wanted to get it in under the deadline.
It is basically a combination of Jonathan's approach using TR1 (which
I do for C++03)
Plus the start of a new impl in bits.
Plus patches from Florian.

Ed



The last patchwas missing some tests.
I'm also going to bzip it - I realized it was huge.


Immediately: I have a good patch with xfails where #include  
should inject into namespace std.  That's probably a one liner in the 
makefiles that's better done in tree.  That stuff kills me.

The values checking and NaN checking is very good.

Once this gets in we'll have all the functions in TR29124 and most of
n3494 - A proposal to add special mathematical functions according to 
the ISO/IEC 8-2:2009 standard.

I stuck the latter in namespace __gnu_cxx.
We need test cases - especially ones that cross switches between 
different algorithms.
I discovered while testing the Airy functions that I had a long standing 
bug that the x<2 and fractional order bessel functions were returning junk!
Our Bessel functions are dodgy for nu >~ 50 - We need an Olver 
asymptotic expansion.


Many one dimensional functions could use a fit (Checbyshev, polynomial, 
rational...).
I still want general algorithms around so we have the tools to generate 
these magic numbers though.


Where angels fear to tread...
The special functions TRs punted on complex functions.
I see no reason to deprive our users of some of these functions.
The gamma function is easy and is actually standard

[PATCH libquadmath, pr68686] tgammaq(x) is always negative for noninteger x < 0

2017-11-13 Thread Ed Smith-Rowland

Here is a patch for tammaq for negative argument pr68686.

I know about depending on ports from upstream but this was done recently 
and this (tgammaq) was left out.


This patch is basically a one-liner.

I have test cases but libquadmath doesn't have a testsuite.

One test just shows alternating signs for -0.5Q, -1.5Q, -2.5Q, etc.

Another test verifies the Gamma reflection formula:

 tgamma(1-x) * tgamma(x) - pi / sinq(pi*x) is tiny.

Builds on x86_64-linux and tests correctly offline.


OK?


2017-11-10  Edward Smith-Rowland  <3dw...@verizon.net>

PR libquadmath/68686
* math/tgammaq.c: Correct sign for negative argument.
diff --git a/libquadmath/math/tgammaq.c b/libquadmath/math/tgammaq.c
index a07d583..3080094 100644
--- a/libquadmath/math/tgammaq.c
+++ b/libquadmath/math/tgammaq.c
@@ -47,7 +47,9 @@ tgammaq (__float128 x)
 /* x == -Inf.  According to ISO this is NaN.  */
 return x - x;
 
-  /* XXX FIXME.  */
   res = expq (lgammaq (x));
-  return signbitq (x) ? -res : res;
+  if (x > 0.0Q || ((int)(-x) & 1) == 1)
+return res;
+  else
+return -res;
 }
#include 
#include 

void
test_alt_signs()
{
  __float128 result = tgammaq(-1.5Q);
  assert(result > 0.0Q);

  result = tgammaq(-2.5Q);
  assert(result < 0.0Q);

  result = tgammaq(-3.5Q);
  assert(result > 0.0Q);

  result = tgammaq(-4.5Q);
  assert(result < 0.0Q);
}

/*
 * Return |\Gamma(x) \Gamma(1 - x) - \frac{\pi}{sin(\pi x)}|
 */
__float128
abs_delta(__float128 x)
{
  return fabsq(tgammaq(x) * tgammaq(1.0Q - x) - M_PIq / sinq(M_PIq * x));
}

/*
 * Test reflection: \Gamma(x) \Gamma(1 - x) = \frac{\pi}{sin(\pi x)}
 */
void
test_reflection()
{
  assert(abs_delta(+1.5Q) < 100 * FLT128_EPSILON);
  assert(abs_delta(+0.5Q) < 100 * FLT128_EPSILON);
  assert(abs_delta(-0.5Q) < 100 * FLT128_EPSILON);
  assert(abs_delta(-1.5Q) < 100 * FLT128_EPSILON);
  assert(abs_delta(-2.5Q) < 100 * FLT128_EPSILON);
}

int
main()
{
  test_alt_signs();

  test_reflection();

  return 0;
}


Re: [PATCH libstdc++/66689] comp_ellint_3 and ellint_3 return garbage values

2017-11-18 Thread Ed Smith-Rowland

On 11/17/2017 03:54 PM, Jonathan Wakely wrote:


Hmm, you're probably right. I'd be tempted to though.

I had an idea.  What about a macro _GLIBCXX_ELLINT_3_POS_NU or something 
that:


1. would allow users to detect which convention is on by default.

2. They could set or unset to get the other convention.

It's bloody but it would work.  it would prevent users from having to 
test the compiler version and guess or check the value every time.


I feel that distros are likely to pick up gcc-7 soon and I'd like to do 
*something*.  This would be something of a transition path.


Ed




Re: [libstdc++] Expose Airy functions.

2017-11-18 Thread Ed Smith-Rowland

Here is the final patch fir libstdc++ Airy functions...

2017-11-18  Edward Smith-Rowland  <3dw...@verizon.net>

* include/bits/specfun.h: Expose airy_ai and airy_bi.
* include/tr1/modified_bessel_func.tcc: Treat NaN and inf arg, return.
* testsuite/ext/special_functions/airy_ai/check_nan.cc: New.
* testsuite/ext/special_functions/airy_ai/check_value.cc: New.
* testsuite/ext/special_functions/airy_ai/compile.cc: New.
* testsuite/ext/special_functions/airy_bi/check_nan.cc: New.
* testsuite/ext/special_functions/airy_bi/check_value.cc: New.
* testsuite/ext/special_functions/airy_bi/compile.cc: New.
Index: include/bits/specfun.h
===
--- include/bits/specfun.h	(revision 254915)
+++ include/bits/specfun.h	(working copy)
@@ -1206,6 +1206,78 @@
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+  // Airy functions
+
+  /**
+   * Return the Airy function @f$ Ai(x) @f$ of @c float argument x.
+   */
+  inline float
+  airy_aif(float __x)
+  {
+float __Ai, __Bi, __Aip, __Bip;
+std::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip);
+return __Ai;
+  }
+
+  /**
+   * Return the Airy function @f$ Ai(x) @f$ of long double argument x.
+   */
+  inline long double
+  airy_ail(long double __x)
+  {
+long double __Ai, __Bi, __Aip, __Bip;
+std::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip);
+return __Ai;
+  }
+
+  /**
+   * Return the Airy function @f$ Ai(x) @f$ of real argument x.
+   */
+  template
+inline typename __gnu_cxx::__promote<_Tp>::__type
+airy_ai(_Tp __x)
+{
+  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+  __type __Ai, __Bi, __Aip, __Bip;
+  std::__detail::__airy<__type>(__x, __Ai, __Bi, __Aip, __Bip);
+  return __Ai;
+}
+
+  /**
+   * Return the Airy function @f$ Bi(x) @f$ of @c float argument x.
+   */
+  inline float
+  airy_bif(float __x)
+  {
+float __Ai, __Bi, __Aip, __Bip;
+std::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip);
+return __Bi;
+  }
+
+  /**
+   * Return the Airy function @f$ Bi(x) @f$ of long double argument x.
+   */
+  inline long double
+  airy_bil(long double __x)
+  {
+long double __Ai, __Bi, __Aip, __Bip;
+std::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip);
+return __Bi;
+  }
+
+  /**
+   * Return the Airy function @f$ Bi(x) @f$ of real argument x.
+   */
+  template
+inline typename __gnu_cxx::__promote<_Tp>::__type
+airy_bi(_Tp __x)
+{
+  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+  __type __Ai, __Bi, __Aip, __Bip;
+  std::__detail::__airy<__type>(__x, __Ai, __Bi, __Aip, __Bip);
+  return __Bi;
+}
+
   // Confluent hypergeometric functions
 
   /**
Index: include/tr1/modified_bessel_func.tcc
===
--- include/tr1/modified_bessel_func.tcc	(revision 254915)
+++ include/tr1/modified_bessel_func.tcc	(working copy)
@@ -377,9 +377,20 @@
   const _Tp __absx = std::abs(__x);
   const _Tp __rootx = std::sqrt(__absx);
   const _Tp __z = _Tp(2) * __absx * __rootx / _Tp(3);
+  const _Tp _S_NaN = std::numeric_limits<_Tp>::quiet_NaN();
+  const _Tp _S_inf = std::numeric_limits<_Tp>::infinity();
 
-  if (__x > _Tp(0))
+  if (__isnan(__x))
+__Bip = __Aip = __Bi = __Ai = std::numeric_limits<_Tp>::quiet_NaN();
+  else if (__z == _S_inf)
 {
+	  __Aip = __Ai = _Tp{0};
+	  __Bip = __Bi = _S_inf;
+	}
+  else if (__z == -_S_inf)
+	__Bip = __Aip = __Bi = __Ai = _Tp{0};
+  else if (__x > _Tp(0))
+{
   _Tp __I_nu, __Ip_nu, __K_nu, __Kp_nu;
 
   __bessel_ik(_Tp(1) / _Tp(3), __z, __I_nu, __K_nu, __Ip_nu, __Kp_nu);
Index: include/tr1/modified_bessel_func.tcc
===
--- include/tr1/modified_bessel_func.tcc	(revision 254915)
+++ include/tr1/modified_bessel_func.tcc	(working copy)
@@ -377,9 +377,20 @@
   const _Tp __absx = std::abs(__x);
   const _Tp __rootx = std::sqrt(__absx);
   const _Tp __z = _Tp(2) * __absx * __rootx / _Tp(3);
+  const _Tp _S_NaN = std::numeric_limits<_Tp>::quiet_NaN();
+  const _Tp _S_inf = std::numeric_limits<_Tp>::infinity();
 
-  if (__x > _Tp(0))
+  if (__isnan(__x))
+__Bip = __Aip = __Bi = __Ai = std::numeric_limits<_Tp>::quiet_NaN();
+  else if (__z == _S_inf)
 {
+	  __Aip = __Ai = _Tp{0};
+	  __Bip = __Bi = _S_inf;
+	}
+  else if (__z == -_S_inf)
+	__Bip = __Aip = __Bi = __Ai = _Tp{0};
+  else if (__x > _Tp(0))
+{
   _Tp __I_nu, __Ip_nu, __K_nu, __Kp_nu;
 
   __bessel_ik(_Tp(1) / _Tp(3), __z, __I_nu, __K_nu, __Ip_nu, __Kp_nu);
Index: testsuite/ext/special_functions/airy_ai/check_nan.cc
===
--- testsuite/ext/special_functions/airy_ai/check_nan.cc	(nonexistent)
+++ testsuite/ext/special

Re: Fix Bug 83566 - cyl_bessel_j returns wrong result for x>1000 for high orders

2018-01-01 Thread Ed Smith-Rowland

On 12/31/2017 09:38 PM, Michele Pezzutti wrote:

Hi.

This patch intends to fix Bug 83566 - cyl_bessel_j returns wrong 
result for x>1000 for high orders.
Seehttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=83566 forissue 
description.


    * libstdc++-v3/include/tr1/bessel_function.tcc
  Series expansion in __cyl_bessel_jn_asymp() shall not be 
truncated at the first terms.
  At least nu/2 terms shall be added, in order to have a 
guaranteed error bound.


    * 
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc

  Testcase for x > 1000 added.

    * 
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc

Testcase for x > 1000 added.


diff --git a/libstdc++-v3/include/tr1/bessel_function.tcc 
b/libstdc++-v3/include/tr1/bessel_function.tcc

index 7ac733d..852a31e 100644
--- a/libstdc++-v3/include/tr1/bessel_function.tcc
+++ b/libstdc++-v3/include/tr1/bessel_function.tcc
@@ -359,15 +359,32 @@ namespace tr1
 __cyl_bessel_jn_asymp(_Tp __nu, _Tp __x, _Tp & __Jnu, _Tp & __Nnu)
 {
   const _Tp __mu   = _Tp(4) * __nu * __nu;
-  const _Tp __mum1 = __mu - _Tp(1);
-  const _Tp __mum9 = __mu - _Tp(9);
-  const _Tp __mum25 = __mu - _Tp(25);
-  const _Tp __mum49 = __mu - _Tp(49);
-  const _Tp __xx = _Tp(64) * __x * __x;
-  const _Tp __P = _Tp(1) - __mum1 * __mum9 / (_Tp(2) * __xx)
-    * (_Tp(1) - __mum25 * __mum49 / (_Tp(12) * __xx));
-  const _Tp __Q = __mum1 / (_Tp(8) * __x)
-    * (_Tp(1) - __mum9 * __mum25 / (_Tp(6) * __xx));
+  const _Tp __8x = _Tp(8) * __x;
+
+  _Tp __P = _Tp(1);
+  _Tp __Q = _Tp(0);
+
+  _Tp __eps = std::numeric_limits<_Tp>::epsilon();
+
+  _Tp __term = _Tp(1);
+  _Tp __epsP = _Tp(0);
+  _Tp __epsQ = _Tp(0);
+
+  unsigned long __2k;
+  for (unsigned long k = 1; k < 1000; k+=2) {
+  __2k = 2 * k;
+
+  __term *= (__mu - _Tp((__2k - 1) * (__2k - 1))) / (k * __8x);
+  __Q += __term;
+  __epsQ = std::abs(__term) < std::abs(__eps * __Q);
+
+  __term *= -(__mu - _Tp((__2k + 1) * (__2k + 1)))/ (_Tp(k + 
1) * __8x);

+  __P += __term;
+  __epsP = std::abs(__term) < std::abs(__eps * __P);
+
+  if (__epsP && __epsQ && k > __nu / 2.)
+    break;
+  }

   const _Tp __chi = __x - (__nu + _Tp(0.5L))
 * __numeric_constants<_Tp>::__pi_2();


diff --git 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc 


index 26f4dd3..e340b78 100644
--- 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc
+++ 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc

@@ -698,6 +698,26 @@ data026[21] =
 };
 const double toler026 = 1.0006e-11;

+// Test data for nu=100.00.
+// max(|f - f_GSL|): 2.5857788132910287e-14
+// max(|f - f_GSL| / |f_GSL|): 1.6767662425535933e-11
+const testcase_cyl_bessel_j
+data027[11] =
+{
+  { 0.0116761350077845, 100., 1000. },
+  {-0.0116998547780258, 100., 1100. },
+  {-0.0228014834050837, 100., 1200. },
+  {-0.0169735007873739, 100., 1300. },
+  {-0.0014154528803530, 100., 1400. },
+  { 0.017265844988, 100., 1500. },
+  { 0.0198025620201474, 100., 1600. },
+  { 0.0161297712798388, 100., 1700. },
+  { 0.0053753369281577, 100., 1800. },
+  {-0.0069238868725646, 100., 1900. },
+  {-0.0154878717200738, 100., 2000. },
+};
+const double toler027 = 1.0006e-10;
+
 template
   void
   test(const testcase_cyl_bessel_j (&data)[Num], Ret toler)
@@ -748,5 +768,6 @@ main()
   test(data024, toler024);
   test(data025, toler025);
   test(data026, toler026);
+  test(data027, toler027);
   return 0;
 }


diff --git 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc 


index 5579149..9caf836 100644
--- 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc
+++ 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc

@@ -742,6 +742,26 @@ data028[20] =
 };
 const double toler028 = 1.0006e-11;

+// Test data for nu=100.00.
+// max(|f - f_GSL|): 3.1049815496508870e-14
+// max(|f - f_GSL| / |f_GSL|): 1.6767662425535933e

Re: Fix Bug 83566 - cyl_bessel_j returns wrong result for x>1000 for high orders

2018-01-01 Thread Ed Smith-Rowland

On 12/31/2017 09:38 PM, Michele Pezzutti wrote:

Hi.

This patch intends to fix Bug 83566 - cyl_bessel_j returns wrong 
result for x>1000 for high orders.
Seehttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=83566 forissue 
description.


    * libstdc++-v3/include/tr1/bessel_function.tcc
  Series expansion in __cyl_bessel_jn_asymp() shall not be 
truncated at the first terms.
  At least nu/2 terms shall be added, in order to have a 
guaranteed error bound.


    * 
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc

  Testcase for x > 1000 added.

    * 
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc

Testcase for x > 1000 added.


diff --git a/libstdc++-v3/include/tr1/bessel_function.tcc 
b/libstdc++-v3/include/tr1/bessel_function.tcc

index 7ac733d..852a31e 100644
--- a/libstdc++-v3/include/tr1/bessel_function.tcc
+++ b/libstdc++-v3/include/tr1/bessel_function.tcc
@@ -359,15 +359,32 @@ namespace tr1
 __cyl_bessel_jn_asymp(_Tp __nu, _Tp __x, _Tp & __Jnu, _Tp & __Nnu)
 {
   const _Tp __mu   = _Tp(4) * __nu * __nu;
-  const _Tp __mum1 = __mu - _Tp(1);
-  const _Tp __mum9 = __mu - _Tp(9);
-  const _Tp __mum25 = __mu - _Tp(25);
-  const _Tp __mum49 = __mu - _Tp(49);
-  const _Tp __xx = _Tp(64) * __x * __x;
-  const _Tp __P = _Tp(1) - __mum1 * __mum9 / (_Tp(2) * __xx)
-    * (_Tp(1) - __mum25 * __mum49 / (_Tp(12) * __xx));
-  const _Tp __Q = __mum1 / (_Tp(8) * __x)
-    * (_Tp(1) - __mum9 * __mum25 / (_Tp(6) * __xx));
+  const _Tp __8x = _Tp(8) * __x;
+
+  _Tp __P = _Tp(1);
+  _Tp __Q = _Tp(0);
+
+  _Tp __eps = std::numeric_limits<_Tp>::epsilon();
+
+  _Tp __term = _Tp(1);
+  _Tp __epsP = _Tp(0);
+  _Tp __epsQ = _Tp(0);
+
+  unsigned long __2k;
+  for (unsigned long k = 1; k < 1000; k+=2) {
+  __2k = 2 * k;
+
+  __term *= (__mu - _Tp((__2k - 1) * (__2k - 1))) / (k * __8x);
+  __Q += __term;
+  __epsQ = std::abs(__term) < std::abs(__eps * __Q);
+
+  __term *= -(__mu - _Tp((__2k + 1) * (__2k + 1)))/ (_Tp(k + 
1) * __8x);

+  __P += __term;
+  __epsP = std::abs(__term) < std::abs(__eps * __P);
+
+  if (__epsP && __epsQ && k > __nu / 2.)
+    break;
+  }

   const _Tp __chi = __x - (__nu + _Tp(0.5L))
 * __numeric_constants<_Tp>::__pi_2();


diff --git 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc 


index 26f4dd3..e340b78 100644
--- 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc
+++ 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc

@@ -698,6 +698,26 @@ data026[21] =
 };
 const double toler026 = 1.0006e-11;

+// Test data for nu=100.00.
+// max(|f - f_GSL|): 2.5857788132910287e-14
+// max(|f - f_GSL| / |f_GSL|): 1.6767662425535933e-11
+const testcase_cyl_bessel_j
+data027[11] =
+{
+  { 0.0116761350077845, 100., 1000. },
+  {-0.0116998547780258, 100., 1100. },
+  {-0.0228014834050837, 100., 1200. },
+  {-0.0169735007873739, 100., 1300. },
+  {-0.0014154528803530, 100., 1400. },
+  { 0.017265844988, 100., 1500. },
+  { 0.0198025620201474, 100., 1600. },
+  { 0.0161297712798388, 100., 1700. },
+  { 0.0053753369281577, 100., 1800. },
+  {-0.0069238868725646, 100., 1900. },
+  {-0.0154878717200738, 100., 2000. },
+};
+const double toler027 = 1.0006e-10;
+
 template
   void
   test(const testcase_cyl_bessel_j (&data)[Num], Ret toler)
@@ -748,5 +768,6 @@ main()
   test(data024, toler024);
   test(data025, toler025);
   test(data026, toler026);
+  test(data027, toler027);
   return 0;
 }


diff --git 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc 


index 5579149..9caf836 100644
--- 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc
+++ 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc

@@ -742,6 +742,26 @@ data028[20] =
 };
 const double toler028 = 1.0006e-11;

+// Test data for nu=100.00.
+// max(|f - f_GSL|): 3.1049815496508870e-14
+// max(|f - f_GSL| / |f_GSL|): 1.6767662425535933e

Re: Fix Bug 83566 - cyl_bessel_j returns wrong result for x>1000 for high orders

2018-01-02 Thread Ed Smith-Rowland

On 12/31/2017 09:38 PM, Michele Pezzutti wrote:

Hi.

This patch intends to fix Bug 83566 - cyl_bessel_j returns wrong 
result for x>1000 for high orders.
Seehttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=83566 forissue 
description.


    * libstdc++-v3/include/tr1/bessel_function.tcc
  Series expansion in __cyl_bessel_jn_asymp() shall not be 
truncated at the first terms.
  At least nu/2 terms shall be added, in order to have a 
guaranteed error bound.


    * 
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc

  Testcase for x > 1000 added.

    * 
libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc

Testcase for x > 1000 added.


diff --git a/libstdc++-v3/include/tr1/bessel_function.tcc 
b/libstdc++-v3/include/tr1/bessel_function.tcc

index 7ac733d..852a31e 100644
--- a/libstdc++-v3/include/tr1/bessel_function.tcc
+++ b/libstdc++-v3/include/tr1/bessel_function.tcc
@@ -359,15 +359,32 @@ namespace tr1
 __cyl_bessel_jn_asymp(_Tp __nu, _Tp __x, _Tp & __Jnu, _Tp & __Nnu)
 {
   const _Tp __mu   = _Tp(4) * __nu * __nu;
-  const _Tp __mum1 = __mu - _Tp(1);
-  const _Tp __mum9 = __mu - _Tp(9);
-  const _Tp __mum25 = __mu - _Tp(25);
-  const _Tp __mum49 = __mu - _Tp(49);
-  const _Tp __xx = _Tp(64) * __x * __x;
-  const _Tp __P = _Tp(1) - __mum1 * __mum9 / (_Tp(2) * __xx)
-    * (_Tp(1) - __mum25 * __mum49 / (_Tp(12) * __xx));
-  const _Tp __Q = __mum1 / (_Tp(8) * __x)
-    * (_Tp(1) - __mum9 * __mum25 / (_Tp(6) * __xx));
+  const _Tp __8x = _Tp(8) * __x;
+
+  _Tp __P = _Tp(1);
+  _Tp __Q = _Tp(0);
+
+  _Tp __eps = std::numeric_limits<_Tp>::epsilon();
+
+  _Tp __term = _Tp(1);
+  _Tp __epsP = _Tp(0);
+  _Tp __epsQ = _Tp(0);
+
+  unsigned long __2k;
+  for (unsigned long k = 1; k < 1000; k+=2) {
+  __2k = 2 * k;
+
+  __term *= (__mu - _Tp((__2k - 1) * (__2k - 1))) / (k * __8x);
+  __Q += __term;
+  __epsQ = std::abs(__term) < std::abs(__eps * __Q);
+
+  __term *= -(__mu - _Tp((__2k + 1) * (__2k + 1)))/ (_Tp(k + 
1) * __8x);

+  __P += __term;
+  __epsP = std::abs(__term) < std::abs(__eps * __P);
+
+  if (__epsP && __epsQ && k > __nu / 2.)
+    break;
+  }

   const _Tp __chi = __x - (__nu + _Tp(0.5L))
 * __numeric_constants<_Tp>::__pi_2();


diff --git 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc 


index 26f4dd3..e340b78 100644
--- 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc
+++ 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc

@@ -698,6 +698,26 @@ data026[21] =
 };
 const double toler026 = 1.0006e-11;

+// Test data for nu=100.00.
+// max(|f - f_GSL|): 2.5857788132910287e-14
+// max(|f - f_GSL| / |f_GSL|): 1.6767662425535933e-11
+const testcase_cyl_bessel_j
+data027[11] =
+{
+  { 0.0116761350077845, 100., 1000. },
+  {-0.0116998547780258, 100., 1100. },
+  {-0.0228014834050837, 100., 1200. },
+  {-0.0169735007873739, 100., 1300. },
+  {-0.0014154528803530, 100., 1400. },
+  { 0.017265844988, 100., 1500. },
+  { 0.0198025620201474, 100., 1600. },
+  { 0.0161297712798388, 100., 1700. },
+  { 0.0053753369281577, 100., 1800. },
+  {-0.0069238868725646, 100., 1900. },
+  {-0.0154878717200738, 100., 2000. },
+};
+const double toler027 = 1.0006e-10;
+
 template
   void
   test(const testcase_cyl_bessel_j (&data)[Num], Ret toler)
@@ -748,5 +768,6 @@ main()
   test(data024, toler024);
   test(data025, toler025);
   test(data026, toler026);
+  test(data027, toler027);
   return 0;
 }


diff --git 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc 


index 5579149..9caf836 100644
--- 
a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc
+++ 
b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc

@@ -742,6 +742,26 @@ data028[20] =
 };
 const double toler028 = 1.0006e-11;

+// Test data for nu=100.00.
+// max(|f - f_GSL|): 3.1049815496508870e-14
+// max(|f - f_GSL| / |f_GSL|): 1.6767662425535933e

Re: Fix Bug 83566 - cyl_bessel_j returns wrong result for x>1000 for high orders

2018-01-02 Thread Ed Smith-Rowland

On 01/02/2018 04:41 PM, Michele Pezzutti wrote:

On 01/02/2018 05:59 PM, Ed Smith-Rowland wrote:

OK,

on *third* look summing up to k = nu/2 at minimum will a achieve the 
result of not blowing up the asymptotic series:


nu^2 - (2k-1)^2.  And it will do that without a check.

This stopping criterion should work even near x=nu which would be the 
most difficult case.  The sum could go further for larger x but let's 
just go with your termination criterion for now. Later, with some 
experimentation, we could sum up to nu/2 at a minimum *then* snoop 
forward until the terms start drifting up. Or we could just solve 
k_max for this case as a function of x. Also, we may never need these 
extras.
For what I could see, 'term' stops to contributing to P, Q few steps 
before k = nu /2.



Right.  I can see these terms rising, sometimes quite high, then falling.
In many experiments, the sums converge before the terms blow up.

In my old impl, I gave up too easily.
Perhaps, in general, one could wait until the terms started decreasing, 
*then* if subsequent terms start growing again exit loop.

But it seems I never get to that point before sum convergence.

On the good side it seems that if x >= 20 nu then you can go quite high 
in nu.


nu =    1000
x  =   2
Jnu  = 0.00540683536187055
Nnu  =    -0.00162387432151849
Jnua = 0.00540683536187055
Nnua =    -0.00162387432151849
Jnua - Jnu =   0
Nnua - Nnu =   0
Jpnu  = 0.00162170521572447
Npnu  =  0.0054001182451475
Jpnua = 0.00162170521572447
Npnua =  0.0054001182451475
Jpnua - Jpnu =   0
Npnua - Npnu =   0
pi x Wronski / 2 =    1.0022382762



Re: Fix Bug 83566 - cyl_bessel_j returns wrong result for x>1000 for high orders

2018-01-04 Thread Ed Smith-Rowland

On 01/03/2018 02:49 PM, Michele Pezzutti wrote:


Hi.

On 01/02/2018 05:43 PM, Michele Pezzutti wrote:


On 01/02/2018 02:28 AM, Ed Smith-Rowland wrote:

I like the patch.

I have a similar one in the tr29124 branch.

Anyway, I got held up and I think it's good to have new folks 
looking into this.


It looks good except that you need to uglify k.


I looked at the GSL implementation, based on same reference, and 
their loop is cleaner. What about porting that implementation here? 
Possible?


My implementation is also using one more term for P than for Q, which 
is discouraged in GSL, according to their comments.


Ed, do you have any comment about this point?
Regarding the 2nd line, after my observations, usually term stops 
contributing to P, Q before k > nu/2, so actually, an offset by one is 
most likely without consequences.

GSL implementation is nevertheless more elegant.


I've seen their implementation.  It's tight.  Feel free to port it.
I assume this is it:
int
gsl_sf_bessel_Jnu_asympx_e(const double nu, const double x, 
gsl_sf_result * result);


You do want to give Q or b one more term so as to make that last factor 
as small as possible.  They're right.


In principal, these ideas should be ported to I,K but I think (and IIRC 
GSL agrees) these under,over-flow before they have much effect.

I think I put the full series in there.  They could use a similar clean-up.

But let's get this in there first.

Ed




Re: Fix Bug 83566 - cyl_bessel_j returns wrong result for x>1000 for high orders

2018-01-05 Thread Ed Smith-Rowland

On 01/04/2018 03:54 PM, Michele Pezzutti wrote:



On 01/04/2018 06:16 PM, Ed Smith-Rowland wrote:

On 01/03/2018 02:49 PM, Michele Pezzutti wrote:


Hi.

On 01/02/2018 05:43 PM, Michele Pezzutti wrote:


On 01/02/2018 02:28 AM, Ed Smith-Rowland wrote:

I like the patch.

I have a similar one in the tr29124 branch.

Anyway, I got held up and I think it's good to have new folks 
looking into this.


It looks good except that you need to uglify k.


I looked at the GSL implementation, based on same reference, and 
their loop is cleaner. What about porting that implementation here? 
Possible?


My implementation is also using one more term for P than for Q, 
which is discouraged in GSL, according to their comments.


Ed, do you have any comment about this point?
Regarding the 2nd line, after my observations, usually term stops 
contributing to P, Q before k > nu/2, so actually, an offset by one 
is most likely without consequences.

GSL implementation is nevertheless more elegant.


I've seen their implementation.  It's tight.  Feel free to port it.
I assume this is it:
int
gsl_sf_bessel_Jnu_asympx_e(const double nu, const double x, 
gsl_sf_result * result);


You do want to give Q or b one more term so as to make that last 
factor as small as possible.  They're right.




Here it is.

diff --git a/libstdc++-v3/include/tr1/bessel_function.tcc 
b/libstdc++-v3/include/tr1/bessel_function.tcc

index 7ac733d..7842350 100644
--- a/libstdc++-v3/include/tr1/bessel_function.tcc
+++ b/libstdc++-v3/include/tr1/bessel_function.tcc
@@ -353,21 +353,47 @@ namespace tr1
  *   @param  __x   The argument of the Bessel functions.
  *   @param  __Jnu  The output Bessel function of the first kind.
  *   @param  __Nnu  The output Neumann function (Bessel function 
of the second kind).

+ *
+ *  Adapted for libstdc++ from GNU GSL version 2.4 
specfunc/bessel_j.c
+ *  Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003 Gerard 
Jungman

  */
 template 
 void
 __cyl_bessel_jn_asymp(_Tp __nu, _Tp __x, _Tp & __Jnu, _Tp & __Nnu)
 {
   const _Tp __mu   = _Tp(4) * __nu * __nu;
-  const _Tp __mum1 = __mu - _Tp(1);
-  const _Tp __mum9 = __mu - _Tp(9);
-  const _Tp __mum25 = __mu - _Tp(25);
-  const _Tp __mum49 = __mu - _Tp(49);
-  const _Tp __xx = _Tp(64) * __x * __x;
-  const _Tp __P = _Tp(1) - __mum1 * __mum9 / (_Tp(2) * __xx)
-    * (_Tp(1) - __mum25 * __mum49 / (_Tp(12) * __xx));
-  const _Tp __Q = __mum1 / (_Tp(8) * __x)
-    * (_Tp(1) - __mum9 * __mum25 / (_Tp(6) * __xx));
+  const _Tp __8x = _Tp(8) * __x;
+
+  _Tp __P = _Tp(0);
+  _Tp __Q = _Tp(0);
+
+  _Tp k = _Tp(0);
+  _Tp __term = _Tp(1);
+
+  int __epsP = 0;
+  int __epsQ = 0;
+
+  _Tp __eps = std::numeric_limits<_Tp>::epsilon();
+
+  do
+    {
+  __term *= (k == 0) ? _Tp(1) : -(__mu - (2 * k - 1) * (2 * k 
- 1)) / (k * __8x);

+  __epsP = std::abs(__term) < std::abs(__eps * __P);
+  __P += __term;
+
+  k++;
+
+  __term *= (__mu - (2 * k - 1) * (2 * k - 1)) / (k * __8x);
+  __epsQ = std::abs(__term) < std::abs(__eps * __Q);
+  __Q += __term;
+
+  if (__epsP && __epsQ && k > __nu / 2.)
+    break;
+
+  k++;
+    }
+  while (k < 1000);
+

   const _Tp __chi = __x - (__nu + _Tp(0.5L))
 * __numeric_constants<_Tp>::__pi_2();



In principal, these ideas should be ported to I,K but I think (and 
IIRC GSL agrees) these under,over-flow before they have much effect.
I think I put the full series in there.  They could use a similar 
clean-up.


But let's get this in there first.

Ed





This looks good to me.  The only nit is that you have to uglify the k 
loop variable.


(I hope we can un-uglify our variables when modules come!)

Do you have copyright assignment in place and all that?

Ed





Re: RFC: What should go in our header?

2018-06-17 Thread Ed Smith-Rowland

On 06/15/2018 11:52 AM, Jonathan Wakely wrote:

C++20 adds a  header, which should define all the library
feature test macros, as well as implementation-specific macros like
_GLIBCXX_RELEASE and __GLIBCXX__.

We should decide whether to implement  by simply including
 and then adding the feature test macros, or if we
should keep it minimal and *only* define _GLIBCXX_RELEASE and
__GLIBCXX__ and the feature tests (and then have 
include ?)

I think I prefer to make  just include .

I think we should define the feature-test macros in both  and
the relevant header (e.g. __cpp_string_view in ). We
could make everything include  and then every header would
define every feature test macro, but I don't think that's good for
portability.

My preference is implemented by the attached patch.


This is pretty much what I was looking at doing.  I say go!


While on the subject, should we just delete some of this autoconf-junk
from our c++config.h headers?

/* Name of package */
/* #undef _GLIBCXX_PACKAGE */

/* Define to the address where bug reports for this package should be 
sent. */

#define _GLIBCXX_PACKAGE_BUGREPORT ""

/* Define to the full name of this package. */
#define _GLIBCXX_PACKAGE_NAME "package-unused"

/* Define to the full name and version of this package. */
#define _GLIBCXX_PACKAGE_STRING "package-unused version-unused"

/* Define to the one symbol short name of this package. */
#define _GLIBCXX_PACKAGE_TARNAME "libstdc++"

/* Define to the home page for this package. */
#define _GLIBCXX_PACKAGE_URL ""

/* Define to the version of this package. */
#define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused"

I don't have an opinion here except if this is unused cruft let's lose 
it.  I think we *are* supposed to have some project and version 
identification.  We have _GLIBCXX_* everywhere.  The folks that use 
libstdc++ *outside* of g++ might have some opinions about this too.


Ed




[libstdc++; pr66689; pr68397] Backport special function fixes to 7.

2018-04-26 Thread Ed Smith-Rowland
I'm thinking of going back on my choice not to fix special function bugs 
on 7.


These build and test clean on gcc-7.

OK?


2018-04-30  Edward Smith-Rowland  <3dw...@verizon.net>

PR libstdc++/pr66689 - comp_ellint_3 and ellint_3 return garbage values
* include/tr1/ell_integral.tcc: Correct the nu sign convention
in ellint_3 and comp_ellint_3.
* testsuite/tr1/5_numerical_facilities/special_functions/
06_comp_ellint_3/check_value.cc: Regen with correct values.
* testsuite/tr1/5_numerical_facilities/special_functions/
14_ellint_3/check_value.cc: Ditto.
* testsuite/special_functions/06_comp_ellint_3/check_value.cc: Ditto.
* testsuite/special_functions/13_ellint_3/check_value.cc: Ditto.
* testsuite/special_functions/06_comp_ellint_3/pr66689.cc: New.
* testsuite/special_functions/13_ellint_3/pr66689.cc: New.
* testsuite/tr1/5_numerical_facilities/special_functions/
06_comp_ellint_3/pr66689.cc: New.
* testsuite/tr1/5_numerical_facilities/special_functions/
14_ellint_3/pr66689.cc: New.
Index: include/tr1/ell_integral.tcc
===
--- include/tr1/ell_integral.tcc(revision 259666)
+++ include/tr1/ell_integral.tcc(working copy)
@@ -685,8 +685,8 @@
   const _Tp __kk = __k * __k;
 
   return __ellint_rf(_Tp(0), _Tp(1) - __kk, _Tp(1))
-   - __nu
-   * __ellint_rj(_Tp(0), _Tp(1) - __kk, _Tp(1), _Tp(1) + __nu)
+   + __nu
+   * __ellint_rj(_Tp(0), _Tp(1) - __kk, _Tp(1), _Tp(1) - __nu)
/ _Tp(3);
 }
 }
@@ -735,9 +735,9 @@
 
   const _Tp __Pi = __s
  * __ellint_rf(__cc, _Tp(1) - __kk * __ss, _Tp(1))
- - __nu * __sss
+ + __nu * __sss
  * __ellint_rj(__cc, _Tp(1) - __kk * __ss, _Tp(1),
-   _Tp(1) + __nu * __ss) / _Tp(3);
+   _Tp(1) - __nu * __ss) / _Tp(3);
 
   if (__n == 0)
 return __Pi;
Index: testsuite/special_functions/06_comp_ellint_3/pr66689.cc
===
--- testsuite/special_functions/06_comp_ellint_3/pr66689.cc (nonexistent)
+++ testsuite/special_functions/06_comp_ellint_3/pr66689.cc (working copy)
@@ -0,0 +1,24 @@
+// { dg-do run { target c++11 } }
+// { dg-require-c-std "" }
+// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
+// { dg-add-options ieee }
+
+#include 
+#include 
+
+void
+test01()
+{
+  double Pi1 = std::comp_ellint_3(0.75, 0.0);
+  VERIFY(std::abs(Pi1 - 1.91099) < 0.1);
+
+  double Pi2 = std::comp_ellint_3(0.75, 0.5);
+  VERIFY(std::abs(Pi2 - 2.80011) < 0.1);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
Index: testsuite/special_functions/13_ellint_3/pr66689.cc
===
--- testsuite/special_functions/13_ellint_3/pr66689.cc  (nonexistent)
+++ testsuite/special_functions/13_ellint_3/pr66689.cc  (working copy)
@@ -0,0 +1,26 @@
+// { dg-do run { target c++11 } }
+// { dg-require-c-std "" }
+// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
+// { dg-add-options ieee }
+
+#include 
+#include 
+
+void
+test01()
+{
+  const double pi = 3.141592654;
+
+  double Pi1 = std::ellint_3(0.75, 0.0, pi / 2.0);
+  VERIFY(std::abs(Pi1 - 1.91099) < 0.1);
+
+  double Pi2 = std::ellint_3(0.75, 0.5, pi / 2.0);
+  VERIFY(std::abs(Pi2 - 2.80011) < 0.1);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
Index: 
testsuite/tr1/5_numerical_facilities/special_functions/06_comp_ellint_3/pr66689.cc
===
--- 
testsuite/tr1/5_numerical_facilities/special_functions/06_comp_ellint_3/pr66689.cc
  (nonexistent)
+++ 
testsuite/tr1/5_numerical_facilities/special_functions/06_comp_ellint_3/pr66689.cc
  (working copy)
@@ -0,0 +1,20 @@
+
+#include 
+#include 
+
+void
+test01()
+{
+  double Pi1 = std::tr1::comp_ellint_3(0.75, 0.0);
+  VERIFY(std::abs(Pi1 - 1.91099) < 0.1);
+
+  double Pi2 = std::tr1::comp_ellint_3(0.75, 0.5);
+  VERIFY(std::abs(Pi2 - 2.80011) < 0.1);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
Index: 
testsuite/tr1/5_numerical_facilities/special_functions/14_ellint_3/pr66689.cc
===
--- 
testsuite/tr1/5_numerical_facilities/special_functions/14_ellint_3/pr66689.cc   
(nonexistent)
+++ 
testsuite/tr1/5_numerical_facilities/special_functions/14_ellint_3/pr66689.cc   
(working copy)
@@ -0,0 +1,22 @@
+
+#include 
+#include 
+
+void
+test01()
+{
+  const double pi = 3.141592654;
+
+  double Pi1 = std::tr1::ellint_3(0.75, 0.0, pi / 2.0);
+  VERIFY(std::abs(Pi1 - 1.91099) < 0.1);
+
+  double Pi2 = std::tr1::ellint_3(0.75, 0.5, pi / 2.0);
+  VERIFY(std::abs(Pi2 

Re: [PATCH] PR libstdc++/80506 fix constant used in condition

2018-05-05 Thread Ed Smith-Rowland

On 04/26/2017 05:16 AM, Jonathan Wakely wrote:

On 26/04/17 11:14 +0200, Paolo Carlini wrote:

.. or maybe using the wrong constant only impacts the performance?!?


Yes, I think so. I did some very simple sanity tests and the numbers
were identical before and after.




I was backporting this and saw that __generate_impl does this twice more.

For trunk and branch-8 I have these patches.

OK?



2018-05-07  Edward Smith-Rowland  <3dw...@verizon.net>

Moar PR libstdc++/80506
* include/bits/random.tcc (gamma_distribution::__generate_impl()):
Fix magic number used in loop condition.
Index: include/bits/random.tcc
===
--- include/bits/random.tcc (revision 259965)
+++ include/bits/random.tcc (working copy)
@@ -2408,7 +2408,7 @@
  __v = __v * __v * __v;
  __u = __aurng();
}
- while (__u > result_type(1.0) - 0.331 * __n * __n * __n * __n
+ while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n
 && (std::log(__u) > (0.5 * __n * __n + __a1
  * (1.0 - __v + std::log(__v);
 
@@ -2429,7 +2429,7 @@
  __v = __v * __v * __v;
  __u = __aurng();
}
- while (__u > result_type(1.0) - 0.331 * __n * __n * __n * __n
+ while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n
 && (std::log(__u) > (0.5 * __n * __n + __a1
  * (1.0 - __v + std::log(__v);
 


Re: Fix Bug 83566 - cyl_bessel_j returns wrong result for x>1000 for high orders

2018-05-05 Thread Ed Smith-Rowland

On 01/08/2018 02:08 PM, Michele Pezzutti wrote:

Formatting fixed.

diff --git a/libstdc++-v3/include/tr1/bessel_function.tcc 
b/libstdc++-v3/include/tr1/bessel_function.tcc

index 7ac733d..5f8fc9f 100644
--- a/libstdc++-v3/include/tr1/bessel_function.tcc
+++ b/libstdc++-v3/include/tr1/bessel_function.tcc
@@ -27,6 +27,10 @@
  *  Do not attempt to use it directly. @headername{tr1/cmath}
  */

+/* __cyl_bessel_jn_asymp adapted from GNU GSL version 2.4 
specfunc/bessel_j.c

+ * Copyright (C) 1996-2003 Gerard Jungman
+ */
+
 //
 // ISO C++ 14882 TR1: 5.2  Special functions
 //
@@ -358,16 +362,42 @@ namespace tr1
 void
 __cyl_bessel_jn_asymp(_Tp __nu, _Tp __x, _Tp & __Jnu, _Tp & __Nnu)
 {
-  const _Tp __mu   = _Tp(4) * __nu * __nu;
-  const _Tp __mum1 = __mu - _Tp(1);
-  const _Tp __mum9 = __mu - _Tp(9);
-  const _Tp __mum25 = __mu - _Tp(25);
-  const _Tp __mum49 = __mu - _Tp(49);
-  const _Tp __xx = _Tp(64) * __x * __x;
-  const _Tp __P = _Tp(1) - __mum1 * __mum9 / (_Tp(2) * __xx)
-    * (_Tp(1) - __mum25 * __mum49 / (_Tp(12) * __xx));
-  const _Tp __Q = __mum1 / (_Tp(8) * __x)
-    * (_Tp(1) - __mum9 * __mum25 / (_Tp(6) * __xx));
+  const _Tp __mu = _Tp(4) * __nu * __nu;
+  const _Tp __8x = _Tp(8) * __x;
+
+  _Tp __P = _Tp(0);
+  _Tp __Q = _Tp(0);
+
+  _Tp __k = _Tp(0);
+  _Tp __term = _Tp(1);
+
+  int __epsP = 0;
+  int __epsQ = 0;
+
+  _Tp __eps = std::numeric_limits<_Tp>::epsilon();
+
+  do
+    {
+  __term *= (__k == 0
+ ? _Tp(1)
+ : -(__mu - (2 * __k - 1) * (2 * __k - 1)) / (__k 
* __8x));

+
+  __epsP = std::abs(__term) < std::abs(__eps * __P);
+  __P += __term;
+
+  __k++;
+
+  __term *= (__mu - (2 * __k - 1) * (2 * __k - 1)) / (__k * 
__8x);

+  __epsQ = std::abs(__term) < std::abs(__eps * __Q);
+  __Q += __term;
+
+  if (__epsP && __epsQ && __k > __nu / 2.)
+    break;
+
+  __k++;
+    }
+  while (__k < 1000);
+

   const _Tp __chi = __x - (__nu + _Tp(0.5L))
 * __numeric_constants<_Tp>::__pi_2();

On 01/06/2018 10:23 AM, Paolo Carlini wrote:

Hi,

On 05/01/2018 23:46, Michele Pezzutti wrote:
+ __term *= (__k == 0) ? _Tp(1) : -(__mu - (2 * __k - 1) * (2 * __k 
- 1))

+    / (__k * __8x);
In such cases, per the Coding Standards, you want an outer level of 
parentheses wrapping the whole right side expression. See toward the 
end of 
https://www.gnu.org/prep/standards/html_node/Formatting.html#Formatting. 
I see that many other places will need fixing, at some point - this 
rather straightforward rule is often overlooked leading to brittle 
formatting of many expressions, probably because it's really obvious 
in practice only together with Emacs, I'm not sure.


Also - this kind of stylistic nitpicking is partially personal taste 
- the parentheses around (__k == 0) seem definitely redundant to me, 
and I don't think you would find many examples of that in our code.


About the Assignement, please be patient. For example, used to be the 
case that when RMS was traveling couldn't process Assignments, for 
example. It can be slow for many reasons, it's 100% normal.


Paolo..






Hi all,

I'd like us to get this in.

Michele, how is the Copyright assignment going?

I'd like to push it down through brach/gcc-6 also.

Ed




Re: Fix Bug 83566 - cyl_bessel_j returns wrong result for x>1000 for high orders

2018-05-06 Thread Ed Smith-Rowland

Michele,

So I think the patch you had plus tests
testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc
testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc
plus I'd like the new tests also in
  testsuite/special_functions/08_cyl_bessel_j/check_value.cc
  testsuite/special_functions/10_cyl_neumann/check_value.cc
for C++17.

Put that up with a Changelog and see if we're all good.

Thank you for going through this and other math issues.

Ed



[libstdc++, PATCH] PR libstdc++/83140 - assoc_legendre returns negated value when m is odd.

2018-05-07 Thread Ed Smith-Rowland

All,

We were using a different convention for P_l^m assoc_legendre(int l, int 
m, FloatTp x)


 - the so-called Condon-Shortley convention which includes (-1)^m.  
This unfortunately is common.


This factor is taken out to match the standard.  The underlying __detail 
code has an arg that allows you to flip this


- mostly to highlight the subtle difference.

The related sph_legendre is unaffected by this (our impl and the 
standard include the C-S phase).


OK for trunk and branches?

Ed



2018-05-07  Edward Smith-Rowland  <3dw...@verizon.net>

PR libstdc++/83140 - assoc_legendre returns negated value when m is odd
* include/tr1/legendre_function.tcc (__assoc_legendre_p): Add __phase
argument defaulted to +1.  Doxy comments on same.
* testsuite/special_functions/02_assoc_legendre/
check_assoc_legendre.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
02_assoc_legendre/check_tr1_assoc_legendre.cc: Regen.

Index: include/tr1/legendre_function.tcc
===
--- include/tr1/legendre_function.tcc   (revision 259973)
+++ include/tr1/legendre_function.tcc   (working copy)
@@ -65,7 +65,7 @@
   namespace __detail
   {
 /**
- *   @brief  Return the Legendre polynomial by recursion on order
+ *   @brief  Return the Legendre polynomial by recursion on degree
  *   @f$ l @f$.
  * 
  *   The Legendre function of @f$ l @f$ and @f$ x @f$,
@@ -74,7 +74,7 @@
  * P_l(x) = \frac{1}{2^l l!}\frac{d^l}{dx^l}(x^2 - 1)^{l}
  *   @f]
  * 
- *   @param  l  The order of the Legendre polynomial.  @f$l >= 0@f$.
+ *   @param  l  The degree of the Legendre polynomial.  @f$l >= 0@f$.
  *   @param  x  The argument of the Legendre polynomial.  @f$|x| <= 1@f$.
  */
 template
@@ -127,16 +127,19 @@
  * P_l^m(x) = (1 - x^2)^{m/2}\frac{d^m}{dx^m}P_l(x)
  *   @f]
  * 
- *   @param  l  The order of the associated Legendre function.
+ *   @param  l  The degree of the associated Legendre function.
  *  @f$ l >= 0 @f$.
  *   @param  m  The order of the associated Legendre function.
  *  @f$ m <= l @f$.
  *   @param  x  The argument of the associated Legendre function.
  *  @f$ |x| <= 1 @f$.
+ *   @param  phase  The phase of the associated Legendre function.
+ *  Use -1 for the Condon-Shortley phase convention.
  */
 template
 _Tp
-__assoc_legendre_p(unsigned int __l, unsigned int __m, _Tp __x)
+__assoc_legendre_p(unsigned int __l, unsigned int __m, _Tp __x,
+  _Tp __phase = _Tp{+1})
 {
 
   if (__x < _Tp(-1) || __x > _Tp(+1))
@@ -160,7 +163,7 @@
   _Tp __fact = _Tp(1);
   for (unsigned int __i = 1; __i <= __m; ++__i)
 {
-  __p_mm *= -__fact * __root;
+  __p_mm *= __phase * __fact * __root;
   __fact += _Tp(2);
 }
 }
@@ -205,8 +208,10 @@
  *   but this factor is rather large for large @f$ l @f$ and @f$ m @f$
  *   and so this function is stable for larger differences of @f$ l @f$
  *   and @f$ m @f$.
+ *   @note Unlike the case for __assoc_legendre_p the Condon-Shortley
+ *   phase factor @f$ (-1)^m @f$ is present here.
  * 
- *   @param  l  The order of the spherical associated Legendre function.
+ *   @param  l  The degree of the spherical associated Legendre function.
  *  @f$ l >= 0 @f$.
  *   @param  m  The order of the spherical associated Legendre function.
  *  @f$ m <= l @f$.
@@ -265,19 +270,15 @@
   const _Tp __lnpre_val =
 -_Tp(0.25L) * __numeric_constants<_Tp>::__lnpi()
 + _Tp(0.5L) * (__lnpoch + __m * __lncirc);
-  _Tp __sr = std::sqrt((_Tp(2) + _Tp(1) / __m)
-   / (_Tp(4) * __numeric_constants<_Tp>::__pi()));
+  const _Tp __sr = std::sqrt((_Tp(2) + _Tp(1) / __m)
+ / (_Tp(4) * __numeric_constants<_Tp>::__pi()));
   _Tp __y_mm = __sgn * __sr * std::exp(__lnpre_val);
   _Tp __y_mp1m = __y_mp1m_factor * __y_mm;
 
   if (__l == __m)
-{
-  return __y_mm;
-}
+return __y_mm;
   else if (__l == __m + 1)
-{
-  return __y_mp1m;
-}
+return __y_mp1m;
   else
 {
   _Tp __y_lm = _Tp(0);
Index: testsuite/special_functions/02_assoc_legendre/check_value.cc
===
--- testsuite/special_functions/02_assoc_legendre/check_value.cc
(revision 259973)
+++ testsuite/special_functions/02_assoc_legendre/check_value.cc
(working copy)
@@ -1,6 +1,6 @@
 // { dg-do run { target c++11 } }
-// { dg-options

Re: [libstdc++, PATCH] PR libstdc++/83140 - assoc_legendre returns negated value when m is odd.

2018-05-10 Thread Ed Smith-Rowland

On 05/09/2018 05:30 AM, Jonathan Wakely wrote:

On 07/05/18 12:39 -0400, Ed Smith-Rowland wrote:

All,

We were using a different convention for P_l^m assoc_legendre(int l, 
int m, FloatTp x)


 - the so-called Condon-Shortley convention which includes (-1)^m.  
This unfortunately is common.


This factor is taken out to match the standard.  The underlying 
__detail code has an arg that allows you to flip this


- mostly to highlight the subtle difference.

The related sph_legendre is unaffected by this (our impl and the 
standard include the C-S phase).


OK for trunk and branches?

Ed






2018-05-07  Edward Smith-Rowland  <3dw...@verizon.net>

PR libstdc++/83140 - assoc_legendre returns negated value when m 
is odd
* include/tr1/legendre_function.tcc (__assoc_legendre_p): Add 
__phase

argument defaulted to +1.  Doxy comments on same.
* testsuite/special_functions/02_assoc_legendre/
check_assoc_legendre.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
02_assoc_legendre/check_tr1_assoc_legendre.cc: Regen.




Index: include/tr1/legendre_function.tcc
===
--- include/tr1/legendre_function.tcc    (revision 259973)
+++ include/tr1/legendre_function.tcc    (working copy)
@@ -65,7 +65,7 @@
  namespace __detail
  {
    /**
- *   @brief  Return the Legendre polynomial by recursion on order
+ *   @brief  Return the Legendre polynomial by recursion on degree
 *   @f$ l @f$.
 *
 *   The Legendre function of @f$ l @f$ and @f$ x @f$,
@@ -74,7 +74,7 @@
 * P_l(x) = \frac{1}{2^l l!}\frac{d^l}{dx^l}(x^2 - 1)^{l}
 *   @f]
 *
- *   @param  l  The order of the Legendre polynomial.  @f$l >= 
0@f$.
+ *   @param  l  The degree of the Legendre polynomial. @f$l >= 
0@f$.
 *   @param  x  The argument of the Legendre polynomial. @f$|x| 
<= 1@f$.

 */
    template
@@ -127,16 +127,19 @@
 * P_l^m(x) = (1 - x^2)^{m/2}\frac{d^m}{dx^m}P_l(x)
 *   @f]
 *
- *   @param  l  The order of the associated Legendre function.
+ *   @param  l  The degree of the associated Legendre function.
 *  @f$ l >= 0 @f$.
 *   @param  m  The order of the associated Legendre function.
 *  @f$ m <= l @f$.
 *   @param  x  The argument of the associated Legendre function.
 *  @f$ |x| <= 1 @f$.
+ *   @param  phase  The phase of the associated Legendre function.
+ *  Use -1 for the Condon-Shortley phase 
convention.

 */
    template
    _Tp
-    __assoc_legendre_p(unsigned int __l, unsigned int __m, _Tp __x)
+    __assoc_legendre_p(unsigned int __l, unsigned int __m, _Tp __x,
+   _Tp __phase = _Tp{+1})


This list-init isn't valid for C++98 i.e. when used via .
GCC seems to allow it, but Clang won't.

We could consider dropping the TR1 support, and just provide these
functions for ISO/IEC 29124:2010 in C++11 (or later) and for C++17.
But that decision should be taken separately, and should only happen
on trunk anyway so we need to use _Tp(+1) here.

OK for trunk with _Tp(+1) instead of _Tp{+1}.

Do we want to change the result of these functions on the branches?
How likely is it that changing it will affect somebody's calcuations
in a way that they don't expect from a minor release on a branch?




Here are the files applied for 260115.

As to backporting...  I did a Google and found rather more activity 
around these functions - especially legendre - than I remembered last 
time I searched.  I thought these functions were languishing, but 
apparently not.  Still low pings on ellint_3.


I *would* like to change branch 8 because it's just out.

I think I should curb my enthusiasm for branches 7 and 6.

Ed.



2018-05-10  Edward Smith-Rowland  <3dw...@verizon.net>

PR libstdc++/83140 - assoc_legendre returns negated value when m is odd
* include/tr1/legendre_function.tcc (__assoc_legendre_p): Add __phase
argument defaulted to +1.  Doxy comments on same.
* testsuite/special_functions/02_assoc_legendre/
check_assoc_legendre.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
02_assoc_legendre/check_tr1_assoc_legendre.cc: Regen.

Index: include/tr1/legendre_function.tcc
===
--- include/tr1/legendre_function.tcc   (revision 260114)
+++ include/tr1/legendre_function.tcc   (working copy)
@@ -65,7 +65,7 @@
   namespace __detail
   {
 /**
- *   @brief  Return the Legendre polynomial by recursion on order
+ *   @brief  Return the Legendre polynomial by recursion on degree
  *   @f$ l @f$.
  * 
  *   The Legendre function of @f$ l @f$ and @f$ x @f$,
@@ -74,7 +74,7 @@
  * P_l(x) = \frac{1}{2^l l!}\frac{d^l}{dx^l}(x^2 - 1)^{l}
  *   @f]
  * 
- *  

Quo Vadis tr1? Was: [libstdc++, PATCH] PR libstdc++/83140 - assoc_legendre returns negated value when m is odd.

2018-05-10 Thread Ed Smith-Rowland

All,


We could consider dropping the TR1 support, and just provide these
functions for ISO/IEC 29124:2010 in C++11 (or later) and for C++17.
But that decision should be taken separately, and should only happen
on trunk anyway so we need to use _Tp(+1) here.


I am in favour of splitting new versions of the special functions out of 
tr1 and into std/bits.

I personally am itching to use at least C++11 for implementation.
We have been defaulting to C++11 for, IIRC, two releases (Hence my 
-Tp{+1} slip LOL).

I have a lot of work towards this that I wanted to get into 9 anyway.

This would end the last useful thing in tr1 that's not better 
implemented elsewhere. There are certainly people using tr1. Can we 
deprecate the whole namespace?  That might be too noisy.  I think we 
should be done with maths bugs in Bugzilla pretty soon.  We should do 
whatever we decide relatively early in 9.


Ed

Also, I think 83566 should go into tr1 first because it's not a 
signature change.




Re: [libstdc++, PATCH] PR libstdc++/83140 - assoc_legendre returns negated value when m is odd.

2018-05-10 Thread Ed Smith-Rowland

On 05/10/2018 01:44 PM, Rainer Orth wrote:

Hi Ed,


2018-05-07  Edward Smith-Rowland  <3dw...@verizon.net>

 PR libstdc++/83140 - assoc_legendre returns negated value when m is
odd
 * include/tr1/legendre_function.tcc (__assoc_legendre_p): Add
__phase
 argument defaulted to +1.  Doxy comments on same.
 * testsuite/special_functions/02_assoc_legendre/
 check_assoc_legendre.cc: Regen.
 * testsuite/tr1/5_numerical_facilities/special_functions/
 02_assoc_legendre/check_tr1_assoc_legendre.cc: Regen.

something went badly wrong with the regeneration of this last file: both
in your attached patch and in what you checked in, the file is empty.

Rainer


I had hosed up the ChangeLog!

CL change committed as 260149.

New Log attached.

Sorry.



2018-05-10  Edward Smith-Rowland  <3dw...@verizon.net>

PR libstdc++/83140 - assoc_legendre returns negated value when m is odd
* include/tr1/legendre_function.tcc (__assoc_legendre_p): Add __phase
argument defaulted to +1.  Doxy comments on same.
* testsuite/special_functions/02_assoc_legendre/
check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
02_assoc_legendre/check_value.cc: Regen.



Re: [libstdc++, PATCH] PR libstdc++/83140 - assoc_legendre returns negated value when m is odd.

2018-05-11 Thread Ed Smith-Rowland



which always causes a failure:

+FAIL: 
tr1/5_numerical_facilities/special_functions/02_assoc_legendre/check_value.cc 
(test for excess errors)

Excess errors:
Undefined   first referenced
  symbol in file
main/usr/lib/crt1.o
ld: fatal: symbol referencing errors

+UNRESOLVED: tr1/5_numerical_facilities/special_functions/02_assoc_legendre/chec
k_value.cc compilation failed to produce executable

Please fix.

Rainer


Done with 260168.

Ed




Re: [PATCH] libstdc++: add uniform on sphere distribution

2014-08-09 Thread Ed Smith-Rowland

On 08/09/2014 11:33 AM, Marc Glisse wrote:

On Sat, 9 Aug 2014, Ulrich Drepper wrote:

If you are going to specialize for dim 2, I imagine you won't be 
computing
normal distributions, you will only generate a point uniformy in a 
square
and reject it if it is not in the ball? (interestingly enough this 
is used

as a subroutine by the implementation of normal_distribution)


We need to be *on* the circle, not inside.


Yes, you still need the normalization step (divide by the norm). It 
works whether you start from a uniform distribution in the disk or 
from a Gaussian in the plane, but the first one is easier to generate 
(generate points in a square until you get one in the disk). When the 
dimension becomes higher, the probability that a point in the cube 
actually belongs to the ball decreases, and it becomes cheaper to use 
a Gaussian.


If we pull in the implementation of normal you will just be able to use 
the two values that normal computes on the first, (and third, ...) calls 
without doing two calls.  That and hypot would be a real win.


Re: [c++-concepts] explicit instantiation and specialization

2014-08-13 Thread Ed Smith-Rowland

I get build fail:

../../gcc_concepts/gcc/cp/call.c:8793:8: error: unused variable ‘m1’ 
[-Werror=unused-variable]

   tree m1 = get_temploid (cand1);
^
../../gcc_concepts/gcc/cp/call.c:8794:8: error: unused variable ‘m2’ 
[-Werror=unused-variable]

   tree m2 = get_temploid (cand2);
^
cc1plus: all warnings being treated as errors

Commenting the lines let the build finish.

Ed



Re: [PATCH, C++, CPP] Add C++1z to the preprocessor. Rename C++1y to C++14.

2014-08-23 Thread Ed Smith-Rowland

On 08/22/2014 04:36 PM, Jason Merrill wrote:

OK, thanks.

Jason


Committed 214400.

Attached patch is the one committed.
Thanks.


libcpp/

2014-08-23  Edward Smith-Rowland  <3dw...@verizon.net>

* include/cpplib.h (enum c_lang): Add CLK_GNUCXX1Z, CLK_CXX1Z;
Rename CLK_GNUCXX1Y, CLK_CXX1Y to CLK_GNUCXX14, CLK_CXX14;
* init.c (struct lang_flags lang_defaults): Add column for trigraphs;
Add rows for CLK_GNUCXX1Z, CLK_CXX1Z; (cpp_set_lang): Set trigraphs;
(cpp_init_builtins): Set __cplusplus to 201402L for C++14;
Set __cplusplus to 201500L for C++17.
* expr.c (cpp_classify_number): Change C++1y to C++14 in binary
constants error message.


gcc/c-family/

2014-08-23  Edward Smith-Rowland  <3dw...@verizon.net>

* c-common.h (enum cxx_dialect): Add cxx14.
* c-opts.c (set_std_cxx1y): Rename to set_std_cxx14; Use cxx14.
* c-ubsan.c (ubsan_instrument_shift): Change comment and logic from
cxx_dialect == cxx11 || cxx_dialect == cxx1y to cxx_dialect >= cxx11.


gcc/cp/

2014-08-23  Edward Smith-Rowland  <3dw...@verizon.net>

* decl.c (compute_array_index_type, grokdeclarator,
undeduced_auto_decl): Change from cxx1y to cxx14.
*lambda.c(add_capture()): Change error message from C++1y to C++14.
* parser.c (cp_parser_unqualified_id, cp_parser_pseudo_destructor_name,
cp_parser_lambda_introducer, cp_parser_lambda_declarator_opt,
cp_parser_decltype, cp_parser_conversion_type_id,
cp_parser_simple_type_specifier, cp_parser_type_id_1,
cp_parser_template_type_arg, cp_parser_std_attribute,
cp_parser_template_declaration_after_export): Ditto.
* pt.c (tsubst): Ditto.
* semantics.c (force_paren_expr, finish_decltype_type): Ditto.
* tree.c: Change comment.
* typeck.c (comp_template_parms_position, cxx_sizeof_or_alignof_type,
cp_build_addr_expr_1, maybe_warn_about_useless_cast): Ditto.


gcc/

2014-08-23  Edward Smith-Rowland  <3dw...@verizon.net>

* doc/invoke.texi: Change c++1y to c++14 and gnu++1y to gnu++14.
Deprecate c++1y. Change language to reflect greater confidence in C++14.


gcc/testsuite/

2014-08-23  Edward Smith-Rowland  <3dw...@verizon.net>

* g++.dg/cpp0x/cplusplus.C: New.
* g++.dg/cpp0x/cplusplus_0x.C: New.
* g++.dg/cpp0x/auto3.C: Change c++1y to c++14.
* g++.dg/cpp0x/auto41.C: Ditto.
* g++.dg/cpp0x/auto9.C: Ditto.
* g++.dg/cpp0x/initlist26.C: Ditto.
* g++.dg/cpp0x/pr59111.C: Ditto.
* g++.dg/cpp0x/trailing2.C: Ditto.
* g++.dg/cpp1y/attr-deprecated.C: Ditto.
* g++.dg/cpp1y/auto-dtor1.C: Ditto.
* g++.dg/cpp1y/auto-fn1.C: Ditto.
* g++.dg/cpp1y/auto-fn2.C: Ditto.
* g++.dg/cpp1y/auto-fn3.C: Ditto.
* g++.dg/cpp1y/auto-fn4.C: Ditto.
* g++.dg/cpp1y/auto-fn5.C: Ditto.
* g++.dg/cpp1y/auto-fn6.C: Ditto.
* g++.dg/cpp1y/auto-fn7.C: Ditto.
* g++.dg/cpp1y/auto-fn8.C: Ditto.
* g++.dg/cpp1y/auto-fn9.C: Ditto.
* g++.dg/cpp1y/auto-fn10.C: Ditto.
* g++.dg/cpp1y/auto-fn11.C: Ditto.
* g++.dg/cpp1y/auto-fn12.C: Ditto.
* g++.dg/cpp1y/auto-fn13.C: Ditto.
* g++.dg/cpp1y/auto-fn14.C: Ditto.
* g++.dg/cpp1y/auto-fn15.C: Ditto.
* g++.dg/cpp1y/auto-fn16.C: Ditto.
* g++.dg/cpp1y/auto-fn17.C: Ditto.
* g++.dg/cpp1y/auto-fn18.C: Ditto.
* g++.dg/cpp1y/auto-fn19.C: Ditto.
* g++.dg/cpp1y/auto-fn20.C: Ditto.
* g++.dg/cpp1y/auto-fn21.C: Ditto.
* g++.dg/cpp1y/auto-fn22.C: Ditto.
* g++.dg/cpp1y/auto-fn23.C: Ditto.
* g++.dg/cpp1y/auto-fn24.C: Ditto.
* g++.dg/cpp1y/auto-fn25.C: Ditto.
* g++.dg/cpp1y/auto-mangle1.C: Ditto.
* g++.dg/cpp1y/auto-neg1.C: Ditto.
* g++.dg/cpp1y/digit-sep.C: Ditto.
* g++.dg/cpp1y/digit-sep-neg.C: Ditto.
* g++.dg/cpp1y/digit-sep-cxx11-neg.C: Ditto.
* g++.dg/cpp1y/fn-generic-member-ool.C: Ditto.
* g++.dg/cpp1y/lambda-deduce-mult.C: Ditto.
* g++.dg/cpp1y/lambda-generic.C: Ditto.
* g++.dg/cpp1y/lambda-generic-cfun.C: Ditto.
* g++.dg/cpp1y/lambda-generic-dep.C: Ditto.
* g++.dg/cpp1y/lambda-generic-mixed.C: Ditto.
* g++.dg/cpp1y/lambda-generic-udt.C: Ditto.
* g++.dg/cpp1y/lambda-generic-variadic.C: Ditto.
* g++.dg/cpp1y/lambda-generic-vla1.C: Ditto.
* g++.dg/cpp1y/lambda-generic-x.C: Ditto.
* g++.dg/cpp1y/lambda-generic-xcfun.C: Ditto.
* g++.dg/cpp1y/lambda-generic-xudt.C: Ditto.
* g++.dg/cpp1y/lambda-init.C: Ditto.
* g++.dg/cpp1y/lambda-init1.C: Ditto.
* g++.dg/cpp1y/lambda-init2.C: Ditto.
* g++.dg/cpp1y/lambda-init3.C: Ditto.
* g++.dg/cpp1y/lambda-init4.C: Ditto.
* g++.dg/cpp1y/lambda-init5.C: Ditto.
* g++.dg/cpp1y/lambda-init6.C: Ditto.
* g++.dg

[PATCH. libstdc++] Use the correct C++14 __cplusplus value (201402L). Added C++1z to the preprocessor.

2014-08-23 Thread Ed Smith-Rowland
With revision 214400 we have the C++14 value of __cplusplus set to the 
correct value of 201402L (from 201300L).

We should use this in the std lib headers.  This patch does this.

Also, we've set C++14 value of __cplusplus to 201500L so we can start 
adding post-C++14 library bits with

#if __cplusplus > 201402L
...
#endif

Built and tested clean on x86_64-linux.

OK?


2014-08-23  Ed Smith-Rowland  <3dw...@verizon.net>

* libsupc++/new: Use the C++14 value of __cplusplus as appropriate.
* include/bits/parse_numbers.h: Ditto.
* include/bits/stl_function.h: Ditto.
* include/bits/unique_ptr.h: Ditto.
* include/bits/stl_algo.h: Ditto.
* include/bits/stl_algobase.h: Ditto.
* include/bits/basic_string.h: Ditto.
* include/std/complex: Ditto.
* include/std/iomanip: Ditto.
* include/std/utility: Ditto.
* include/std/type_traits: Ditto.
* include/std/tuple: Ditto.
* include/std/chrono: Ditto.
* include/parallel/algobase.h: Ditto.
Index: libsupc++/new
===
--- libsupc++/new   (revision 214399)
+++ libsupc++/new   (working copy)
@@ -81,7 +81,7 @@
 
   // We throw this exception for GNU VLAs of negative length in all C++
   // dialects, so declare it if we aren't in strict conformance mode.
-#if __cplusplus > 201103L || !defined(__STRICT_ANSI__)
+#if __cplusplus >= 201402L || !defined(__STRICT_ANSI__)
   class bad_array_length : public bad_alloc
   {
   public:
Index: include/bits/parse_numbers.h
===
--- include/bits/parse_numbers.h(revision 214399)
+++ include/bits/parse_numbers.h(working copy)
@@ -34,7 +34,7 @@
 
 // From n3642.pdf except I added binary literals and digit separator '\''.
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
 
 #include 
 
@@ -283,6 +283,6 @@
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
-#endif // __cplusplus > 201103L
+#endif // __cplusplus >= 201402L
 
 #endif // _GLIBCXX_PARSE_NUMBERS_H
Index: include/bits/stl_function.h
===
--- include/bits/stl_function.h (revision 214399)
+++ include/bits/stl_function.h (working copy)
@@ -56,7 +56,7 @@
 #ifndef _STL_FUNCTION_H
 #define _STL_FUNCTION_H 1
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
 #include 
 #endif
 
@@ -140,7 +140,7 @@
*  @{
*/
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   struct __is_transparent;  // undefined
 
   template
@@ -216,7 +216,7 @@
   { return -__x; }
 };
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   template<>
 struct plus
 {
@@ -311,7 +311,7 @@
*
*  @{
*/
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   template
 struct equal_to;
 
@@ -385,7 +385,7 @@
   { return __x <= __y; }
 };
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   /// One of the @link comparison_functors comparison functors@endlink.
   template<>
 struct equal_to
@@ -481,7 +481,7 @@
*
*  @{
*/
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   template
 struct logical_and;
 
@@ -519,7 +519,7 @@
   { return !__x; }
 };
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   /// One of the @link logical_functors Boolean operations functors@endlink.
   template<>
 struct logical_and
@@ -564,7 +564,7 @@
 #endif
   /** @}  */
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   template
 struct bit_and;
 
@@ -612,7 +612,7 @@
   { return ~__x; }
 };
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   template <>
 struct bit_and
 {
Index: include/bits/unique_ptr.h
===
--- include/bits/unique_ptr.h   (revision 214399)
+++ include/bits/unique_ptr.h   (working copy)
@@ -742,7 +742,7 @@
   }
 };
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   template
 struct _MakeUniq
 { typedef unique_ptr<_Tp> __single_object; };
Index: include/bits/stl_algo.h
===
--- include/bits/stl_algo.h (revision 214399)
+++ include/bits/stl_algo.h (working copy)
@@ -3570,7 +3570,7 @@
   __gnu_cxx::__ops::__iter_comp_iter(__pred));
 }
 
-#if __cplusplus > 201103L
+#if __cplusplus >= 201402L
   template
 bool
Index: include/bits/stl_algobase.h
===
--- include/bits/stl_algobase.h (revision 214399)
+++ include/bits/stl_algobase.h (working copy)
@@ -1090,7 +1090,7 @@
   return true;
 }
 
-#if __cplusplus > 201103L
+#if __cplusplus >=

Re: [PATCH. libstdc++] Use the correct C++14 __cplusplus value (201402L). Added C++1z to the preprocessor.

2014-08-26 Thread Ed Smith-Rowland

On 08/26/2014 04:59 AM, Paolo Carlini wrote:

Hi,

On 08/26/2014 10:56 AM, Rainer Orth wrote:

bits/c++config...
Which won't help users seeing them in the headers.  Maybe the issue
could be avoided by chosing names that make it clear that they are
g++/libstdc++ specific, not generic?

Sure, whatever works, the names were tentative, for the cpp idea.

Paolo.


I should have mentioned this thought.

Maybe we could do something more scary like

   __GLIBCXX_CPLUSPLUS_98
   __GLIBCXX_CPLUSPLUS_11
   __GLIBCXX_CPLUSPLUS_14

so people won't use them.

The __cplusplus_11 etc. look almost "standard" ;-)

Ed



[PATCH, CPP/23827] standard C++ should not have hex float preprocessing tokens

2014-08-27 Thread Ed Smith-Rowland
This old one says the C++98 ANSI doesn't have hex float literals and 
should error gracefully.
Fixed by changing a language feature flag as suggested by the audit 
trail and by adding an error message.


Built and tested on x86_64-linux.

OK?


libcpp/

2014-08-27  Edward Smith-Rowland  <3dw...@verizon.net>

PR cpp/23827 - standard C++ should not have hex float preprocessor
tokens
* libcpp/init.c (lang_flags): Change CXX98 flag for extended numbers
from 1 to 0.
* libcpp/expr.c (cpp_classify_number): Weite error message for improper
use of hex floating literal.


gcc/testsuite/

2014-08-27  Edward Smith-Rowland  <3dw...@verizon.net>

PR cpp/23827 - standard C++ should not have hex float preprocessor
tokens
* g++.dg/cpp/pr23827_cxx11.C: New.
* g++.dg/cpp/pr23827_cxx98.C: New.
* g++.dg/cpp/pr23827_cxx98_neg.C: New.
* gcc.dg/cpp/pr23827_c90.c: New.
* gcc.dg/cpp/pr23827_c90_neg.c: New.
* gcc.dg/cpp/pr23827_c99.c: New.
Index: libcpp/init.c
===
--- libcpp/init.c   (revision 214556)
+++ libcpp/init.c   (working copy)
@@ -103,7 +103,7 @@
   /* STDC99   */  { 1,  0,  1,  0,  0,  1,  1,  1,  0,   0,   0,0, 0,  
   1 },
   /* STDC11   */  { 1,  0,  1,  0,  1,  1,  1,  1,  1,   0,   0,0, 0,  
   1 },
   /* GNUCXX   */  { 0,  1,  1,  0,  0,  0,  1,  1,  0,   0,   0,0, 0,  
   0 },
-  /* CXX98*/  { 0,  1,  1,  0,  0,  1,  1,  1,  0,   0,   0,0, 0,  
   1 },
+  /* CXX98*/  { 0,  1,  0,  0,  0,  1,  1,  1,  0,   0,   0,0, 0,  
   1 },
   /* GNUCXX11 */  { 1,  1,  1,  0,  1,  0,  1,  1,  1,   1,   1,0, 0,  
   0 },
   /* CXX11*/  { 1,  1,  1,  0,  1,  1,  1,  1,  1,   1,   1,0, 0,  
   1 },
   /* GNUCXX14 */  { 1,  1,  1,  0,  1,  0,  1,  1,  1,   1,   1,1, 1,  
   0 },
Index: libcpp/expr.c
===
--- libcpp/expr.c   (revision 214556)
+++ libcpp/expr.c   (working copy)
@@ -540,9 +540,16 @@
SYNTAX_ERROR_AT (virtual_location,
 "no digits in hexadecimal floating constant");
 
-  if (radix == 16 && CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, c99))
-   cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
-"use of C99 hexadecimal floating constant");
+  if (radix == 16 && CPP_PEDANTIC (pfile)
+ && !CPP_OPTION (pfile, extended_numbers))
+   {
+ if (CPP_OPTION (pfile, cplusplus))
+   cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
+"use of C++11 hexadecimal floating constant");
+ else
+   cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
+"use of C99 hexadecimal floating constant");
+   }
 
   if (float_flag == AFTER_EXPON)
{
Index: gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C
===
--- gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C(revision 0)
+++ gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C(working copy)
@@ -0,0 +1,23 @@
+// { dg-do run { target c++11 } }
+// { dg-options "-pedantic-errors" }
+
+#define f (
+#define l )
+#define str(x) #x
+#define xstr(x) str(x)
+
+// C90 and C++98: "0x1p+( 0x1p+)"
+// C99 and C++11: "0x1p+f 0x1p+l"
+const char *s = xstr(0x1p+f 0x1p+l);
+
+extern "C" void abort (void);
+extern "C" int strcmp (const char *, const char *);
+
+int
+main()
+{
+  if (strcmp (s, "0x1p+( 0x1p+)"))
+return 0; // Correct C99 and C++11 behavior.
+  else
+abort (); // Correct C90 and C++ behavior.
+}
Index: gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C
===
--- gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C(revision 0)
+++ gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C(working copy)
@@ -0,0 +1,23 @@
+// { dg-do run { target c++98_only } }
+// { dg-options "-ansi -pedantic-errors" }
+
+#define f (
+#define l )
+#define str(x) #x
+#define xstr(x) str(x)
+
+// C90 and C++98: "0x1p+( 0x1p+)"
+// C99 and C++11: "0x1p+f 0x1p+l"
+const char *s = xstr(0x1p+f 0x1p+l);
+
+extern "C" void abort (void);
+extern "C" int strcmp (const char *, const char *);
+
+int
+main()
+{
+  if (strcmp (s, "0x1p+( 0x1p+)"))
+abort (); // Correct C99 and C++11 behavior.
+  else
+return 0; // Correct C90 and C++ behavior.
+}
Index: gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C
===
--- gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C(revision 0)
+++ gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C(working copy)
@@ -0,0 +1,4 @@
+// { dg-do compile { target c++98_only } }
+/* { dg-options "-ansi -pedantic-errors" }  */
+
+double x = 0x3.1415babep0; // { dg-error "use of C..11 hexadecimal floating 
constan

Re: [PATCH, CPP/23827] standard C++ should not have hex float preprocessing tokens

2014-08-28 Thread Ed Smith-Rowland

On 08/27/2014 03:40 PM, Jason Merrill wrote:

OK.

Jason


Is this OK for 4.9 also?
It builds and tests clean on x86_64-linux.

Attached slightly modified patch.

Ed


libcpp/

2014-08-28  Edward Smith-Rowland  <3dw...@verizon.net>

PR cpp/23827 - standard C++ should not have hex float preprocessor
tokens
* libcpp/init.c (lang_flags): Change CXX98 flag for extended numbers
from 1 to 0.
* libcpp/expr.c (cpp_classify_number): Weite error message for improper
use of hex floating literal.


gcc/testsuite/

2014-08-28  Edward Smith-Rowland  <3dw...@verizon.net>

PR cpp/23827 - standard C++ should not have hex float preprocessor
tokens
* g++.dg/cpp/pr23827_cxx11.C: New.
* g++.dg/cpp/pr23827_cxx98.C: New.
* g++.dg/cpp/pr23827_cxx98_neg.C: New.
* gcc.dg/cpp/pr23827_c90.c: New.
* gcc.dg/cpp/pr23827_c90_neg.c: New.
* gcc.dg/cpp/pr23827_c99.c: New.

Index: libcpp/init.c
===
--- libcpp/init.c   (revision 214616)
+++ libcpp/init.c   (working copy)
@@ -98,7 +98,7 @@
   /* STDC99   */  { 1,  0,  1,   0,  0,  1,   1,   1,   0,   0,   0,0, 
 0 },
   /* STDC11   */  { 1,  0,  1,   0,  1,  1,   1,   1,   1,   0,   0,0, 
 0 },
   /* GNUCXX   */  { 0,  1,  1,   0,  0,  0,   1,   1,   0,   0,   0,0, 
 0 },
-  /* CXX98*/  { 0,  1,  1,   0,  0,  1,   1,   1,   0,   0,   0,0, 
 0 },
+  /* CXX98*/  { 0,  1,  0,   0,  0,  1,   1,   1,   0,   0,   0,0, 
 0 },
   /* GNUCXX11 */  { 1,  1,  1,   0,  1,  0,   1,   1,   1,   1,   1,0, 
 0 },
   /* CXX11*/  { 1,  1,  1,   0,  1,  1,   1,   1,   1,   1,   1,0, 
 0 },
   /* GNUCXX1Y */  { 1,  1,  1,   0,  1,  0,   1,   1,   1,   1,   1,1, 
 1 },
Index: libcpp/expr.c
===
--- libcpp/expr.c   (revision 214616)
+++ libcpp/expr.c   (working copy)
@@ -540,9 +540,16 @@
SYNTAX_ERROR_AT (virtual_location,
 "no digits in hexadecimal floating constant");
 
-  if (radix == 16 && CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, c99))
-   cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
-"use of C99 hexadecimal floating constant");
+  if (radix == 16 && CPP_PEDANTIC (pfile)
+ && !CPP_OPTION (pfile, extended_numbers))
+   {
+ if (CPP_OPTION (pfile, cplusplus))
+   cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
+"use of C++11 hexadecimal floating constant");
+ else
+   cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
+"use of C99 hexadecimal floating constant");
+   }
 
   if (float_flag == AFTER_EXPON)
{
Index: gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C
===
--- gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C(revision 0)
+++ gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C(working copy)
@@ -0,0 +1,23 @@
+// { dg-do run { target c++11 } }
+// { dg-options "-pedantic-errors" }
+
+#define f (
+#define l )
+#define str(x) #x
+#define xstr(x) str(x)
+
+// C90 and C++98: "0x1p+( 0x1p+)"
+// C99 and C++11: "0x1p+f 0x1p+l"
+const char *s = xstr(0x1p+f 0x1p+l);
+
+extern "C" void abort (void);
+extern "C" int strcmp (const char *, const char *);
+
+int
+main()
+{
+  if (strcmp (s, "0x1p+( 0x1p+)"))
+return 0; // Correct C99 and C++11 behavior.
+  else
+abort (); // Correct C90 and C++ behavior.
+}
Index: gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C
===
--- gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C(revision 0)
+++ gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C(working copy)
@@ -0,0 +1,23 @@
+// { dg-do run { target c++98_only } }
+// { dg-options "-ansi -pedantic-errors" }
+
+#define f (
+#define l )
+#define str(x) #x
+#define xstr(x) str(x)
+
+// C90 and C++98: "0x1p+( 0x1p+)"
+// C99 and C++11: "0x1p+f 0x1p+l"
+const char *s = xstr(0x1p+f 0x1p+l);
+
+extern "C" void abort (void);
+extern "C" int strcmp (const char *, const char *);
+
+int
+main()
+{
+  if (strcmp (s, "0x1p+( 0x1p+)"))
+abort (); // Correct C99 and C++11 behavior.
+  else
+return 0; // Correct C90 and C++ behavior.
+}
Index: gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C
===
--- gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C(revision 0)
+++ gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C(working copy)
@@ -0,0 +1,4 @@
+// { dg-do compile { target c++98_only } }
+/* { dg-options "-ansi -pedantic-errors" }  */
+
+double x = 0x3.1415babep0; // { dg-error "use of C..11 hexadecimal floating 
constant" }
Index: gcc/testsuite/gcc.dg/cpp/pr23827_c90.c
==

Re: [PATCH, CPP/23827] standard C++ should not have hex float preprocessing tokens

2014-08-28 Thread Ed Smith-Rowland

On 08/28/2014 09:47 AM, Jason Merrill wrote:

On 08/28/2014 09:41 AM, Marc Glisse wrote:

In my opinion it is not appropriate for a backport, no. If someone was
using hex floats with -std=c++98 with 4.9.1, it should still work with
4.9.2, I only expect to have to fix such things when moving to 5.0.


Agreed.

Jason





OK, I understand.  Makes sense.
It is a capability change not really just a bugfix per se.
On that note is it worth a sentence in Changes?

Ed



[PATCH C++] - SD-6 Implementation Part 1 - __has_include.

2014-09-01 Thread Ed Smith-Rowland

Greetings,

I am finally getting back to my SD-6 C++ features test work.
This first part adds a __has_include__ built-in that will return true if 
a header exists.
I also added __has_include_next__ as an extension.  Clang has this 
extension.


Both these built-ins will be wrapped in function type macros in a later 
patch to c-family.


As written, these are available to the whole C-family rather than just C++.
I think this makes a valuable addition for everyone.
(I sort of wonder why this wasn't added to the actual preprocessor 20 
years ago.)


Bootstrapped and tested under x86_64-linux.

OK?

Ed

2014-09-02  Edward Smith-Rowland  <3dw...@verizon.net>

Implement SD-6: SG10 Feature Test Recommendations
* internal.h (lexer_state, spec_nodes): Add in__has_include__.
* directives.c: Support __has_include__ builtin.
* expr.c (parse_has_include): New function to parse __has_include__
builtin; (eval_token()): Use it.
* files.c (_cpp_has_header()): New funtion to look for header;
(open_file_failed()): Not an error to not find a header file for
__has_include__.
* identifiers.c (_cpp_init_hashtable()): Add entry for __has_include__.
* pch.c (cpp_read_state): Lookup __has_include__.
* traditional.c (enum ls, _cpp_scan_out_logical_line()): Walk through
__has_include__ statements.

Index: internal.h
===
--- internal.h  (revision 214680)
+++ internal.h  (working copy)
@@ -258,6 +258,9 @@
   /* Nonzero when parsing arguments to a function-like macro.  */
   unsigned char parsing_args;
 
+  /* Nonzero to prevent macro expansion.  */
+  unsigned char in__has_include__;
+
   /* Nonzero if prevent_expansion is true only because output is
  being discarded.  */
   unsigned char discarding_output;
@@ -279,6 +282,8 @@
   cpp_hashnode *n_true;/* C++ keyword true */
   cpp_hashnode *n_false;   /* C++ keyword false */
   cpp_hashnode *n__VA_ARGS__;  /* C99 vararg macros */
+  cpp_hashnode *n__has_include__;  /* __has_include__ operator */
+  cpp_hashnode *n__has_include_next__; /* __has_include_next__ operator */
 };
 
 typedef struct _cpp_line_note _cpp_line_note;
@@ -645,6 +650,8 @@
 extern bool _cpp_read_file_entries (cpp_reader *, FILE *);
 extern const char *_cpp_get_file_name (_cpp_file *);
 extern struct stat *_cpp_get_file_stat (_cpp_file *);
+extern bool _cpp_has_header (cpp_reader *, const char *, int,
+enum include_type);
 
 /* In expr.c */
 extern bool _cpp_parse_expr (cpp_reader *, bool);
@@ -680,6 +687,7 @@
 extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
 linenum_type, unsigned int);
 extern void _cpp_pop_buffer (cpp_reader *);
+extern char *_cpp_bracket_include (cpp_reader *);
 
 /* In directives.c */
 struct _cpp_dir_only_callbacks
Index: directives.c
===
--- directives.c(revision 214680)
+++ directives.c(working copy)
@@ -549,6 +549,11 @@
   if (is_def_or_undef && node == pfile->spec_nodes.n_defined)
cpp_error (pfile, CPP_DL_ERROR,
   "\"defined\" cannot be used as a macro name");
+  else if (is_def_or_undef
+   && (node == pfile->spec_nodes.n__has_include__
+|| node == pfile->spec_nodes.n__has_include_next__))
+   cpp_error (pfile, CPP_DL_ERROR,
+  "\"__has_include__\" cannot be used as a macro name");
   else if (! (node->flags & NODE_POISONED))
return node;
 }
@@ -2601,3 +2606,12 @@
   node->directive_index = i;
 }
 }
+
+/* Extract header file from a bracket include. Parsing starts after '<'.
+   The string is malloced and must be freed by the caller.  */
+char *
+_cpp_bracket_include(cpp_reader *pfile)
+{
+  return glue_header_name (pfile);
+}
+
Index: expr.c
===
--- expr.c  (revision 214680)
+++ expr.c  (working copy)
@@ -64,6 +64,8 @@
 static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
 static void check_promotion (cpp_reader *, const struct op *);
 
+static cpp_num parse_has_include (cpp_reader *, enum include_type);
+
 /* Token type abuse to create unary plus and minus operators.  */
 #define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1))
 #define CPP_UMINUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 2))
@@ -1048,6 +1050,10 @@
 case CPP_NAME:
   if (token->val.node.node == pfile->spec_nodes.n_defined)
return parse_defined (pfile);
+  else if (token->val.node.node == pfile->spec_nodes.n__has_include__)
+   return parse_has_include (pfile, IT_INCLUDE);
+  else if (token->val.node.node == pfile->spec_nodes.n__has_include_next__)
+   return parse_has_include (pfile, IT_INCLUDE_NEXT);
   else if (CPP_OPTION

[PATCH C++] - SD-6 Implementation Part 2 - __has_include macro and C++ language feature macros.

2014-09-01 Thread Ed Smith-Rowland

Greetings,

I am finally getting back to my SD-6 C++ features test work.

This second part adds a __has_include function-like macro that will 
return true if a header exists. I also added a __has_include_next 
function-like macro as an extension. Clang has this extension.

These macros just wrap the built-ins introduced in the previous patch.

As requested by folk I have rearranged which language-feature macros are 
available with what .

There is one bit: arrays of runtime bound.  These got kicked out of C++14 I 
think and is languishing in a TS.
OTOH, we still support it.  It's better than the C99 version we supported.
What direction should I take?

Bootstrapped and tested under x86_64-linux.

OK?

Ed

2014-09-02  Edward Smith-Rowland  <3dw...@verizon.net>

Implement SD-6: SG10 Feature Test Recommendations
* c-cppbuiltin.c (c_cpp_builtins()): Define language feature
macros and the __has_header macro.

Index: c-cppbuiltin.c
===
--- c-cppbuiltin.c  (revision 214680)
+++ c-cppbuiltin.c  (working copy)
@@ -794,6 +794,12 @@
   /* For stddef.h.  They require macros defined in c-common.c.  */
   c_stddef_cpp_builtins ();
 
+  /* Set include test macros for all C/C++ (not for just C++11 etc.)
+ the builtins __has_include__ and __has_include_next__ are defined
+ in libcpp.  */
+  cpp_define (pfile, "__has_include(STR)=__has_include__(STR)");
+  cpp_define (pfile, "__has_include_next(STR)=__has_include_next__(STR)");
+
   if (c_dialect_cxx ())
 {
   if (flag_weak && SUPPORTS_ONE_ONLY)
@@ -800,12 +806,57 @@
cpp_define (pfile, "__GXX_WEAK__=1");
   else
cpp_define (pfile, "__GXX_WEAK__=0");
+
   if (warn_deprecated)
cpp_define (pfile, "__DEPRECATED");
+
   if (flag_rtti)
cpp_define (pfile, "__GXX_RTTI");
+
   if (cxx_dialect >= cxx11)
 cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
+
+  /* Binary literals and variable length arrays have been allowed in g++
+before C++11 and were standardized for C++14.  Runtime sized arrays
+have C++14 semantics even for C++98.  */
+  if (!pedantic || cxx_dialect > cxx11)
+   {
+ cpp_define (pfile, "__cpp_binary_literals=201304");
+ cpp_define (pfile, "__cpp_runtime_arrays=201304");
+   }
+  if (cxx_dialect >= cxx11)
+   {
+ /* Set feature test macros for C++11  */
+ cpp_define (pfile, "__cpp_unicode_characters=200704");
+ cpp_define (pfile, "__cpp_raw_strings=200710");
+ cpp_define (pfile, "__cpp_unicode_literals=200710");
+ cpp_define (pfile, "__cpp_user_defined_literals=200809");
+ cpp_define (pfile, "__cpp_lambdas=200907");
+ cpp_define (pfile, "__cpp_constexpr=200704");
+ cpp_define (pfile, "__cpp_static_assert=200410");
+ cpp_define (pfile, "__cpp_decltype=200707");
+ cpp_define (pfile, "__cpp_attributes=200809");
+ cpp_define (pfile, "__cpp_rvalue_reference=200610");
+ cpp_define (pfile, "__cpp_variadic_templates=200704");
+ cpp_define (pfile, "__cpp_alias_templates=200704");
+ /* Return type deduction was added as an extension to C++11
+and was standardized for C+14.  */
+ cpp_define (pfile, "__cpp_return_type_deduction=201304");
+   }
+  if (cxx_dialect > cxx11)
+   {
+ /* Set feature test macros for C++14  */
+ cpp_define (pfile, "__cpp_init_captures=201304");
+ cpp_define (pfile, "__cpp_generic_lambdas=201304");
+ //cpp_undef (pfile, "__cpp_constexpr");
+ //cpp_define (pfile, "__cpp_constexpr=201304");
+ cpp_define (pfile, "__cpp_decltype_auto=201304");
+ //cpp_define (pfile, "__cpp_aggregate_nsdmi=201304");
+ cpp_define (pfile, "__cpp_variable_templates=201304");
+ cpp_define (pfile, "__cpp_digit_separators=201309");
+ cpp_define (pfile, "__cpp_attribute_deprecated=201309");
+ //cpp_define (pfile, "__cpp_sized_deallocation=201309");
+   }
 }
   /* Note that we define this for C as well, so that we know if
  __attribute__((cleanup)) will interface with EH.  */


[PATCH C++] - SD-6 Implementation Part 3 - .

2014-09-01 Thread Ed Smith-Rowland

Greetings,

I am finally getting back to my SD-6 C++ features test work.

This adds feature macros to various libstdc++ components.
The new version of SD-6 cleans up the shared_mutex noise.

Some libraries that were moved to different tSen are still given macros as they 
are in the SD-6 draft.

Bootstrapped and tested under x86_64-linux.

OK?

Ed

2014-09-02  Edward Smith-Rowland  <3dw...@verizon.net>

Implement SD-6: SG10 Feature Test Recommendations
* include/bits/basic_string.h: Add __cpp_lib feature test macro.
* include/bits/stl_algobase.h: Ditto.
* include/bits/stl_function.h: Ditto.
* include/bits/unique_ptr.h: Ditto.
* include/std/chrono: Ditto.
* include/std/complex: Ditto.
* include/std/iomanip: Ditto.
* include/std/shared_mutex: Ditto.
* include/std/tuple: Ditto.
* include/std/type_traits: Ditto.
* include/std/utility: Ditto.
* testsuite/experimental/feat-cxx14.cc: New.
* testsuite/experimental/feat-lib-fund.cc: New.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
* testsuite/20_util/duration/literals/range.cc: Adjust.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Adjust.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Adjust.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Adjust.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
Adjust.

Index: include/bits/basic_string.h
===
--- include/bits/basic_string.h (revision 214680)
+++ include/bits/basic_string.h (working copy)
@@ -3140,6 +3140,8 @@
 
 #if __cplusplus > 201103L
 
+#define __cpp_lib_string_udls 201304
+
   inline namespace literals
   {
   inline namespace string_literals
Index: include/bits/stl_algobase.h
===
--- include/bits/stl_algobase.h (revision 214680)
+++ include/bits/stl_algobase.h (working copy)
@@ -1091,6 +1091,9 @@
 }
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_robust_nonmodifying_seq_ops 201304
+
   /**
*  @brief Tests a range for element-wise equality.
*  @ingroup non_mutating_algorithms
Index: include/bits/stl_function.h
===
--- include/bits/stl_function.h (revision 214680)
+++ include/bits/stl_function.h (working copy)
@@ -217,6 +217,10 @@
 };
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_transparent_operators 201210
+#define __cpp_lib_generic_associative_lookup 201304
+
   template<>
 struct plus
 {
Index: include/bits/unique_ptr.h
===
--- include/bits/unique_ptr.h   (revision 214680)
+++ include/bits/unique_ptr.h   (working copy)
@@ -743,6 +743,9 @@
 };
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_make_unique 201304
+
   template
 struct _MakeUniq
 { typedef unique_ptr<_Tp> __single_object; };
Index: include/std/chrono
===
--- include/std/chrono  (revision 214680)
+++ include/std/chrono  (working copy)
@@ -782,6 +782,8 @@
 
 #if __cplusplus > 201103L
 
+#define __cpp_lib_chrono_udls 201304
+
   inline namespace literals
   {
   inline namespace chrono_literals
Index: include/std/complex
===
--- include/std/complex (revision 214680)
+++ include/std/complex (working copy)
@@ -1929,6 +1929,8 @@
 inline namespace literals {
 inline namespace complex_literals {
 
+#define __cpp_lib_complex_udls 201309
+
   constexpr std::complex
   operator""if(long double __num)
   { return std::complex{0.0F, static_cast(__num)}; }
Index: include/std/iomanip
===
--- include/std/iomanip (revision 214680)
+++ include/std/iomanip (working copy)
@@ -339,6 +339,8 @@
 
 #if __cplusplus > 201103L
 
+#define __cpp_lib_quoted_string_io 201304
+
 _GLIBCXX_END_NAMESPACE_VERSION
   namespace __detail {
   _GLIBCXX_BEGIN_NAMESPACE_VERSION
Index: include/std/shared_mutex
===
--- include/std/shared_mutex(revision 214680)
+++ include/std/shared_mutex(working copy)
@@ -52,6 +52,9 @@
*/
 
 #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+
+#define __cpp_lib_shared_timed_mutex 201402
+
   /// shared_timed_mutex
   class shared_timed_mutex
   {
Index: include/std/tuple
===
--- include/std/tuple   (revision 214680)
+++ include/std/tuple   (wo

[PATCH C++] - SD-6 Implementation

2014-09-01 Thread Ed Smith-Rowland

The Fourth installment, testing and other oddments will be sent tomorrow.

The implementation of __has_cpp_attribute is underway and will come in a 
few days as a Fifth installment (modulo bugs this should be all).

I have it working in C++.
I feel though that it would be welcome as it is in clang for all 
C-family languages.  I intend to offer a __has_attribute for all C 
languages.

The __has_cpp_attribute will just be for C++.

Thiago, I did not mean to clobber your work.  This has been baking for a 
while (last patches in June) and I just got back to it after a break 
with little useful attention to g++.
Perhaps we can combine our work.  I'll look over your patch.  I know you 
want this to support Qt ;-)  I think this effort will help.


Sincerely,

Ed



[PATCH C++] - SD-6 Implementation Part 4 - Test suite.

2014-09-06 Thread Ed Smith-Rowland

Greetings,

I am finally getting back to my SD-6 C++ features test work.

This adds front end and preprocessor tests for the language feature tests and 
__has_include.

I am still working on the fifth and last in this series to add 
__had_cpp_attribute but these first four patches add a very useful subset of 
the SD-6 feature testing.

Bootstrapped and tested under x86_64-linux.

OK?

Ed

2014-09-06  Edward Smith-Rowland  <3dw...@verizon.net>

Implement SD-6: SG10 Feature Test Recommendations
* g++.dg/cpp1y/feat-cxx11-neg.C: New.
* g++.dg/cpp1y/feat-cxx11.C: New.
* g++.dg/cpp1y/feat-cxx14.C: New.
* g++.dg/cpp1y/feat-cxx98.C: New.
* g++.dg/cpp1y/feat-cxx98-neg.C: New.
* g++.dg/cpp1y/phoobhar.h: New.
* g++.dg/cpp1y/testinc/phoobhar.h: New.

Index: g++.dg/cpp1y/feat-cxx11-neg.C
===
--- g++.dg/cpp1y/feat-cxx11-neg.C   (revision 0)
+++ g++.dg/cpp1y/feat-cxx11-neg.C   (working copy)
@@ -0,0 +1,32 @@
+// { dg-do compile { target c++11_only } }
+// { dg-options "-pedantic-errors" }
+
+// These *are* defined in C++14 onwards.
+
+#ifndef __cpp_binary_literals
+#  error "__cpp_binary_literals" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_init_captures
+#  error "__cpp_init_captures" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_generic_lambdas
+#  error "__cpp_generic_lambdas" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_decltype_auto
+#  error "__cpp_decltype_auto" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_runtime_arrays
+#  error "__cpp_runtime_arrays" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_digit_separators
+#  error "__cpp_digit_separators" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_attribute_deprecated
+#  error "__cpp_attribute_deprecated" // { dg-error "error" }
+#endif
Index: g++.dg/cpp1y/feat-cxx11.C
===
--- g++.dg/cpp1y/feat-cxx11.C   (revision 0)
+++ g++.dg/cpp1y/feat-cxx11.C   (working copy)
@@ -0,0 +1,94 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+#ifndef __cpp_unicode_characters
+#  error "__cpp_unicode_characters"
+#elif __cpp_unicode_characters != 200704
+#  error "__cpp_unicode_characters != 200704"
+#endif
+
+#ifndef __cpp_raw_strings
+#  error "__cpp_raw_strings"
+#elif __cpp_raw_strings != 200710
+#  error "__cpp_raw_strings != 200710"
+#endif
+
+#ifndef __cpp_unicode_literals
+#  error "__cpp_unicode_literals"
+#elif __cpp_unicode_literals != 200710
+#  error "__cpp_unicode_literals != 200710"
+#endif
+
+#ifndef __cpp_user_defined_literals
+#  error "__cpp_user_defined_literals"
+#elif __cpp_user_defined_literals != 200809
+#  error "__cpp_user_defined_literals != 200809"
+#endif
+
+#ifndef __cpp_lambdas
+#  error "__cpp_lambdas"
+#elif __cpp_lambdas != 200907
+#  error "__cpp_lambdas != 200907"
+#endif
+
+#ifndef __cpp_constexpr
+#  error "__cpp_constexpr"
+#elif __cpp_constexpr != 200704
+#  error "__cpp_constexpr != 200704"
+#endif
+
+#ifndef __cpp_static_assert
+#  error "__cpp_static_assert"
+#elif __cpp_static_assert != 200410
+#  error "__cpp_static_assert != 200410"
+#endif
+
+#ifndef __cpp_decltype
+#  error "__cpp_decltype"
+#elif __cpp_decltype != 200707
+#  error "__cpp_decltype != 200707"
+#endif
+
+#ifndef __cpp_attributes
+#  error "__cpp_attributes"
+#elif __cpp_attributes != 200809
+#  error "__cpp_attributes != 200809"
+#endif
+
+#ifndef __cpp_rvalue_reference
+#  error "__cpp_rvalue_reference"
+#elif __cpp_rvalue_reference != 200610
+#  error "__cpp_rvalue_reference != 200610"
+#endif
+
+#ifndef __cpp_variadic_templates
+#  error "__cpp_variadic_templates"
+#elif __cpp_variadic_templates != 200704
+#  error "__cpp_variadic_templates != 200704"
+#endif
+
+#ifndef __cpp_alias_templates
+#  error "__cpp_alias_templates"
+#elif __cpp_alias_templates != 200704
+#  error "__cpp_alias_templates != 200704"
+#endif
+
+//  This C++14 feature was developed as an extension for C++11.
+#ifndef __cpp_return_type_deduction
+#  error "__cpp_return_type_deduction"
+#elif __cpp_return_type_deduction != 201304
+#  error "__cpp_return_type_deduction != 201304"
+#endif
+
+//  These C++14 features are allowed in C++11 in non-ANSI modes.
+#ifndef __cpp_binary_literals
+#  error "__cpp_binary_literals"
+#elif __cpp_binary_literals != 201304
+#  error "__cpp_binary_literals != 201304"
+#endif
+
+#ifndef __cpp_runtime_arrays
+#  error "__cpp_runtime_arrays"
+#elif __cpp_runtime_arrays != 201304
+#  error "__cpp_runtime_arrays != 201304"
+#endif
Index: g++.dg/cpp1y/feat-cxx14.C
===
--- g++.dg/cpp1y/feat-cxx14.C   (revision 0)
+++ g++.dg/cpp1y/feat-cxx14.C   (working copy)
@@ -0,0 +1,232 @@
+// { dg-do compile { target c++14 } }
+// { dg-options "-I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" }
+
+// Begin C++11 tests.
+
+#ifndef __cpp_unicode_characters
+#  error "__cpp_unicode_char

Re: [C++14] implement [[deprecated]].

2013-11-09 Thread Ed Smith-Rowland

On 10/27/2013 05:17 AM, Paolo Carlini wrote:

On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:

I think this is pretty easy - gnu::deprecated has the same semantics.
Since we decided to have this now, we should also update the docs, 
thus htdocs/projects/cxx1y.html (which normally would link 
htdocs/gcc-4.9/changes.html, thus a line or so there too).


Thanks!
Paolo.



Here is a patch to the web pages for new C++14 front-end and library 
additions.

Check to see if you agree or if I left anything out.

OK?

Ed

Index: htdocs/projects/cxx1y.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.8
diff -r1.8 cxx1y.html
113,114c113,115
<   http://isocpp.org/files/papers/n3760.htm";>N3760
<   No
---
>href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html";>N3760
>   
> 4.9 (N3797)
118,119c119,121
<   http://isocpp.org/files/papers/N3781.pdf";>N3781
<   No
---
>href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf";>N3781
>   
> 4.9 (N3797)
Index: htdocs/gcc-4.9/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v
retrieving revision 1.32
diff -r1.32 changes.html
150a151,174
> G++ supports the C++1y [[deprecated]]
> attribute modulo bugs in the underying [[gnu::deprecated]] attribute.  
> Classes
> and functions can be marked deprecated and 
> 
> 
>   
> class A {};
> #if __cplusplus > 201103:
> class A [[deprecated("A is deprecated in C++14; Use B instead")]];
> class B {};
> #endif
>   
>   
> 
>   int i = 1048576;
>   int j = 1'048'576;
>   int k = 0x10';
>   int m = 0'004'000'000;
>   int n = 0b0001''''';
> 
>   double x = 1.602'176'565e-19;
>   double y = 1.602'176'565e-1'9;
> 
>   
158a183,205
>  href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014";>
>Improved experimental support for the upcoming ISO C++ standard, 
> C++14,
>including:
>   
>  fixing constexpr member functions without 
> const; 
>  implementation of the exchange() utility function; 
> 
>  addressing tuples by type; 
>  implemention of make_unique; 
>  making std::result_of SFINAE-friendly; 
>  adding operator() to 
> integral_constant; 
>  adding user-defined literals for standard library types
>  string, chrono, and 
> complex; 
>  adding two range overloads to non-modifying sequence oprations; 
> 
>  adding IO manipulators for quoted strings; 
>  adding constexpr members to utilities, 
> complex,
>  chrono, and some containers; 
>  adding compile-time integer_sequences; 
>  adding cleaner transformation traits; 
>  adding a class for optional types; 
>  making functionals operator functors easier to use 
> and
>  more generic; 
>   
> 


[wwwdocs] [C++14] Library and front-end additions

2013-11-09 Thread Ed Smith-Rowland

On 10/27/2013 05:17 AM, Paolo Carlini wrote:

On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:

I think this is pretty easy - gnu::deprecated has the same semantics.
Since we decided to have this now, we should also update the docs, 
thus htdocs/projects/cxx1y.html (which normally would link 
htdocs/gcc-4.9/changes.html, thus a line or so there too).


Thanks!
Paolo.


My last email had a bad patch.

Try this one.

OK?

Index: htdocs/projects/cxx1y.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.8
diff -r1.8 cxx1y.html
113,114c113,115
<   http://isocpp.org/files/papers/n3760.htm";>N3760
<   No
---
>href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html";>N3760
>   
> 4.9 (N3797)
118,119c119,121
<   http://isocpp.org/files/papers/N3781.pdf";>N3781
<   No
---
>href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf";>N3781
>   
> 4.9 (N3797)
Index: htdocs/gcc-4.9/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v
retrieving revision 1.32
diff -r1.32 changes.html
150a151,182
> G++ supports the C++1y [[deprecated]]
> attribute modulo bugs in the underying [[gnu::deprecated]] attribute.  
> Classes
> and functions can be marked deprecated and 
> 
> 
>   
> class A {};
> int bar(int n)
> { return 42 + n - 1; }
> #if __cplusplus > 201103:
> class [[deprecated("A is deprecated in C++14; Use B instead")]] A;
> [[deprecated("bar is unsafe; use foo() instead")]]
> int bar(int n);
> 
> int foo(int n) { return 42 + n; }
> class B {};
> #endif
>   
>   
> G++ supports C++1y digit separators.
> Long numeric literals can be subdivided with a single quote ' to enhance 
> readability:
> 
>   int i = 1048576;
>   int j = 1'048'576;
>   int k = 0x10';
>   int m = 0'004'000'000;
>   int n = 0b0001''''';
> 
>   double x = 1.602'176'565e-19;
>   double y = 1.602'176'565e-1'9;
> 
>   
158a191,213
>  href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014";>
>Improved experimental support for the upcoming ISO C++ standard, 
> C++14,
>including:
>   
>  fixing constexpr member functions without 
> const; 
>  implementation of the exchange() utility function; 
> 
>  addressing tuples by type; 
>  implemention of make_unique; 
>  making std::result_of SFINAE-friendly; 
>  adding operator() to 
> integral_constant; 
>  adding user-defined literals for standard library types
>  string, chrono, and 
> complex; 
>  adding two range overloads to non-modifying sequence oprations; 
> 
>  adding IO manipulators for quoted strings; 
>  adding constexpr members to utilities, 
> complex,
>  chrono, and some containers; 
>  adding compile-time integer_sequences; 
>  adding cleaner transformation traits; 
>  adding a class for optional types; 
>  making functionals operator functors easier to use 
> and
>  more generic; 
>   
> 


Re: [wwwdocs] [C++14] Library and front-end additions

2013-11-10 Thread Ed Smith-Rowland

On 11/10/2013 11:54 AM, Jonathan Wakely wrote:

On 10 November 2013 16:52, Jonathan Wakely  wrote:

I thought I'd already made similar changes to gcc-4.9/changes.html for
the C++14 changes but I never committed it.  The only comment I have
is that "chrono" isn't a type, but the change is fine as far as I'm
concerned, thanks.

Oh, and optional isn't part of C++14.
Right. i guess there are interesting conversations to be had about how 
we document and flag all these TSs and constraints...

   Here's what I had, although it
doesn't mention all the changes:

Index: changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v
retrieving revision 1.31
diff -u -r1.31 changes.html
--- changes.html31 Oct 2013 18:03:28 -  1.31
+++ changes.html10 Nov 2013 16:53:19 -
@@ -142,8 +142,20 @@


  http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2011";>
-   Improved support for C++11, including support for .
+   Improved support for C++11, including support for
.
  
+Experimental support for most C++1y library features, including:
+  
+User-defined literals for strings, durations and complex
numbers.
+Additional overloads for std::equal,
std::mismatch
+and std::is_permutation.
+std::make_unique
+std::quoted
+std::shared_lock
+std::integer_sequence
+  
+
+An implementation of std::experimental::optional.
  The non-standard function std::copy_exception
has been deprecated
  and will be removed in a future version.
std::make_exception_ptr
  should be used instead.



OK, I folded our versions together.  Thank you.  I also fixed up my code 
examples.


OK?

Ed

Index: htdocs/projects/cxx1y.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.8
diff -r1.8 cxx1y.html
113,114c113,115
<   http://isocpp.org/files/papers/n3760.htm";>N3760
<   No
---
>href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html";>N3760
>   
> 4.9 (N3797)
118,119c119,121
<   http://isocpp.org/files/papers/N3781.pdf";>N3781
<   No
---
>href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf";>N3781
>   
> 4.9 (N3797)
Index: htdocs/gcc-4.9/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v
retrieving revision 1.32
diff -r1.32 changes.html
150a151,183
>   
> G++ supports the C++1y [[deprecated]]
> attribute modulo bugs in the underying [[gnu::deprecated]] attribute.  
> Classes
> and functions can be marked deprecated and 
> 
> class A;
> int bar(int n);
> #if __cplusplus > 201103
> class [[deprecated("A is deprecated in C++14; Use B instead")]] A;
> [[deprecated("bar is unsafe; use foo() instead")]]
> int bar(int n);
> 
> int foo(int n);
> class B;
> #endif
> A aa; // warning: 'A' is deprecated : A is deprecated in C++14; Use B instead
> int j = bar(2); // warning: 'int bar(int)' is deprecated : bar is unsafe; use 
> foo() instead
> 
>   
>   
> G++ supports C++1y digit separators.
> Long numeric literals can be subdivided with a single quote ' to enhance 
> readability:
> 
>   int i = 1048576;
>   int j = 1'048'576;
>   int k = 0x10';
>   int m = 0'004'000'000;
>   int n = 0b0001''''';
> 
>   double x = 1.602'176'565e-19;
>   double y = 1.602'176'565e-1'9;
> 
>   
157c190
.
---
>Improved support for C++11, including support for 
> .
158a192,217
>  href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014";>
>Improved experimental support for the upcoming ISO C++ standard, 
> C++14,
>including:
>   
>  fixing constexpr member functions without 
> const; 
>  implementation of the std::exchange() utility 
> function; 
>  addressing tuples by type; 
>  implemention of std::make_unique; 
>  implemention of std::shared_lock; 
>  making std::result_of SFINAE-friendly; 
>  adding operator() to 
> integral_constant; 
>  adding user-defined literals for standard library types
>  std::basic_string, 
> std::chrono::duration,
>  and std::complex; 
>  adding two range overloads to non-modifying sequence oprations
>  std::equal and std::mismatch; 
>  adding IO manipulators for quoted strings; 
>  adding constexpr members to 
> ,
>  , , and 
> some containers; 
>  adding compile-time std::integer_sequence; 
>  adding cleaner transformation traits; 
>  making s operator functors easier 

Re: [wwwdocs] [C++14] Library and front-end additions

2013-11-10 Thread Ed Smith-Rowland

On 11/10/2013 03:59 PM, Jonathan Wakely wrote:

On 10 November 2013 20:28, Ed Smith-Rowland wrote:

OK, I folded our versions together.  Thank you.  I also fixed up my code
examples.

OK?

That looks good, thanks very much for updating it.


OK, I got gcc-4.9/changes.html checked in (after some trouble).
Apparently I can't get projects/cxx1y.html checked in now.

Here is the patch.

Could someone else please check it and check it in?

Sorry.

Ed

Index: htdocs/projects/cxx1y.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.8
diff -r1.8 cxx1y.html
113,114c113,115
<   http://isocpp.org/files/papers/n3760.htm";>N3760
<   No
---
>href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html";>N3760
>   
> 4.9 (N3797)
118,119c119,121
<   http://isocpp.org/files/papers/N3781.pdf";>N3781
<   No
---
>href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf";>N3781
>   
> 4.9 (N3797)


Allow [[deprecated]] even for C++11 (with pedwarn)

2014-10-05 Thread Ed Smith-Rowland

Greetings,

There was some feeling that not allowing [[deprecated]] for C++ was a 
little extreme.


This patch builds and tests clean on x86_64-linux.  OK?

Ed


gcc/c-family:

2014-10-06  Edward Smith-Rowland  <3dw...@verizon.net>

* c-family/c-cppbuiltin.c: Move __cpp_attribute_deprecated to the
C++11 section.


gcc/cp:

2014-10-06  Edward Smith-Rowland  <3dw...@verizon.net>

* cp/parser.c: Allow [[deprecated]] for C++11.  Issue a pedwarn.


gcc/testsuite:

2014-10-06  Edward Smith-Rowland  <3dw...@verizon.net>

* g++.dg/cpp1y/attr-deprecated-neg.C: Attribute no longer ignored.
* g++.dg/cpp1y/feat-cxx11-neg.C: Comment out __cpp_attribute_deprecated 
test.
* g++.dg/cpp1y/feat-cxx11.C: Add __cpp_attribute_deprecated test.

Index: c-family/c-cppbuiltin.c
===
--- c-family/c-cppbuiltin.c (revision 215826)
+++ c-family/c-cppbuiltin.c (working copy)
@@ -828,6 +828,7 @@
  cpp_define (pfile, "__cpp_rvalue_reference=200610");
  cpp_define (pfile, "__cpp_variadic_templates=200704");
  cpp_define (pfile, "__cpp_alias_templates=200704");
+ cpp_define (pfile, "__cpp_attribute_deprecated=201309");
}
   if (cxx_dialect > cxx11)
{
@@ -841,7 +842,6 @@
  //cpp_define (pfile, "__cpp_aggregate_nsdmi=201304");
  cpp_define (pfile, "__cpp_variable_templates=201304");
  cpp_define (pfile, "__cpp_digit_separators=201309");
- cpp_define (pfile, "__cpp_attribute_deprecated=201309");
  //cpp_define (pfile, "__cpp_sized_deallocation=201309");
  /* We'll have to see where runtime arrays wind up.
 Let's put it in C++14 for now.  */
Index: cp/parser.c
===
--- cp/parser.c (revision 215826)
+++ cp/parser.c (working copy)
@@ -22211,8 +22211,14 @@
   if (is_attribute_p ("noreturn", attr_id))
TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
   /* C++14 deprecated attribute is equivalent to GNU's.  */
-  else if (cxx_dialect >= cxx14 && is_attribute_p ("deprecated", attr_id))
-   TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
+  else if (cxx_dialect >= cxx11 && is_attribute_p ("deprecated", attr_id))
+   {
+ if (cxx_dialect == cxx11)
+   pedwarn (token->location, OPT_Wpedantic,
+"% is a C++14 feature;"
+" use %");
+ TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
+   }
 }
 
   /* Now parse the optional argument clause of the attribute.  */
Index: testsuite/g++.dg/cpp1y/attr-deprecated-neg.C
===
--- testsuite/g++.dg/cpp1y/attr-deprecated-neg.C(revision 215826)
+++ testsuite/g++.dg/cpp1y/attr-deprecated-neg.C(working copy)
@@ -1,23 +1,24 @@
 // { dg-do compile { target c++11_only } }
+// { dg-options "-pedantic" }
 
-class [[deprecated]] A // { dg-warning "attribute directive ignored" }
+class [[deprecated]] A // { dg-warning "'deprecated' is a C..14 feature" }
 {
 };
 
-[[deprecated]]
+[[deprecated]] // { dg-warning "'deprecated' is a C..14 feature" }
 int
-foo(int n) // { dg-warning "attribute directive ignored" }
+foo(int n)
 {
   return 42 + n;
 }
 
-class [[deprecated("B has been superceded by C")]] B // { dg-warning 
"attribute directive ignored" }
+class [[deprecated("B has been superceded by C")]] B // { dg-warning 
"'deprecated' is a C..14 feature" }
 {
 };
 
-[[deprecated("bar is unsafe; use foobar instead")]]
+[[deprecated("bar is unsafe; use foobar instead")]] // { dg-warning 
"'deprecated' is a C..14 feature" }
 int
-bar(int n) // { dg-warning "attribute directive ignored" }
+bar(int n)
 {
   return 42 + n - 1;
 }
@@ -47,12 +48,12 @@
 int
 main()
 {
-  A aaa;
-  int n = foo(12);
+  A aaa; // { dg-warning "is deprecated" }
+  int n = foo(12); // { dg-warning "is deprecated" }
 
-  B bbb;
-  int m = bar(666);
+  B bbb; // { dg-warning "is deprecated" }
+  int m = bar(666); // { dg-warning "is deprecated" }
 
-  C ccc;
-  int l = foobar(8);
+  C ccc; // { dg-warning "is deprecated" "" { target { c++14 } } }
+  int l = foobar(8); // { dg-warning "is deprecated" "" { target { c++14 } } }
 }
Index: testsuite/g++.dg/cpp1y/feat-cxx11-neg.C
===
--- testsuite/g++.dg/cpp1y/feat-cxx11-neg.C (revision 215826)
+++ testsuite/g++.dg/cpp1y/feat-cxx11-neg.C (working copy)
@@ -31,9 +31,10 @@
 #  error "__cpp_digit_separators" // { dg-error "error" }
 #endif
 
-#ifndef __cpp_attribute_deprecated
-#  error "__cpp_attribute_deprecated" // { dg-error "error" }
-#endif
+//  Attribute [[deprecated]] is allowed in C++11 as an extension (with 
pedwarn).
+//#ifndef __cpp_attribute_deprecated
+//#  error "__cpp_attribute_deprecated"
+//#endif
 
 #ifndef __cpp_run

Re: [wwwdocs] Add feature-testing macros and std::is_final to gcc-5/changes.html

2014-10-07 Thread Ed Smith-Rowland

On 10/02/2014 10:24 AM, Jonathan Wakely wrote:

On 02/10/14 10:09 -0400, Ed Smith-Rowland wrote:

On 10/02/2014 06:14 AM, Jonathan Wakely wrote:

On 02/10/14 11:12 +0100, Jonathan Wakely wrote:

Note Ed's recent changes. Committed to CVS.


And fix a markup error that I expected xmllint to catch :-(
Thank you! I tried to do this and couldn't for permissions.  I'm 
probably not doing it right.


If I remember my cvs-fu you need CVS_RHS=ssh and use
CVSROOT=:ext:$u...@gcc.gnu.org:/cvs/gcc (with your sourceware.org
username as $USER) and then it should work over SSH just like svn and
git.

Anyway, the real thing I wanted to suggest is we put a line for 
C-family about the availability of __has_include and 
__has_include_next.  We could mention clang has it.


Good idea, I'm happy to commit a patch if you can prepare something.


OK, here is a patch for both using typename as a class key for template 
template parms and for __has_include, etc.

Are these too wordy?

Ed

Index: htdocs/gcc-5/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-5/changes.html,v
retrieving revision 1.14
diff -r1.14 changes.html
56a57,81
> New preprocessor constructs, __has_include_next
> and __has_include_next, to test the availability of 
> headers
> have been added.
> This demonstrates a way to include the header 
> <optional>
> only if it is available:
> 
> #ifdef __has_include
> #  if __has_include(<optional>)
> #include <optional>
> #define have_optional 1
> #  elif __has_include(<experimental/optional>)
> #include <experimental/optional>
> #define have_optional 1
> #define experimental_optional
> #  else
> #define have_optional 0
> #  endif
> #endif
> 
> The header search paths for __has_include_next
> and __has_include_next are equivalent to those
> of the standard directive #include
> and the extension #include_next respectively.
> 
> 
88a114,117
>   G++ now allows typename in a template template parameter.
> 
>   template<template<typename> typename X> struct D; // 
> OK
> 


Re: [4.9 PATCH, testsuite]: Fix g++.dg/cpp1y/feat-cxx14.C testsuite errors

2014-10-09 Thread Ed Smith-Rowland

On 10/09/2014 05:54 PM, Mike Stump wrote:

On Oct 9, 2014, at 11:56 AM, Uros Bizjak  wrote:

2014-10-09  Uros Bizjak  

* g++.dg/cpp1y/feat-cxx14.C: Variable templates not in yet.
(dg-do): Use c++1y target.

Tested on x86_64. OK for branch?

So, I need Ed or Jason to review it…


Yes, please put this in.
cxx14 was added to 5.0 and shadowed the error about variable templates.
Argh.

The patch is good.

Thank you all!
Ed



Re: [C++11, C++14 PATCH 2/3] Support for SD-6: SG10 Feature Test Recommendations - c-family and testsuite

2014-06-02 Thread Ed Smith-Rowland

On 06/02/2014 10:31 AM, Jason Merrill wrote:

On 05/31/2014 02:30 AM, Marc Glisse wrote:

Also, I am pretty sure that gcc doesn't support the latest constexpr, we
shouldn't define those macros lightly.


That's correct.  We should leave __cpp_constexpr at 200704 for now.
Right...  That was a testing thing I left in by accident to make sure 
supercedance would work.  Commented out. ;-)



I think having __has_include for all languages is fine since it is
already in the implementation defined namespace.


Agreed.  These macros should be defined if the feature is supported.

I now have these for all C/C++ versions.  When I implemented these I 
thought "Why the heck hasn't the preprocessor had these for 20 years..."
Similarly, features of later standards that we implement in earlier 
conformance modes as extensions (specifically, init-captures and 
binary literals) should have the appropriate macros defined.

Very good idea...
I'll research these. unless someone has a little list somewhere...?


Jason






Re: [PATCH, PR C++/61038] - g++ -E is unusable with UDL strings

2014-06-05 Thread Ed Smith-Rowland

On 05/20/2014 04:44 PM, Jason Merrill wrote:

On 05/13/2014 08:59 PM, Ed Smith-Rowland wrote:

+  escape_it = escape_it || cpp_userdef_string_p (token->type)
+|| cpp_userdef_char_p (token->type);


Let's add the new cases to the previous statement instead of a new 
one.  OK with that change.


Jason



PR c++/61038
I was asked to combine the escape logic for regular chars and strings
with the escape logic for user-defined literals chars and strings.
I just forgot the first time.

After rebuilding and testing committed as obvious.

ed@bad-horse:~/gcc_literal$ svn diff -rPREV  libcpp/ChangeLog 
libcpp/macro.c

Index: libcpp/ChangeLog
===
--- libcpp/ChangeLog(revision 211266)
+++ libcpp/ChangeLog(working copy)
@@ -1,3 +1,9 @@
+2014-06-04  Edward Smith-Rowland  <3dw...@verizon.net>
+
+PR c++/61038
+* macro.c (stringify_arg (cpp_reader *, macro_arg *)):
+Combine user-defined escape logic with the other string and char logic.
+
 2014-05-26  Richard Biener  

 * configure.ac: Remove long long and __int64 type checks,
Index: libcpp/macro.c
===
--- libcpp/macro.c(revision 211265)
+++ libcpp/macro.c(working copy)
@@ -492,11 +492,10 @@
|| token->type == CPP_WSTRING || token->type == CPP_WCHAR
|| token->type == CPP_STRING32 || token->type == CPP_CHAR32
|| token->type == CPP_STRING16 || token->type == CPP_CHAR16
-   || token->type == CPP_UTF8STRING);
+   || token->type == CPP_UTF8STRING
+   || cpp_userdef_string_p (token->type)
+   || cpp_userdef_char_p (token->type));

-  escape_it = escape_it || cpp_userdef_string_p (token->type)
-|| cpp_userdef_char_p (token->type);
-
   /* Room for each char being written in octal, initial space and
  final quote and NUL.  */
   len = cpp_token_len (token);



Re: std::quoted doesn't respect padding

2014-06-05 Thread Ed Smith-Rowland

On 04/01/2014 07:33 AM, Jonathan Wakely wrote:

[CCing gcc-patches]

On 11/03/14 11:18 -0400, Ed Smith-Rowland wrote:

On 02/14/2014 07:56 PM, Jonathan Wakely wrote:

We need to implement this fix (probably after 4.9 is released though)

http://cplusplus.github.io/LWG/lwg-active.html#2344


Here is a patch (Stage 1 obviously).


A couple of things I didn't notice earlier ...


Index: include/std/iomanip
===
--- include/std/iomanip(revision 208430)
+++ include/std/iomanip(working copy)
@@ -41,6 +41,7 @@

#if __cplusplus >= 201103L
#include 
+#include  // used in quoted.


We really only need  for __cplusplus > 201103L, otherwise we
include it unnecessarily for C++11.



-return __os;
+return __os << __ostr.str();
  }


It should be slightly more efficient to do __os << __ostr.rdbuf() here,
and in the other operator<< overload, since that copies directly from
the stringbuf to __os's own streambuf, rather than creating a
temporary std::string and copying from that.



Sorry for the hiatus...

Here is a new patch with issues fixed.

OK if it passes testing on x86_64-linux?

Ed

2014-06-05  Ed Smith-Rowland  <3dw...@verizon.net>

DR 2344 - std::quoted doesn't respect padding
* include/std/iomanip: Allow for padding in quoted inserters.
* testsuite/27_io/manipulators/standard/char/dr2344.cc: New.
* testsuite/27_io/manipulators/standard/wchar_t/dr2344.cc: New.

Index: include/std/iomanip
===
--- include/std/iomanip (revision 211281)
+++ include/std/iomanip (working copy)
@@ -41,7 +41,10 @@
 
 #if __cplusplus >= 201103L
 #include 
+#if __cplusplus > 201103L
+#include  // used in quoted.
 #endif
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -342,7 +345,6 @@
 
 /**
  * @brief Struct for delimited strings.
- *The left and right delimiters can be different.
  */
 template
   struct _Quoted_string
@@ -364,8 +366,10 @@
   };
 
 /**
- * @brief Inserter for delimited strings.
- *The left and right delimiters can be different.
+ * @brief Inserter for quoted strings.
+ *
+ *  _GLIBCXX_RESOLVE_LIB_DEFECTS
+ *  DR 2344 quoted()'s interaction with padding is unclear
  */
 template
   auto&
@@ -372,21 +376,24 @@
   operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 const _Quoted_string& __str)
   {
-   __os << __str._M_delim;
+   std::basic_ostringstream<_CharT, _Traits> __ostr;
+   __ostr << __str._M_delim;
for (const _CharT* __c = __str._M_string; *__c; ++__c)
  {
if (*__c == __str._M_delim || *__c == __str._M_escape)
- __os << __str._M_escape;
-   __os << *__c;
+ __ostr << __str._M_escape;
+   __ostr << *__c;
  }
-   __os << __str._M_delim;
+   __ostr << __str._M_delim;
 
-   return __os;
+   return __os << __ostr.rdbuf();
   }
 
 /**
- * @brief Inserter for delimited strings.
- *The left and right delimiters can be different.
+ * @brief Inserter for quoted strings.
+ *
+ *  _GLIBCXX_RESOLVE_LIB_DEFECTS
+ *  DR 2344 quoted()'s interaction with padding is unclear
  */
 template
   auto&
@@ -393,16 +400,17 @@
   operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 const _Quoted_string<_String, _CharT>& __str)
   {
-   __os << __str._M_delim;
+   std::basic_ostringstream<_CharT, _Traits> __ostr;
+   __ostr << __str._M_delim;
for (auto& __c : __str._M_string)
  {
if (__c == __str._M_delim || __c == __str._M_escape)
- __os << __str._M_escape;
-   __os << __c;
+ __ostr << __str._M_escape;
+   __ostr << __c;
  }
-   __os << __str._M_delim;
+   __ostr << __str._M_delim;
 
-   return __os;
+   return __os << __ostr.rdbuf();
   }
 
 /**
Index: testsuite/27_io/manipulators/standard/char/dr2344.cc
===
--- testsuite/27_io/manipulators/standard/char/dr2344.cc(revision 0)
+++ testsuite/27_io/manipulators/standard/char/dr2344.cc(working copy)
@@ -0,0 +1,50 @@
+// { dg-do run }
+// { dg-options "-std=gnu++14" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your 

Re: std::quoted doesn't respect padding

2014-06-06 Thread Ed Smith-Rowland

On 06/05/2014 11:48 AM, Jonathan Wakely wrote:

On 05/06/14 11:43 -0400, Ed Smith-Rowland wrote:

On 04/01/2014 07:33 AM, Jonathan Wakely wrote:

[CCing gcc-patches]

On 11/03/14 11:18 -0400, Ed Smith-Rowland wrote:

On 02/14/2014 07:56 PM, Jonathan Wakely wrote:

We need to implement this fix (probably after 4.9 is released though)

http://cplusplus.github.io/LWG/lwg-active.html#2344


Here is a patch (Stage 1 obviously).


A couple of things I didn't notice earlier ...


Index: include/std/iomanip
===
--- include/std/iomanip(revision 208430)
+++ include/std/iomanip(working copy)
@@ -41,6 +41,7 @@

#if __cplusplus >= 201103L
#include 
+#include  // used in quoted.


We really only need  for __cplusplus > 201103L, otherwise we
include it unnecessarily for C++11.



-return __os;
+return __os << __ostr.str();
 }


It should be slightly more efficient to do __os << __ostr.rdbuf() here,
and in the other operator<< overload, since that copies directly from
the stringbuf to __os's own streambuf, rather than creating a
temporary std::string and copying from that.



Sorry for the hiatus...

Here is a new patch with issues fixed.

OK if it passes testing on x86_64-linux?


Great, OK for trunk and 4.9 too, I think.

Thanks!




The rdbuf version fails.
The compare asserts fail and

  //  Should be: ["AB \"CD\" EF"xx]
  //  Gives: ["AB \"CD\" EF"xx]
  std::cout << "[" << std::left << std::setfill('x') << std::setw(20) 
<< R"("AB \"CD\" EF")" << "]" << std::endl;

  //  Should be: ["GH \"IJ\" KL"yy]
  //  Gives: ["yyyGH \"IJ\" KL"]
  std::cout << "[" << std::left << std::setfill('y') << std::setw(20) 
<< std::quoted(R"(GH "IJ" KL)") << "]" << std::endl;


This prints
["AB \"CD\" EF"xx]
[

No newline on the second line - just the '['.
I'll look at rdbuf. Error in rdbuf? Do I need to do something?

Failing that we know str() works even though it is inefficient.

Ed



Re: std::quoted doesn't respect padding

2014-06-06 Thread Ed Smith-Rowland

On 06/06/2014 10:27 AM, Jonathan Wakely wrote:

On 06/06/14 10:08 -0400, Ed Smith-Rowland wrote:

I'll look at rdbuf. Error in rdbuf? Do I need to do something?


No, just me being dumb. The ostream::operator<<(streambuf*) overload
behaves as an unformatted output function, so won't obey the padding,
which is exactly what you're trying to fix.  Sorry for suggesting it.



As committed..

I'll backport to 4.9 tomorrow or Sunday.

2014-06-06  Ed Smith-Rowland  <3dw...@verizon.net>

DR 2344 - std::quoted doesn't respect padding
* include/std/iomanip: Allow for padding in quoted inserters.
* testsuite/27_io/manipulators/standard/char/dr2344.cc: New.
* testsuite/27_io/manipulators/standard/wchar_t/dr2344.cc: New.

Index: include/std/iomanip
===
--- include/std/iomanip (revision 211313)
+++ include/std/iomanip (working copy)
@@ -41,7 +41,10 @@
 
 #if __cplusplus >= 201103L
 #include 
+#if __cplusplus > 201103L
+#include  // used in quoted.
 #endif
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -342,7 +345,6 @@
 
 /**
  * @brief Struct for delimited strings.
- *The left and right delimiters can be different.
  */
 template
   struct _Quoted_string
@@ -364,8 +366,10 @@
   };
 
 /**
- * @brief Inserter for delimited strings.
- *The left and right delimiters can be different.
+ * @brief Inserter for quoted strings.
+ *
+ *  _GLIBCXX_RESOLVE_LIB_DEFECTS
+ *  DR 2344 quoted()'s interaction with padding is unclear
  */
 template
   auto&
@@ -372,21 +376,24 @@
   operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 const _Quoted_string& __str)
   {
-   __os << __str._M_delim;
+   std::basic_ostringstream<_CharT, _Traits> __ostr;
+   __ostr << __str._M_delim;
for (const _CharT* __c = __str._M_string; *__c; ++__c)
  {
if (*__c == __str._M_delim || *__c == __str._M_escape)
- __os << __str._M_escape;
-   __os << *__c;
+ __ostr << __str._M_escape;
+   __ostr << *__c;
  }
-   __os << __str._M_delim;
+   __ostr << __str._M_delim;
 
-   return __os;
+   return __os << __ostr.str();
   }
 
 /**
- * @brief Inserter for delimited strings.
- *The left and right delimiters can be different.
+ * @brief Inserter for quoted strings.
+ *
+ *  _GLIBCXX_RESOLVE_LIB_DEFECTS
+ *  DR 2344 quoted()'s interaction with padding is unclear
  */
 template
   auto&
@@ -393,16 +400,17 @@
   operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 const _Quoted_string<_String, _CharT>& __str)
   {
-   __os << __str._M_delim;
+   std::basic_ostringstream<_CharT, _Traits> __ostr;
+   __ostr << __str._M_delim;
for (auto& __c : __str._M_string)
  {
if (__c == __str._M_delim || __c == __str._M_escape)
- __os << __str._M_escape;
-   __os << __c;
+ __ostr << __str._M_escape;
+   __ostr << __c;
  }
-   __os << __str._M_delim;
+   __ostr << __str._M_delim;
 
-   return __os;
+   return __os << __ostr.str();
   }
 
 /**
Index: testsuite/27_io/manipulators/standard/char/dr2344.cc
===
--- testsuite/27_io/manipulators/standard/char/dr2344.cc(revision 0)
+++ testsuite/27_io/manipulators/standard/char/dr2344.cc(working copy)
@@ -0,0 +1,50 @@
+// { dg-do run }
+// { dg-options "-std=gnu++14" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.6 - Quoted manipulators[quoted.manip]
+
+#include 
+#include 
+#include 
+
+void
+test01()
+{
+  bool test [[gnu::unused]] = true;
+
+  std::ostringstream ssx;
+  ssx << "[" << std::left << std::setfill('x') << std::set

[4.9] Re: std::quoted doesn't respect padding - backport from trunk.

2014-06-07 Thread Ed Smith-Rowland

On 06/06/2014 11:41 PM, Ed Smith-Rowland wrote:

On 06/06/2014 10:27 AM, Jonathan Wakely wrote:

On 06/06/14 10:08 -0400, Ed Smith-Rowland wrote:

I'll look at rdbuf. Error in rdbuf? Do I need to do something?


No, just me being dumb. The ostream::operator<<(streambuf*) overload
behaves as an unformatted output function, so won't obey the padding,
which is exactly what you're trying to fix.  Sorry for suggesting it.



As committed..

I'll backport to 4.9 tomorrow or Sunday.


This tested clean on gcc-4.9 as expected.
I just noted backport in the ChangeLog.

2014-06-07  Ed Smith-Rowland  <3dw...@verizon.net>

DR 2344 - std::quoted doesn't respect padding
* include/std/iomanip: Allow for padding in quoted inserters.
* testsuite/27_io/manipulators/standard/char/dr2344.cc: New.
* testsuite/27_io/manipulators/standard/wchar_t/dr2344.cc: New.

Index: include/std/iomanip
===
--- include/std/iomanip (revision 211313)
+++ include/std/iomanip (working copy)
@@ -41,7 +41,10 @@
 
 #if __cplusplus >= 201103L
 #include 
+#if __cplusplus > 201103L
+#include  // used in quoted.
 #endif
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -342,7 +345,6 @@
 
 /**
  * @brief Struct for delimited strings.
- *The left and right delimiters can be different.
  */
 template
   struct _Quoted_string
@@ -364,8 +366,10 @@
   };
 
 /**
- * @brief Inserter for delimited strings.
- *The left and right delimiters can be different.
+ * @brief Inserter for quoted strings.
+ *
+ *  _GLIBCXX_RESOLVE_LIB_DEFECTS
+ *  DR 2344 quoted()'s interaction with padding is unclear
  */
 template
   auto&
@@ -372,21 +376,24 @@
   operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 const _Quoted_string& __str)
   {
-   __os << __str._M_delim;
+   std::basic_ostringstream<_CharT, _Traits> __ostr;
+   __ostr << __str._M_delim;
for (const _CharT* __c = __str._M_string; *__c; ++__c)
  {
if (*__c == __str._M_delim || *__c == __str._M_escape)
- __os << __str._M_escape;
-   __os << *__c;
+ __ostr << __str._M_escape;
+   __ostr << *__c;
  }
-   __os << __str._M_delim;
+   __ostr << __str._M_delim;
 
-   return __os;
+   return __os << __ostr.str();
   }
 
 /**
- * @brief Inserter for delimited strings.
- *The left and right delimiters can be different.
+ * @brief Inserter for quoted strings.
+ *
+ *  _GLIBCXX_RESOLVE_LIB_DEFECTS
+ *  DR 2344 quoted()'s interaction with padding is unclear
  */
 template
   auto&
@@ -393,16 +400,17 @@
   operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 const _Quoted_string<_String, _CharT>& __str)
   {
-   __os << __str._M_delim;
+   std::basic_ostringstream<_CharT, _Traits> __ostr;
+   __ostr << __str._M_delim;
for (auto& __c : __str._M_string)
  {
if (__c == __str._M_delim || __c == __str._M_escape)
- __os << __str._M_escape;
-   __os << __c;
+ __ostr << __str._M_escape;
+   __ostr << __c;
  }
-   __os << __str._M_delim;
+   __ostr << __str._M_delim;
 
-   return __os;
+   return __os << __ostr.str();
   }
 
 /**
Index: testsuite/27_io/manipulators/standard/char/dr2344.cc
===
--- testsuite/27_io/manipulators/standard/char/dr2344.cc(revision 0)
+++ testsuite/27_io/manipulators/standard/char/dr2344.cc(working copy)
@@ -0,0 +1,50 @@
+// { dg-do run }
+// { dg-options "-std=gnu++14" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.6 - Quoted manipulators[quoted.manip]
+
+#include 
+#include 
+#include 
+
+void
+test01()
+{
+  bool test [[gnu::unused]] = tr

[C++11, C++14 PATCH 1/4] Support for SD-6: SG10 Feature Test Recommendations: libcpp

2014-06-09 Thread Ed Smith-Rowland

This is the second round of the SD-6 support series.
I believe I have answered everyones concerns.

Built and tested on x86_64-linux.

OK?

2014-06-09  Ed Smith-Rowland  <3dw...@verizon.net>

Implement SD-6: SG10 Feature Test Recommendations
* directives.c: Support __has_include__ builtin.
* expr.c (parse_has_include): New function to parse __has_include__
builtin; (eval_token()): Use it.
* files.c (_cpp_has_header()): New funtion to look for header;
(open_file_failed()): Not an error to not find a header file for
__has_include__.
* identifiers.c (_cpp_init_hashtable()): Add entry for __has_include__.
* internal.h (lexer_state, spec_nodes): Add in__has_include__.
* pch.c (cpp_read_state): Lookup __has_include__.
* traditional.c (enum ls, _cpp_scan_out_logical_line()): Walk through
__has_include__ statements.
Index: internal.h
===
--- internal.h  (revision 211354)
+++ internal.h  (working copy)
@@ -258,6 +258,9 @@
   /* Nonzero when parsing arguments to a function-like macro.  */
   unsigned char parsing_args;
 
+  /* Nonzero to prevent macro expansion.  */
+  unsigned char in__has_include__;
+
   /* Nonzero if prevent_expansion is true only because output is
  being discarded.  */
   unsigned char discarding_output;
@@ -279,6 +282,8 @@
   cpp_hashnode *n_true;/* C++ keyword true */
   cpp_hashnode *n_false;   /* C++ keyword false */
   cpp_hashnode *n__VA_ARGS__;  /* C99 vararg macros */
+  cpp_hashnode *n__has_include__;  /* __has_include__ operator */
+  cpp_hashnode *n__has_include_next__; /* __has_include_next__ operator */
 };
 
 typedef struct _cpp_line_note _cpp_line_note;
@@ -645,6 +650,8 @@
 extern bool _cpp_read_file_entries (cpp_reader *, FILE *);
 extern const char *_cpp_get_file_name (_cpp_file *);
 extern struct stat *_cpp_get_file_stat (_cpp_file *);
+extern bool _cpp_has_header (cpp_reader *, const char *, int,
+enum include_type);
 
 /* In expr.c */
 extern bool _cpp_parse_expr (cpp_reader *, bool);
@@ -680,6 +687,7 @@
 extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
 linenum_type, unsigned int);
 extern void _cpp_pop_buffer (cpp_reader *);
+extern char *_cpp_bracket_include (cpp_reader *);
 
 /* In directives.c */
 struct _cpp_dir_only_callbacks
Index: directives.c
===
--- directives.c(revision 211354)
+++ directives.c(working copy)
@@ -549,6 +549,11 @@
   if (is_def_or_undef && node == pfile->spec_nodes.n_defined)
cpp_error (pfile, CPP_DL_ERROR,
   "\"defined\" cannot be used as a macro name");
+  else if (is_def_or_undef
+   && (node == pfile->spec_nodes.n__has_include__
+|| node == pfile->spec_nodes.n__has_include_next__))
+   cpp_error (pfile, CPP_DL_ERROR,
+  "\"__has_include__\" cannot be used as a macro name");
   else if (! (node->flags & NODE_POISONED))
return node;
 }
@@ -2601,3 +2606,12 @@
   node->directive_index = i;
 }
 }
+
+/* Extract header file from a bracket include. Parsing starts after '<'.
+   The string is malloced and must be freed by the caller.  */
+char *
+_cpp_bracket_include(cpp_reader *pfile)
+{
+  return glue_header_name (pfile);
+}
+
Index: expr.c
===
--- expr.c  (revision 211354)
+++ expr.c  (working copy)
@@ -64,6 +64,8 @@
 static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
 static void check_promotion (cpp_reader *, const struct op *);
 
+static cpp_num parse_has_include (cpp_reader *, enum include_type);
+
 /* Token type abuse to create unary plus and minus operators.  */
 #define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1))
 #define CPP_UMINUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 2))
@@ -1041,6 +1043,10 @@
 case CPP_NAME:
   if (token->val.node.node == pfile->spec_nodes.n_defined)
return parse_defined (pfile);
+  else if (token->val.node.node == pfile->spec_nodes.n__has_include__)
+   return parse_has_include (pfile, IT_INCLUDE);
+  else if (token->val.node.node == pfile->spec_nodes.n__has_include_next__)
+   return parse_has_include (pfile, IT_INCLUDE_NEXT);
   else if (CPP_OPTION (pfile, cplusplus)
   && (token->val.node.node == pfile->spec_nodes.n_true
   || token->val.node.node == pfile->spec_nodes.n_false))
@@ -2065,3 +2071,71 @@
 
   return lhs;
 }
+
+/* Handle meeting "__has_include__" in a preprocessor expression.  */
+static cpp_num
+parse_has_include (cpp_reader *pfi

[C++11, C++14 PATCH 2/4] Support for SD-6: SG10 Feature Test Recommendations: gcc/c-family

2014-06-09 Thread Ed Smith-Rowland

This is the second round of the SD-6 support series.
I believe I have answered everyones concerns.

Built and tested on x86_64-linux.

OK?


2014-06-09  Ed Smith-Rowland  <3dw...@verizon.net>

Implement SD-6: SG10 Feature Test Recommendations
* c-cppbuiltin.c (c_cpp_builtins()): Define language feature
macros and the __has_header macro.

Index: c-cppbuiltin.c
===
--- c-cppbuiltin.c  (revision 211354)
+++ c-cppbuiltin.c  (working copy)
@@ -794,6 +794,12 @@
   /* For stddef.h.  They require macros defined in c-common.c.  */
   c_stddef_cpp_builtins ();
 
+  /* Set feature test macros for all C/C++ (not for just C++11 etc.)
+ the builtins __has_include__ and __has_include_next__ are defined
+ int libcpp.  */
+  cpp_define (pfile, "__has_include(STR)=__has_include__(STR)");
+  cpp_define (pfile, "__has_include_next(STR)=__has_include_next__(STR)");
+
   if (c_dialect_cxx ())
 {
   if (flag_weak && SUPPORTS_ONE_ONLY)
@@ -805,7 +811,40 @@
   if (flag_rtti)
cpp_define (pfile, "__GXX_RTTI");
   if (cxx_dialect >= cxx11)
-cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
+   {
+  cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
+
+ /* Set feature test macros for C++11  */
+ cpp_define (pfile, "__cpp_unicode_characters=200704");
+ cpp_define (pfile, "__cpp_raw_strings=200710");
+ cpp_define (pfile, "__cpp_unicode_literals=200710");
+ cpp_define (pfile, "__cpp_user_defined_literals=200809");
+ cpp_define (pfile, "__cpp_lambdas=200907");
+ cpp_define (pfile, "__cpp_constexpr=200704");
+ cpp_define (pfile, "__cpp_static_assert=200410");
+ cpp_define (pfile, "__cpp_decltype=200707");
+ cpp_define (pfile, "__cpp_attributes=200809");
+ cpp_define (pfile, "__cpp_rvalue_reference=200610");
+ cpp_define (pfile, "__cpp_variadic_templates=200704");
+ cpp_define (pfile, "__cpp_alias_templates=200704");
+   }
+  if (cxx_dialect > cxx11)
+   {
+ /* Set feature test macros for C++14  */
+ cpp_define (pfile, "__cpp_binary_literals=201304");
+ cpp_define (pfile, "__cpp_init_captures=201304");
+ cpp_define (pfile, "__cpp_generic_lambdas=201304");
+ //cpp_undef (pfile, "__cpp_constexpr");
+ //cpp_define (pfile, "__cpp_constexpr=201304");
+ cpp_define (pfile, "__cpp_decltype_auto=201304");
+ cpp_define (pfile, "__cpp_return_type_deduction=201304");
+ cpp_define (pfile, "__cpp_runtime_arrays=201304");
+ //cpp_define (pfile, "__cpp_aggregate_nsdmi=201304");
+ //cpp_define (pfile, "__cpp_variable_templates=201304");
+ cpp_define (pfile, "__cpp_digit_separators=201309");
+ cpp_define (pfile, "__cpp_attribute_deprecated=201309");
+ //cpp_define (pfile, "__cpp_sized_deallocation=201309");
+   }
 }
   /* Note that we define this for C as well, so that we know if
  __attribute__((cleanup)) will interface with EH.  */


[C++11, C++14 PATCH 3/4] Support for SD-6: SG10 Feature Test Recommendations: libstdc++-v3

2014-06-09 Thread Ed Smith-Rowland

This is the second round of the SD-6 support series.
I believe I have answered everyones concerns.
Several test suite adjustments were added.

Built and tested on x86_64-linux.

OK?

2014-06-09  Ed Smith-Rowland  <3dw...@verizon.net>

Implement SD-6: SG10 Feature Test Recommendations
* include/bits/basic_string.h: Add __cpp_lib feature test macro.
* include/bits/stl_algobase.h: Ditto.
* include/bits/stl_function.h: Ditto.
* include/bits/unique_ptr.h: Ditto.
* include/std/array: Ditto.
* include/std/chrono: Ditto.
* include/std/complex: Ditto.
* include/std/iomanip: Ditto.
* include/std/mutex: Ditto.
* include/std/shared_mutex: Ditto.
* include/std/tuple: Ditto.
* include/std/type_traits: Ditto.
* include/std/utility: Ditto.
* testsuite/experimental/feat-cxx14.cc: New.
* testsuite/experimental/feat-lib-fund.cc: New.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
* testsuite/20_util/duration/literals/range.cc: Adjust.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Adjust.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Adjust.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Adjust.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
Adjust.

Index: include/bits/basic_string.h
===
--- include/bits/basic_string.h (revision 211363)
+++ include/bits/basic_string.h (working copy)
@@ -3124,6 +3124,8 @@
 
 #if __cplusplus > 201103L
 
+#define __cpp_lib_string_udls 201304
+
   inline namespace literals
   {
   inline namespace string_literals
Index: include/bits/stl_algobase.h
===
--- include/bits/stl_algobase.h (revision 211363)
+++ include/bits/stl_algobase.h (working copy)
@@ -1091,6 +1091,7 @@
 }
 
 #if __cplusplus > 201103L
+#define __cpp_lib_robust_nonmodifying_seq_ops 201304
   /**
*  @brief Tests a range for element-wise equality.
*  @ingroup non_mutating_algorithms
Index: include/bits/stl_function.h
===
--- include/bits/stl_function.h (revision 211363)
+++ include/bits/stl_function.h (working copy)
@@ -217,6 +217,10 @@
 };
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_transparent_operators 201210
+#define __cpp_lib_generic_associative_lookup 201304
+
   template<>
 struct plus
 {
Index: include/bits/unique_ptr.h
===
--- include/bits/unique_ptr.h   (revision 211363)
+++ include/bits/unique_ptr.h   (working copy)
@@ -743,6 +743,9 @@
 };
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_make_unique 201304
+
   template
 struct _MakeUniq
 { typedef unique_ptr<_Tp> __single_object; };
Index: include/std/array
===
--- include/std/array   (revision 211363)
+++ include/std/array   (working copy)
@@ -35,6 +35,9 @@
 # include 
 #else
 
+#undef __cpp_lib_constexpr_functions
+#define __cpp_lib_constexpr_functions 201210
+
 #include 
 #include 
 #include 
Index: include/std/chrono
===
--- include/std/chrono  (revision 211363)
+++ include/std/chrono  (working copy)
@@ -43,6 +43,9 @@
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
 
+#undef __cpp_lib_constexpr_functions
+#define __cpp_lib_constexpr_functions 201210
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
   /**
@@ -782,6 +785,8 @@
 
 #if __cplusplus > 201103L
 
+#define __cpp_lib_chrono_udls 201304
+
   inline namespace literals
   {
   inline namespace chrono_literals
Index: include/std/complex
===
--- include/std/complex (revision 211363)
+++ include/std/complex (working copy)
@@ -1929,6 +1929,8 @@
 inline namespace literals {
 inline namespace complex_literals {
 
+#define __cpp_lib_complex_udls 201309
+
   constexpr std::complex
   operator""if(long double __num)
   { return std::complex{0.0F, static_cast(__num)}; }
Index: include/std/iomanip
===
--- include/std/iomanip (revision 211363)
+++ include/std/iomanip (working copy)
@@ -339,6 +339,8 @@
 
 #if __cplusplus > 201103L
 
+#define __cpp_lib_quoted_string_io 201304
+
 _GLIBCXX_END_NAMESPACE_VERSION
   namespace __detail {
   _GLIBCXX_BEGIN_NAMESPACE_VERSION
Index: include/std/mutex
==

[C++11, C++14 PATCH 4/4] Support for SD-6: SG10 Feature Test Recommendations: gcc/testsuite

2014-06-09 Thread Ed Smith-Rowland

This is the second round of the SD-6 support series.
I believe I have answered everyones concerns.

Built and tested on x86_64-linux.

OK?


libstdc++:

2014-06-09  Ed Smith-Rowland  <3dw...@verizon.net>

Implement SD-6: SG10 Feature Test Recommendations
* g++.dg/cpp1y/feat-cxx11-neg.C: New.
* g++.dg/cpp1y/feat-cxx11.C: New.
* g++.dg/cpp1y/feat-cxx14-neg.C: New.
* g++.dg/cpp1y/feat-cxx14.C: New.
* g++.dg/cpp1y/phoobhar.h: New.
* g++.dg/cpp1y/testinc/phoobhar.h: New.
* g++.dg/cpp1y/testinc/phoobhar.h: New.

Index: g++.dg/cpp1y/feat-cxx11-neg.C
===
--- g++.dg/cpp1y/feat-cxx11-neg.C   (revision 0)
+++ g++.dg/cpp1y/feat-cxx11-neg.C   (working copy)
@@ -0,0 +1,35 @@
+// { dg-do compile { target c++11_only } }
+
+// These *are* defined in C++14 onwards.
+
+#ifndef __cpp_binary_literals
+#  error "__cpp_binary_literals" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_init_captures
+#  error "__cpp_init_captures" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_generic_lambdas
+#  error "__cpp_generic_lambdas" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_decltype_auto
+#  error "__cpp_decltype_auto" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_return_type_deduction
+#  error "__cpp_return_type_deduction" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_runtime_arrays
+#  error "__cpp_runtime_arrays" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_digit_separators
+#  error "__cpp_digit_separators" // { dg-error "error" }
+#endif
+
+#ifndef __cpp_attribute_deprecated
+#  error "__cpp_attribute_deprecated" // { dg-error "error" }
+#endif
Index: g++.dg/cpp1y/feat-cxx11.C
===
--- g++.dg/cpp1y/feat-cxx11.C   (revision 0)
+++ g++.dg/cpp1y/feat-cxx11.C   (working copy)
@@ -0,0 +1,73 @@
+// { dg-do compile { target c++11_only } }
+
+#ifndef __cpp_unicode_characters
+#  error "__cpp_unicode_characters"
+#elif  __cpp_unicode_characters != 200704
+#  error "__cpp_unicode_characters != 200704"
+#endif
+
+#ifndef __cpp_raw_strings
+#  error "__cpp_raw_strings"
+#elif  __cpp_raw_strings != 200710
+#  error "__cpp_raw_strings != 200710"
+#endif
+
+#ifndef __cpp_unicode_literals
+#  error "__cpp_unicode_literals"
+#elif  __cpp_unicode_literals != 200710
+#  error "__cpp_unicode_literals != 200710"
+#endif
+
+#ifndef __cpp_user_defined_literals
+#  error "__cpp_user_defined_literals"
+#elif  __cpp_user_defined_literals != 200809
+#  error "__cpp_user_defined_literals != 200809"
+#endif
+
+#ifndef __cpp_lambdas
+#  error "__cpp_lambdas"
+#elif  __cpp_lambdas != 200907
+#  error "__cpp_lambdas != 200907"
+#endif
+
+#ifndef __cpp_constexpr
+#  error "__cpp_constexpr"
+#elif  __cpp_constexpr != 200704
+#  error "__cpp_constexpr != 200704"
+#endif
+
+#ifndef __cpp_static_assert
+#  error "__cpp_static_assert"
+#elif  __cpp_static_assert != 200410
+#  error "__cpp_static_assert != 200410"
+#endif
+
+#ifndef __cpp_decltype
+#  error "__cpp_decltype"
+#elif  __cpp_decltype != 200707
+#  error "__cpp_decltype != 200707"
+#endif
+
+#ifndef __cpp_attributes
+#  error "__cpp_attributes"
+#elif  __cpp_attributes != 200809
+#  error "__cpp_attributes != 200809"
+#endif
+
+#ifndef __cpp_rvalue_reference
+#  error "__cpp_rvalue_reference"
+#elif  __cpp_rvalue_reference != 200610
+#  error "__cpp_rvalue_reference != 200610"
+#endif
+
+#ifndef __cpp_variadic_templates
+#  error "__cpp_variadic_templates"
+#elif  __cpp_variadic_templates != 200704
+#  error "__cpp_variadic_templates != 200704"
+#endif
+
+#ifndef __cpp_alias_templates
+#  error "__cpp_alias_templates"
+#elif  __cpp_alias_templates != 200704
+#  error "__cpp_alias_templates != 200704"
+#endif
Index: g++.dg/cpp1y/feat-cxx14-neg.C
===
--- g++.dg/cpp1y/feat-cxx14-neg.C   (revision 0)
+++ g++.dg/cpp1y/feat-cxx14-neg.C   (working copy)
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++1y } }
+
+//  TODO: Change != to == when C++14 constexpr goes in.
+#ifndef __cpp_constexpr
+#  error "__cpp_constexpr"
+#elif __cpp_constexpr != 200704
+#  error "__cpp_constexpr != 200704" // { dg-error "error" }
+#endif
Index: g++.dg/cpp1y/feat-cxx14.C
===
--- g++.dg/cpp1y/feat-cxx14.C   (revision 0)
+++ g++.dg/cpp1y/feat-cxx14.C   (working copy)
@@ -0,0 +1,187 @@
+// { dg-do compile { target c++1y } }
+// { dg-options "-I . -I te

Re: [c++-concepts] Fix assertion failure with cp_maybe_constrained_type_specifier

2014-06-24 Thread Ed Smith-Rowland
I saw this during bootstrap.  I've verified that the patch works (I was 
working on similar).


Ed



Re: [c++-concepts] Fix assertion failure with cp_maybe_constrained_type_specifier

2014-06-24 Thread Ed Smith-Rowland

I am still having problems doing a full build.

I get stuck on something that I think can't be a concepts problem in 
gcc/config/i386/i386.c:


make[3]: Entering directory `/home/ed/obj_concepts/gcc'
/home/ed/obj_concepts/./prev-gcc/xg++ 
-B/home/ed/obj_concepts/./prev-gcc/ 
-B/home/ed/bin_concepts/x86_64-unknown-linux-gnu/bin/ -nostdinc++ 
-B/home/ed/obj_concepts/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs 
-B/home/ed/obj_concepts/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs 
-I/home/ed/obj_concepts/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu 
-I/home/ed/obj_concepts/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include 
-I/home/ed/gcc_concepts/libstdc++-v3/libsupc++ 
-L/home/ed/obj_concepts/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs 
-L/home/ed/obj_concepts/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs 
-c -g -O2 -gtoggle -DIN_GCC -fno-exceptions -fno-rtti 
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
-Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic 
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror 
-fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc_concepts/gcc 
-I../../gcc_concepts/gcc/. -I../../gcc_concepts/gcc/../include 
-I../../gcc_concepts/gcc/../libcpp/include -I/home/ed/obj_concepts/./gmp 
-I/home/ed/gcc_concepts/gmp -I/home/ed/obj_concepts/./mpfr/src 
-I/home/ed/gcc_concepts/mpfr/src -I/home/ed/gcc_concepts/mpc/src 
-I../../gcc_concepts/gcc/../libdecnumber 
-I../../gcc_concepts/gcc/../libdecnumber/bid -I../libdecnumber 
-I../../gcc_concepts/gcc/../libbacktrace -DCLOOG_INT_GMP 
-I/home/ed/obj_concepts/./cloog/include 
-I/home/ed/gcc_concepts/cloog/include -I../gcc_concepts/cloog/include 
-I/home/ed/obj_concepts/./isl/include 
-I/home/ed/gcc_concepts/isl/include -o i386.o -MT i386.o -MMD -MP -MF 
./.deps/i386.TPo ../../gcc_concepts/gcc/config/i386/i386.c
../../gcc_concepts/gcc/config/i386/i386.c:113:56: error: uninitialized 
const member ‘stringop_algs::stringop_strategy::max’

{rep_prefix_1_byte, {{-1, rep_prefix_1_byte, false;
^
../../gcc_concepts/gcc/config/i386/i386.c:113:56: error: missing 
initializer for member ‘stringop_algs::stringop_strategy::max’ 
[-Werror=missing-field-initializers]
../../gcc_concepts/gcc/config/i386/i386.c:113:56: error: uninitialized 
const member ‘stringop_algs::stringop_strategy::alg’
../../gcc_concepts/gcc/config/i386/i386.c:113:56: error: missing 
initializer for member ‘stringop_algs::stringop_strategy::alg’ 
[-Werror=missing-field-initializers]
../../gcc_concepts/gcc/config/i386/i386.c:113:56: error: missing 
initializer for member ‘stringop_algs::stringop_strategy::noalign’ 
[-Werror=missing-field-initializers]



Am I the only one seeing this?
Do you turn off the warning when you compile?

Ed



Re: [c++-concepts] Fix assertion failure with cp_maybe_constrained_type_specifier

2014-06-24 Thread Ed Smith-Rowland

I'm not sure the warning is correct in any case...

In i386.h

struct stringop_algs
{
  const enum stringop_alg unknown_size;
  const struct stringop_strategy {
const int max;
const enum stringop_alg alg;
int noalign;
  } size [MAX_STRINGOP_ALGS];
};

in i386.c
---
static stringop_algs ix86_size_memcpy[2] = {
  {rep_prefix_1_byte, {{-1, rep_prefix_1_byte, false}}},
  {rep_prefix_1_byte, {{-1, rep_prefix_1_byte, false;
static stringop_algs ix86_size_memset[2] = {
  {rep_prefix_1_byte, {{-1, rep_prefix_1_byte, false}}},
  {rep_prefix_1_byte, {{-1, rep_prefix_1_byte, false;



Re: Re: [c++-concepts] Fix assertion failure with cp_maybe_constrained_type_specifier

2014-06-24 Thread Ed Smith-Rowland
 
 

On 06/24/14, Andrew Sutton wrote:

Weird. Any chance you're doing a bootstrap build?

There was an earlier bootstrapping issue with this branch. We had
turned on -std=c++1y by default, and it was causing some conversion
errors with lvalue references to bitfields in libasan.

This doesn't *look* like a regression caused by concepts -- I don't
think I'm touching the initializer code at all.

Andrew Sutton


Andrew,

I did a full 3-stage bootstrap which is the default these days.
I'll try --disable-bootstrap and see what happens.

In other news: I think the lvalue to bitfield issue is resolved in 4.9 and 
trunk.
Note to self: Add a testcase for that if not done already.

Ed


Re: [c++-concepts] Fix assertion failure with cp_maybe_constrained_type_specifier

2014-06-26 Thread Ed Smith-Rowland

On 06/25/2014 10:03 AM, Andrew Sutton wrote:

I did a full 3-stage bootstrap which is the default these days.
I'll try --disable-bootstrap and see what happens.

I just did a full bootstrap build and got the same errors. The errors
are correct for C++11, which was enabled by default in this branch.
IIRC, aggregate initialization requires the initializer-clause to
match the structure exactly (or at least not omit any const
initializers?)

I think this was something Gaby wanted when we created the branch, but
I'm not sure it's worth keeping because of the bootstrapping errors. I
could reset the default dialect to 98 and turn on concepts iff 1y is
enabled, or I could turn on 1y if -fconcepts is enabled.

Thoughts?

Andrew


I did --disable-bootstrap and it worked a charm.

I, for one, would like gcc to bootstrap with c++11/c++14.  I think we 
should be starting to shake down that path.  I'm probably not alone in this.


On the other hand, I don't think c++-concepts branch should be the 
leader on this.  We have our work cut out for us without fighting these 
bugs.  Maybe a c++11-bootstrap branch could be started to work the c++1* 
bootstrap out.


As long as gcc defaults to bootstrappng with c++98 I think we should do 
that if it won't preclude concepts work.  Put it this way: I want 
concepts in trunk faster than I think we could get c++11 bootstrapping 
gcc working and set as default.  I could be wrong - maybe 
c++11-bootstrap won't be that hard.


As for flags.  I vote for concepts switched on for -std=c++1y.  As for 
-fconcepts turning on c++1y I'm less sure.  We could allow concepts for 
C++11 (I don't think c++98 would work because of constexpr and maybe new 
template syntax).  I hadn't thought about that.  Personally I leave 
-std=c++14 and use all the things... ;-)


I'm CCing Jason.



Re: [c++-concepts] Fix assertion failure with cp_maybe_constrained_type_specifier

2014-06-26 Thread Ed Smith-Rowland


So is C++14 a done deal with a __cplusplus date and all?
I've been waiting for some news or a trip report from Rapperswil and 
have seen nothing on isocpp.


I've been thinking of adding a thing or two to C++1z like clang has - 
The Disabling trigraph expansion by default looks easy.


Ed



Re: [c++-concepts] Fix assertion failure with cp_maybe_constrained_type_specifier

2014-06-27 Thread Ed Smith-Rowland

On 06/26/2014 11:28 PM, Jason Merrill wrote:

On 06/26/2014 09:38 PM, Ed Smith-Rowland wrote:

So is C++14 a done deal with a __cplusplus date and all?


The C++14 draft was finalized at the February meeting in Issaquah; the 
ratification process isn't quite done, but I haven't heard any reason 
to doubt that it will be done soon.  The __cplusplus date is 201402L.
I guess we should set this correctly in libcpp/init.c or wherever. Do 
you see a problem with changing it from its current value of 201300?  We 
don't use the actual number AFAICT.  I guess we could also use a fake 
date for c++1z/c++17.  Say 201500?



I've been thinking of adding a thing or two to C++1z like clang has -
The Disabling trigraph expansion by default looks easy.


Aren't trigraphs off by default already?

They are *off* by default with gnu++NN and *on* by default with c++NN.  
We want them *off* by default for all (gnu|c)++(1z|17).  But -trigraphs 
will restore them for all versions.

Jason






Re: [Bug c++/60249] [c++11] Compiler goes into semi-infinite loop with wrong usage of user defined string literals

2014-06-28 Thread Ed Smith-Rowland

On 06/27/2014 05:39 PM, paolo.carlini at oracle dot com wrote:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60249

--- Comment #5 from Paolo Carlini  ---
Patch looks *great*. If it works, please send it to mailing list ASAP.

I think I finally got these weird user-defined string literal bugs. 
"Don't cross the streams!"


Dr. Egon Spengler

PR C++/58781    - Unicode 
strings broken in a strange way
PR C++/59867    - Template 
string literal loses first symbol
PR C++/60249    - Compiler 
goes into semi-infinite loop with wrong usage of user defined string literals
Plus I fixed an misleading error message for string literal operator templates 
(not available in C++11).

Built and tested clean on x86_64-linux.

OK?

I would also like to apply this to 4.9.

cp/

2014-06-28  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58781
PR c++/60249
PR c++/59867
* parser.c (cp_parser_userdef_string_literal()): Take a tree
not a cp_token*. (cp_parser_string_literal(): Don't hack
the token stream!


testsuite/

2014-06-28  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58781
PR c++/60249
PR c++/59867
* testsuite/g++.dg/cpp0x/pr58781.C: New.
* testsuite/g++.dg/cpp0x/pr60249.C: New.
* testsuite/g++.dg/cpp1y/pr59867.C: New.

Index: cp/parser.c
===
--- cp/parser.c (revision 211481)
+++ cp/parser.c (working copy)
@@ -1893,7 +1893,7 @@
 static tree cp_parser_userdef_char_literal
   (cp_parser *);
 static tree cp_parser_userdef_string_literal
-  (cp_token *);
+  (tree);
 static tree cp_parser_userdef_numeric_literal
   (cp_parser *);
 
@@ -3713,8 +3713,7 @@
{
  tree literal = build_userdef_literal (suffix_id, value,
OT_NONE, NULL_TREE);
- tok->u.value = literal;
- return cp_parser_userdef_string_literal (tok);
+ value = cp_parser_userdef_string_literal (literal);
}
 }
   else
@@ -3962,9 +3961,8 @@
as arguments.  */
 
 static tree
-cp_parser_userdef_string_literal (cp_token *token)
+cp_parser_userdef_string_literal (tree literal)
 {
-  tree literal = token->u.value;
   tree suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
   tree name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
   tree value = USERDEF_LITERAL_VALUE (literal);
@@ -23156,10 +23154,17 @@
ok = false;
}
   if (!ok)
-   error ("literal operator template %qD has invalid parameter list."
-  "  Expected non-type template argument pack "
-  " or ",
-  decl);
+   {
+ if (cxx_dialect >= cxx1y)
+   error ("literal operator template %qD has invalid parameter list."
+  "  Expected non-type template argument pack "
+  " or ",
+  decl);
+ else
+   error ("literal operator template %qD has invalid parameter list."
+  "  Expected non-type template argument pack ",
+  decl);
+   }
 }
   /* Register member declarations.  */
   if (member_p && !friend_p && decl && !DECL_CLASS_TEMPLATE_P (decl))
Index: testsuite/g++.dg/cpp0x/pr58781.C
===
--- testsuite/g++.dg/cpp0x/pr58781.C(revision 0)
+++ testsuite/g++.dg/cpp0x/pr58781.C(revision 0)
@@ -0,0 +1,18 @@
+// PR c++/58781
+// { dg-do compile { target c++11 } }
+
+#include 
+
+int
+operator""_s(const char32_t *a, size_t b)
+{
+  return 0;
+}
+
+int
+f()
+{
+  using a = decltype(U"\x1181"_s);
+  using b = decltype(U"\x8111"_s);
+  using c = decltype(U" \x1181"_s);
+}
Index: testsuite/g++.dg/cpp0x/pr60249.C
===
--- testsuite/g++.dg/cpp0x/pr60249.C(revision 0)
+++ testsuite/g++.dg/cpp0x/pr60249.C(revision 0)
@@ -0,0 +1,4 @@
+// PR c++/60249
+// { dg-do compile { target c++11 } }
+
+decltype(""_) x;
Index: testsuite/g++.dg/cpp1y/pr59867.C
===
--- testsuite/g++.dg/cpp1y/pr59867.C(revision 0)
+++ testsuite/g++.dg/cpp1y/pr59867.C(revision 0)
@@ -0,0 +1,52 @@
+// PR c++/59867
+// { dg-do compile { target c++14 } }
+
+#include 
+using namespace std;
+
+// constant
+template
+  struct meta_value
+  {
+typedef meta_value type;
+typedef T value_type;
+static const T value = x;
+  };
+
+// array
+template
+  struct meta_array
+  {
+typedef meta_array type;
+typedef T item_type;
+  };
+
+// static array -> runtime array conversion utility
+template
+  struct array_gen;
+
+template
+  struct array_gen>
+  {
+static const T value[sizeof...(xs)];
+  };
+
+template
+  const T
+  array_gen>::value[sizeof

[PATCH PR C++/58781, 59867, 60249 ] Various user-defined string literal issues involving character encodings, dropped bytes, semi-infinite loops

2014-06-28 Thread Ed Smith-Rowland
Please disregard previous email "Re: [Bug c++/60249] [c++11] Compiler 
goes into semi-infinite loop with wrong usage of user defined string 
literals"

A new patch with tweaked testcase is attached.  Sorry for the noise.

I finally fixed these weird user-defined string literal bugs.

I was messing with cp_token stream unnecessarily and poorly.  Changed by 
using a tree in cp_parser_userdef_string_literal.


PR C++/58781  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58781>  - 
Unicode strings broken in a strange way
PR C++/59867  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867>  - 
Template string literal loses first symbol
PR C++/60249  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60249>  - 
Compiler goes into semi-infinite loop with wrong usage of user defined 
string literals
Plus I fixed an misleading error message for string literal operator 
templates (not available in C++11).


Built and tested clean on x86_64-linux.

OK?

I would also like to apply this to 4.9.

Ed Smith-Rowland


cp/

2014-06-28  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58781
PR c++/60249
PR c++/59867
* parser.c (cp_parser_userdef_string_literal()): Take a tree
not a cp_token*. (cp_parser_string_literal(): Don't hack
the token stream!


testsuite/

2014-06-28  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58781
PR c++/60249
PR c++/59867
* testsuite/g++.dg/cpp0x/pr58781.C: New.
* testsuite/g++.dg/cpp0x/pr60249.C: New.
* testsuite/g++.dg/cpp1y/pr59867.C: New.


Index: cp/parser.c
===
--- cp/parser.c (revision 212100)
+++ cp/parser.c (working copy)
@@ -1899,7 +1899,7 @@
 static tree cp_parser_userdef_char_literal
   (cp_parser *);
 static tree cp_parser_userdef_string_literal
-  (cp_token *);
+  (tree);
 static tree cp_parser_userdef_numeric_literal
   (cp_parser *);
 
@@ -3721,8 +3721,7 @@
{
  tree literal = build_userdef_literal (suffix_id, value,
OT_NONE, NULL_TREE);
- tok->u.value = literal;
- return cp_parser_userdef_string_literal (tok);
+ value = cp_parser_userdef_string_literal (literal);
}
 }
   else
@@ -3970,9 +3969,8 @@
as arguments.  */
 
 static tree
-cp_parser_userdef_string_literal (cp_token *token)
+cp_parser_userdef_string_literal (tree literal)
 {
-  tree literal = token->u.value;
   tree suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
   tree name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
   tree value = USERDEF_LITERAL_VALUE (literal);
@@ -23202,10 +23200,17 @@
ok = false;
}
   if (!ok)
-   error ("literal operator template %qD has invalid parameter list."
-  "  Expected non-type template argument pack "
-  " or ",
-  decl);
+   {
+ if (cxx_dialect >= cxx1y)
+   error ("literal operator template %qD has invalid parameter list."
+  "  Expected non-type template argument pack "
+  " or ",
+  decl);
+ else
+   error ("literal operator template %qD has invalid parameter list."
+  "  Expected non-type template argument pack ",
+  decl);
+   }
 }
   /* Register member declarations.  */
   if (member_p && !friend_p && decl && !DECL_CLASS_TEMPLATE_P (decl))
Index: testsuite/g++.dg/cpp0x/pr58781.C
===
--- testsuite/g++.dg/cpp0x/pr58781.C(revision 0)
+++ testsuite/g++.dg/cpp0x/pr58781.C(working copy)
@@ -0,0 +1,18 @@
+// PR c++/58781
+// { dg-do compile { target c++11 } }
+
+#include 
+
+int
+operator""_s(const char32_t *a, size_t b)
+{
+  return 0;
+}
+
+int
+f()
+{
+  using a = decltype(U"\x1181"_s);
+  using b = decltype(U"\x8111"_s);
+  using c = decltype(U" \x1181"_s);
+}
Index: testsuite/g++.dg/cpp0x/pr60249.C
===
--- testsuite/g++.dg/cpp0x/pr60249.C(revision 0)
+++ testsuite/g++.dg/cpp0x/pr60249.C(working copy)
@@ -0,0 +1,6 @@
+// PR c++/60249
+// { dg-do compile { target c++11 } }
+
+decltype(""_) x; // { dg-error "unable to find string literal operator" }
+
+// { dg-error "invalid type in declaration before" "invalid" { target *-*-* } 
4 }
Index: testsuite/g++.dg/cpp1y/pr59867.C
===
--- testsuite/g++.dg/cpp1y/pr59867.C(revision 0)
+++ testsuite/g++.dg/cpp1y/pr59867.C(working copy)
@@ -0,0 +1,52 @@
+// PR c++/59867
+// { dg-do compile { target c++14 } }
+
+#include 
+using namespace std;

PR C++/60209 - Declaration of user-defined literal operator cause error

2014-07-03 Thread Ed Smith-Rowland

Support operator"" ""(...) per CWG 1473.

I'll be AFK over the holiday.

Bootstrapped and tested on x86_64-linux.

OK?

I'm less sure if this is appropriate for 4.9.

Index: cp/parser.c
===
--- cp/parser.c (revision 212248)
+++ cp/parser.c (working copy)
@@ -1895,7 +1895,7 @@
 static tree cp_parser_identifier
   (cp_parser *);
 static tree cp_parser_string_literal
-  (cp_parser *, bool, bool);
+  (cp_parser *, bool, bool, bool);
 static tree cp_parser_userdef_char_literal
   (cp_parser *);
 static tree cp_parser_userdef_string_literal
@@ -3566,7 +3566,8 @@
 
FUTURE: ObjC++ will need to handle @-strings here.  */
 static tree
-cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok)
+cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok,
+ bool lookup_udlit = true)
 {
   tree value;
   size_t count;
@@ -3721,7 +3722,10 @@
{
  tree literal = build_userdef_literal (suffix_id, value,
OT_NONE, NULL_TREE);
- value = cp_parser_userdef_string_literal (literal);
+ if (lookup_udlit)
+   value = cp_parser_userdef_string_literal (literal);
+ else
+   value = literal;
}
 }
   else
@@ -12635,7 +12639,7 @@
 {
   tree id = NULL_TREE;
   cp_token *token;
-  bool bad_encoding_prefix = false;
+  bool utf8 = false;
 
   /* Peek at the next token.  */
   token = cp_lexer_peek_token (parser->lexer);
@@ -12835,83 +12839,73 @@
   cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
   return ansi_opname (ARRAY_REF);
 
+case CPP_UTF8STRING:
+case CPP_UTF8STRING_USERDEF:
+  utf8 = true;
+case CPP_STRING:
 case CPP_WSTRING:
 case CPP_STRING16:
 case CPP_STRING32:
-case CPP_UTF8STRING:
- bad_encoding_prefix = true;
-  /* Fall through.  */
-
-case CPP_STRING:
-  if (cxx_dialect == cxx98)
-   maybe_warn_cpp0x (CPP0X_USER_DEFINED_LITERALS);
-  if (bad_encoding_prefix)
-   {
- error ("invalid encoding prefix in literal operator");
- return error_mark_node;
-   }
-  if (TREE_STRING_LENGTH (token->u.value) > 2)
-   {
- error ("expected empty string after % keyword");
- return error_mark_node;
-   }
-  /* Consume the string.  */
-  cp_lexer_consume_token (parser->lexer);
-  /* Look for the suffix identifier.  */
-  token = cp_lexer_peek_token (parser->lexer);
-  if (token->type == CPP_NAME)
-   {
- id = cp_parser_identifier (parser);
- if (id != error_mark_node)
-   {
- const char *name = IDENTIFIER_POINTER (id);
- return cp_literal_operator_id (name);
-   }
-   }
-  else if (token->type == CPP_KEYWORD)
-   {
- error ("unexpected keyword;"
-" remove space between quotes and suffix identifier");
- return error_mark_node;
-   }
-  else
-   {
- error ("expected suffix identifier");
- return error_mark_node;
-   }
-
+case CPP_STRING_USERDEF:
 case CPP_WSTRING_USERDEF:
 case CPP_STRING16_USERDEF:
 case CPP_STRING32_USERDEF:
-case CPP_UTF8STRING_USERDEF:
-  bad_encoding_prefix = true;
-  /* Fall through.  */
+  {
+   tree str, string_tree;
+   int sz, len;
 
-case CPP_STRING_USERDEF:
-  if (cxx_dialect == cxx98)
-   maybe_warn_cpp0x (CPP0X_USER_DEFINED_LITERALS);
-  if (bad_encoding_prefix)
-   {
- error ("invalid encoding prefix in literal operator");
+   if (cxx_dialect == cxx98)
+ maybe_warn_cpp0x (CPP0X_USER_DEFINED_LITERALS);
+
+   /* Consume the string.  */
+   str = cp_parser_string_literal (parser, /*translate=*/true,
+ /*wide_ok=*/true, /*lookup_udlit=*/false);
+   if (str == error_mark_node)
  return error_mark_node;
-   }
-  {
-   tree string_tree = USERDEF_LITERAL_VALUE (token->u.value);
-   if (TREE_STRING_LENGTH (string_tree) > 2)
+   else if (TREE_CODE (str) == USERDEF_LITERAL)
  {
+   string_tree = USERDEF_LITERAL_VALUE (str);
+   id = USERDEF_LITERAL_SUFFIX_ID (str);
+ }
+   else
+ {
+   string_tree = str;
+   /* Look for the suffix identifier.  */
+   token = cp_lexer_peek_token (parser->lexer);
+   if (token->type == CPP_NAME)
+ id = cp_parser_identifier (parser);
+   else if (token->type == CPP_KEYWORD)
+ {
+   error ("unexpected keyword;"
+  " remove space between quotes and suffix identifier");
+   return error_mark_node;
+ }
+   else
+ {
+   error ("expected suffix identifier");
+   return error_mark_node;
+ }
+ }
+   sz = T

[C++ Patch] PR 58155 - -Wliteral-suffix warns about tokens which are skipped

2014-07-07 Thread Ed Smith-Rowland
This patch addresses an old issue of warning about macro touching string 
literal even if the code is skipped:


#define BAZ "baz"
#if 0
"bar"BAZ
#endif

Just skip the warning Wliteral-suffix if the preprocessor is skipping.

Built and tested on x86_64-linux.

OK?

And for 4.9?

Thanks,

Ed Smith-Rowland


libcpp/

2014-07-07  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58155 - -Wliteral-suffix warns about tokens which are skipped
by preprocessor
* lex.c (lex_raw_string ()): Do not warn about invalid suffix
if skipping. (lex_string ()): Ditto.


gcc/testsuite/

2014-07-07  Edward Smith-Rowland  <3dw...@verizon.net>

PR c++/58155 - -Wliteral-suffix warns about tokens which are skipped
g++.dg/cpp0x/pr58155.C: New.
Index: libcpp/lex.c
===
--- libcpp/lex.c(revision 212209)
+++ libcpp/lex.c(working copy)
@@ -1646,7 +1646,7 @@
   if (is_macro (pfile, cur))
{
  /* Raise a warning, but do not consume subsequent tokens.  */
- if (CPP_OPTION (pfile, warn_literal_suffix))
+ if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping)
cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX,
   token->src_loc, 0,
   "invalid suffix on literal; C++11 requires "
@@ -1775,7 +1775,7 @@
   if (is_macro (pfile, cur))
{
  /* Raise a warning, but do not consume subsequent tokens.  */
- if (CPP_OPTION (pfile, warn_literal_suffix))
+ if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping)
cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX,
   token->src_loc, 0,
   "invalid suffix on literal; C++11 requires "
Index: gcc/testsuite/g++.dg/cpp0x/pr58155.C
===
--- gcc/testsuite/g++.dg/cpp0x/pr58155.C(revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/pr58155.C(revision 0)
@@ -0,0 +1,13 @@
+// { dg-do compile { target c++11 } }
+
+#define BAZ "baz"
+
+#if 0
+
+"bar"BAZ
+
+R"(
+  bar
+)"BAZ
+
+#endif


[PING] [C++17] Implement N3928 - Extending static_assert

2015-05-19 Thread Ed Smith-Rowland

On 05/02/2015 04:16 PM, Ed Smith-Rowland wrote:

This extends' static assert to not require a message string.
I elected to make this work also for C++11 and C++14 and warn only 
with -pedantic.

I think many people just write
  static_assert(thing, "");
.

I took the path of building an empty string in the parser in this case.
I wasn't sure if setting message to NULL_TREE would cause sadness 
later on or not.


I also, perhaps in a fit of overzealousness made finish_static_assert 
not print the extra ": " and an empty message in this case.


I didn't modify _Static_assert for C.

Built and tested on x86_64-linux.

OK



Ping? Comments?




Re: C/C++ PATCH to allow deprecating enum values (PR c/47043)

2015-05-23 Thread Ed Smith-Rowland

On 05/22/2015 06:19 PM, Mikhail Maltsev wrote:

On 22.05.2015 12:10, Marek Polacek wrote:

Thanks, applied.  Here's the final version.

By the way, we have a feature test macro, __cpp_attributes=200809 which
can be used to determine, whether C++11 attribute syntax is supported by
the compiler.

I propose to add something similar for this extension (like
__cpp_gnu_enum_attributes=... for C++ and __GCC_HAVE_ENUM_ATTRIBUTES for
C). Thoughts?


I think SG 10 is or did debate this a weekor two ago.  I haven't heard.
I had made some recommendations along the lines you describe. Another 
member had suggested just bumping the date on


__cpp_attributes

I don't know what/if they decided.

Ed



[wwwdocs] Remove extra SD-6 column in C++14 language stats.

2015-04-19 Thread Ed Smith-Rowland
I accidentally added an extra column to the C++14 language stats by 
duplicating a column for the SD-6 feature test macros.


This one-liner fixes it.

I'll need someone to apply this...

Sorry.

Ed

? class_key.txt
? help
? patch
? patch_cxx14
? patch_cxx14_2
? patch_cxx14_3
? patch_cxx1y
? patch_feature_test
? patch_feature_test_2
? patch_has_attribute
? htdocs/projects/patch_cxx1y
Index: htdocs/projects/cxx1y.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.22
diff -r1.22 cxx1y.html
142d141
<   __has_cpp_attribute(deprecated) >= 201309


[PATCH] [libstdc++] Add uniform container erasure.

2015-04-30 Thread Ed Smith-Rowland

This has been in me tree for a good while.

It is fairly simple and adds C++ experimental container erasure.

Builds and tests cleanly on x86_64-linux.

OK?

Index: include/Makefile.am
===
--- include/Makefile.am (revision 222573)
+++ include/Makefile.am (working copy)
@@ -645,15 +645,26 @@
 experimental_headers = \
${experimental_srcdir}/algorithm \
${experimental_srcdir}/any \
+   ${experimental_srcdir}/array \
${experimental_srcdir}/chrono \
+   ${experimental_srcdir}/deque \
+   ${experimental_srcdir}/erase_if.tcc \
+   ${experimental_srcdir}/forward_list \
${experimental_srcdir}/functional \
+   ${experimental_srcdir}/list \
+   ${experimental_srcdir}/map \
${experimental_srcdir}/optional \
${experimental_srcdir}/ratio \
+   ${experimental_srcdir}/set \
+   ${experimental_srcdir}/string \
${experimental_srcdir}/string_view \
+   ${experimental_srcdir}/string_view.tcc \
${experimental_srcdir}/system_error \
-   ${experimental_srcdir}/string_view.tcc \
${experimental_srcdir}/tuple \
-   ${experimental_srcdir}/type_traits
+   ${experimental_srcdir}/type_traits \
+   ${experimental_srcdir}/unordered_map \
+   ${experimental_srcdir}/unordered_set \
+   ${experimental_srcdir}/vector
 
 # This is the common subset of C++ files that all three "C" header models use.
 c_base_srcdir = $(C_INCLUDE_DIR)
Index: include/Makefile.in
===
--- include/Makefile.in (revision 222573)
+++ include/Makefile.in (working copy)
@@ -912,15 +912,26 @@
 experimental_headers = \
${experimental_srcdir}/algorithm \
${experimental_srcdir}/any \
+   ${experimental_srcdir}/array \
${experimental_srcdir}/chrono \
+   ${experimental_srcdir}/deque \
+   ${experimental_srcdir}/erase_if.tcc \
+   ${experimental_srcdir}/forward_list \
${experimental_srcdir}/functional \
+   ${experimental_srcdir}/list \
+   ${experimental_srcdir}/map \
${experimental_srcdir}/optional \
${experimental_srcdir}/ratio \
+   ${experimental_srcdir}/set \
+   ${experimental_srcdir}/string \
${experimental_srcdir}/string_view \
+   ${experimental_srcdir}/string_view.tcc \
${experimental_srcdir}/system_error \
-   ${experimental_srcdir}/string_view.tcc \
${experimental_srcdir}/tuple \
-   ${experimental_srcdir}/type_traits
+   ${experimental_srcdir}/type_traits \
+   ${experimental_srcdir}/unordered_map \
+   ${experimental_srcdir}/unordered_set \
+   ${experimental_srcdir}/vector
 
 
 # This is the common subset of C++ files that all three "C" header models use.
Index: include/experimental/array
===
--- include/experimental/array  (revision 0)
+++ include/experimental/array  (working copy)
@@ -0,0 +1,180 @@
+//  https://gist.github.com/lichray/6034753
+//  -*- C++ -*-
+
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file experimental/functional
+ *  This is a TS C++ Library header.
+ */
+
+#ifndef _GLIBCXX_EXPERIMENTAL_ARRAY
+#define _GLIBCXX_EXPERIMENTAL_ARRAY 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include 
+#else
+
+#include 
+#include 
+#include 
+
+namespace std
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+
+//  Made this up...
+#define __cpp_lib_experimental_make_array 201411
+
+namespace __detail
+{
+
+  template
+struct __lazy_conditional;
+
+  template
+struct __lazy_conditional
+{
+  using type = typename _Tp::type;
+};
+
+  template
+struct __lazy_conditional
+{
+  using type = typename _Tp::type;
+};
+
+  template
+struct __lazy_conditional
+{
+  using type = typename _Up::type;
+};
+
+  template
+using __if = 

Re: [PATCH] [libstdc++] Add uniform container erasure.

2015-04-30 Thread Ed Smith-Rowland



And make_array, which isn't in the working paper yet, so I'd prefer to
leave that part out for now.

D'oh!  Sorry about that..  Removed.

The Doxygen @headername command tells users which header they are
supposed to include, rather than this one. Since there is no
 header that's wrong. I'd just omit the @headername.

Done.

This file doesn't really seem like a .tcc to me, it isn't providing
definitions of templates declared elsewhere (specifically in an
erase_if.h header).

Maybe we want an experimental/bits/ directory for this sort of thing
(which I could also use for the filesystem headers I'm about to
commit) but in the meanwhile I think just experimental/erase_if.h is a
better name.
Done. (I didn't make experimental/bits - I'll move erase_if.h after you 
add the bits directory).

OK for trunk with those changes (remove make_array, rename erase_if.tcc)


Rebuilt, retested and committed as 222630.
Altered patch attached.

Thanks,

Ed

2015-04-30  Edward Smith-Rowland  <3dw...@verizon.net>

Add fundamentals TR container erasure.
* include/Makefile.am: Add new headers.
* include/Makefile.in: Add new headers.
* include/experimental/array: New.
* include/experimental/deque: New.
* include/experimental/erase_if.tcc: New.
* include/experimental/forward_list: New.
* include/experimental/list: New.
* include/experimental/map: New.
* include/experimental/set: New.
* include/experimental/string: New.
* include/experimental/unordered_map: New.
* include/experimental/unordered_set: New.
* include/experimental/vector: New.
* testsuite/experimental/deque/erasure.cc: New.
* testsuite/experimental/forward_list/erasure.cc: New.
* testsuite/experimental/list/erasure.cc: New.
* testsuite/experimental/map/erasure.cc: New.
* testsuite/experimental/set/erasure.cc: New.
* testsuite/experimental/string/erasure.cc: New.
* testsuite/experimental/unordered_map/erasure.cc: New.
* testsuite/experimental/unordered_set/erasure.cc: New.
* testsuite/experimental/vector/erasure.cc: New.

Index: include/Makefile.am
===
--- include/Makefile.am (revision 222599)
+++ include/Makefile.am (working copy)
@@ -646,14 +646,24 @@
${experimental_srcdir}/algorithm \
${experimental_srcdir}/any \
${experimental_srcdir}/chrono \
+   ${experimental_srcdir}/deque \
+   ${experimental_srcdir}/erase_if.h \
+   ${experimental_srcdir}/forward_list \
${experimental_srcdir}/functional \
+   ${experimental_srcdir}/list \
+   ${experimental_srcdir}/map \
${experimental_srcdir}/optional \
${experimental_srcdir}/ratio \
+   ${experimental_srcdir}/set \
+   ${experimental_srcdir}/string \
${experimental_srcdir}/string_view \
+   ${experimental_srcdir}/string_view.tcc \
${experimental_srcdir}/system_error \
-   ${experimental_srcdir}/string_view.tcc \
${experimental_srcdir}/tuple \
-   ${experimental_srcdir}/type_traits
+   ${experimental_srcdir}/type_traits \
+   ${experimental_srcdir}/unordered_map \
+   ${experimental_srcdir}/unordered_set \
+   ${experimental_srcdir}/vector
 
 # This is the common subset of C++ files that all three "C" header models use.
 c_base_srcdir = $(C_INCLUDE_DIR)
Index: include/Makefile.in
===
--- include/Makefile.in (revision 222599)
+++ include/Makefile.in (working copy)
@@ -913,14 +913,24 @@
${experimental_srcdir}/algorithm \
${experimental_srcdir}/any \
${experimental_srcdir}/chrono \
+   ${experimental_srcdir}/deque \
+   ${experimental_srcdir}/erase_if.h \
+   ${experimental_srcdir}/forward_list \
${experimental_srcdir}/functional \
+   ${experimental_srcdir}/list \
+   ${experimental_srcdir}/map \
${experimental_srcdir}/optional \
${experimental_srcdir}/ratio \
+   ${experimental_srcdir}/set \
+   ${experimental_srcdir}/string \
${experimental_srcdir}/string_view \
+   ${experimental_srcdir}/string_view.tcc \
${experimental_srcdir}/system_error \
-   ${experimental_srcdir}/string_view.tcc \
${experimental_srcdir}/tuple \
-   ${experimental_srcdir}/type_traits
+   ${experimental_srcdir}/type_traits \
+   ${experimental_srcdir}/unordered_map \
+   ${experimental_srcdir}/unordered_set \
+   ${experimental_srcdir}/vector
 
 
 # This is the common subset of C++ files that all three "C" header models use.
Index: include/experimental/deque
===
--- include/experimental/deque  (revision 0)
+++ include/experimental/deque  (working copy)
@@ -0,0 +1,72 @@
+//  -*- C++ -*-
+
+// Copyright (C) 2015 Free Software Foundation

Re: [PATCH] [libstdc++] Add uniform container erasure.

2015-05-01 Thread Ed Smith-Rowland

On 04/30/2015 02:01 PM, Daniel Krügler wrote:
Shouldn't the "one-liner" forwarding function templates be declared as 
inline? - Daniel 

You are right.

This builds and tests clean on x86_64-linux.

OK?

2015-05-01  Edward Smith-Rowland  <3dw...@verizon.net>

Inline one-line erasure dispatch functions.
* include/experimental/forward_list (erase_if(), erase()): Inline.
* include/experimental/list (erase_if(), erase()): Inline.
* include/experimental/map (erase_if(*)): Inline.
* include/experimental/set (erase_if(*)): Inline.
* include/experimental/string (erase_if(), erase()): Inline.
* include/experimental/unordered_map (erase_if(*)): Inline.
* include/experimental/unordered_set (erase_if(*)): Inline.
Index: include/experimental/forward_list
===
--- include/experimental/forward_list   (revision 222661)
+++ include/experimental/forward_list   (working copy)
@@ -46,12 +46,13 @@
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template
-void 
+inline void 
 erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred)
 { __cont.remove_if(__pred); }
 
   template
-void erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
+inline void
+erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
 {
   using __elem_type = typename forward_list<_Tp, _Alloc>::value_type;
   erase_if(__cont, [&](__elem_type& __elem) { return __elem == __value; });
Index: include/experimental/list
===
--- include/experimental/list   (revision 222661)
+++ include/experimental/list   (working copy)
@@ -46,12 +46,12 @@
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template
-void
+inline void
 erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred)
 { __cont.remove_if(__pred); }
 
   template
-void
+inline void
 erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
 {
   using __elem_type = typename list<_Tp, _Alloc>::value_type;
Index: include/experimental/map
===
--- include/experimental/map(revision 222661)
+++ include/experimental/map(working copy)
@@ -48,13 +48,13 @@
 
   template
-void
+inline void
 erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
 { __detail::__erase_nodes_if(__cont, __pred); }
 
   template
-void
+inline void
 erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
 { __detail::__erase_nodes_if(__cont, __pred); }
 
Index: include/experimental/set
===
--- include/experimental/set(revision 222661)
+++ include/experimental/set(working copy)
@@ -48,13 +48,13 @@
 
   template
-void
+inline void
 erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
 { __detail::__erase_nodes_if(__cont, __pred); }
 
   template
-void
+inline void
 erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
 { __detail::__erase_nodes_if(__cont, __pred); }
 
Index: include/experimental/string
===
--- include/experimental/string (revision 222661)
+++ include/experimental/string (working copy)
@@ -48,7 +48,7 @@
 
   template
-void
+inline void
 erase_if(basic_string<_CharT, _Traits, _Alloc>& __cont, _Predicate __pred)
 {
   __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred),
@@ -56,7 +56,7 @@
 }
 
   template
-void
+inline void
 erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value)
 {
   __cont.erase(std::remove(__cont.begin(), __cont.end(), __value),
Index: include/experimental/unordered_map
===
--- include/experimental/unordered_map  (revision 222661)
+++ include/experimental/unordered_map  (working copy)
@@ -48,7 +48,7 @@
 
   template
-void
+inline void
 erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
 _Predicate __pred)
 { __detail::__erase_nodes_if(__cont, __pred); }
@@ -55,7 +55,7 @@
 
   template
-void
+inline void
 erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
 _Predicate __pred)
 { __detail::__erase_nodes_if(__cont, __pred); }
Index: include/experimental/unordered_set
===
--- include/experimental/unordered_set  (revision 222661)
+++ include/experimental/unordered_set  (working copy)
@@ -48,7 +48,7 @@
 
   template
-void
+inline void
 erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont,
 _Predicate __pred)
 { __detail::__erase_nodes_if(__cont, __pred); }
@@ -55,7 +55,7 @@
 
   template
-void
+inline void
  

Re: [libstdc++ PATCH] Implement observer_ptr

2015-05-01 Thread Ed Smith-Rowland

On 05/01/2015 05:01 PM, Jonathan Wakely wrote:

On 01/05/15 16:37 +0300, Ville Voutilainen wrote:

Tested on Linux-x64.

   Implement observer_ptr.


Thanks! Committed with some minor formatting changes.

I've also committed this to add feature-test macros and update the
docs. Tested powerpc64le-linux, committed to trunk.


I pretty sure we're supposed to add the macro for *all* the headers that 
got enable_if.


I actually went ahead and did this on 222713.

2015-05-02  Edward Smith-Rowland  <3dw...@verizon.net>

* include/experimental/deque: Add feature-test macro.
* include/experimental/forward_list: Ditto.
* include/experimental/list: Ditto.
* include/experimental/map: Ditto.
* include/experimental/set: Ditto.
* include/experimental/string: Ditto.
* include/experimental/unordered_map: Ditto.
* include/experimental/unordered_set: Ditto.




Re: [libstdc++ PATCH] Implement observer_ptr

2015-05-02 Thread Ed Smith-Rowland

On 05/02/2015 05:42 AM, Jonathan Wakely wrote:

On 02/05/15 10:40 +0100, Jonathan Wakely wrote:

On 01/05/15 22:02 -0400, Ed Smith-Rowland wrote:

On 05/01/2015 05:01 PM, Jonathan Wakely wrote:

On 01/05/15 16:37 +0300, Ville Voutilainen wrote:

Tested on Linux-x64.

 Implement observer_ptr.


Thanks! Committed with some minor formatting changes.

I've also committed this to add feature-test macros and update the
docs. Tested powerpc64le-linux, committed to trunk.


I pretty sure we're supposed to add the macro for *all* the headers 
that got enable_if.


That's not how I read the Fundamentals TS:

Programmers who wish to determine whether a feature is available in
an implementation should base that determination on the presence of
the header (determined with __has_include()) and the
state of the macro with the recommended name.

And the header for erase_if is listed as .



And SD-6 says:

 For library features, the “Header“ column identifies the header that
 is expected to define the macro, although the macro may also be
 predefined.




OK.  Thanks.

I do remember an SD-6 discussion about how annoying the 
define-the-macro-in-all-relevant-headers was.

I didn't know there was a resolution.  I need to reeducate myself.
Meanwhile I'll rollback my patch.

Reverted in 222722.

I'll ask next time.
Sorry for the noise.

Ed



[C++17] Implement N3928 - Extending static_assert

2015-05-02 Thread Ed Smith-Rowland

This extends' static assert to not require a message string.
I elected to make this work also for C++11 and C++14 and warn only with 
-pedantic.

I think many people just write
  static_assert(thing, "");
.

I took the path of building an empty string in the parser in this case.
I wasn't sure if setting message to NULL_TREE would cause sadness later 
on or not.


I also, perhaps in a fit of overzealousness made finish_static_assert 
not print the extra ": " and an empty message in this case.


I didn't modify _Static_assert for C.

Built and tested on x86_64-linux.

OK

cp/

2015-05-02  Edward Smith-Rowland  <3dw...@verizon.net>

Implement N3928 - Extending static_assert
* parser.c (cp_parser_static_assert): Support static_assert with
no message string.  Supply an empty string in this case.
* semantics.c (finish_static_assert): Don't try to print a message if
the message strnig is empty.


testsuite/

2015-05-02  Edward Smith-Rowland  <3dw...@verizon.net>

Implement N3928 - Extending static_assert
* g++.dg/cpp0x/static_assert8.C: Adjust.
* g++.dg/cpp0x/static_assert12.C: New.
* g++.dg/cpp0x/static_assert13.C: New.
* g++.dg/cpp1y/static_assert1.C: New.
* g++.dg/cpp1y/static_assert2.C: New.
* g++.dg/cpp1z/static_assert-nomsg.C: New.
Index: cp/parser.c
===
--- cp/parser.c (revision 222723)
+++ cp/parser.c (working copy)
@@ -12153,6 +12153,7 @@
 
static_assert-declaration:
  static_assert ( constant-expression , string-literal ) ; 
+ static_assert ( constant-expression ) ; (C++1Z)
 
If MEMBER_P, this static_assert is a class member.  */
 
@@ -12190,20 +12191,35 @@
/*allow_non_constant_p=*/true,
/*non_constant_p=*/&dummy);
 
-  /* Parse the separating `,'.  */
-  cp_parser_require (parser, CPP_COMMA, RT_COMMA);
+  if (cp_lexer_peek_token (parser->lexer)->type == CPP_CLOSE_PAREN)
+{
+  if (cxx_dialect < cxx1z)
+   pedwarn (input_location, OPT_Wpedantic,
+"static_assert without a message "
+"only available with -std=c++1z or -std=gnu++1z");
+  /* Eat the ')'  */
+  cp_lexer_consume_token (parser->lexer);
+  message = build_string (1, "");
+  TREE_TYPE (message) = char_array_type_node;
+  fix_string_type (message);
+}
+  else
+{
+  /* Parse the separating `,'.  */
+  cp_parser_require (parser, CPP_COMMA, RT_COMMA);
 
-  /* Parse the string-literal message.  */
-  message = cp_parser_string_literal (parser, 
-  /*translate=*/false,
-  /*wide_ok=*/true);
+  /* Parse the string-literal message.  */
+  message = cp_parser_string_literal (parser, 
+ /*translate=*/false,
+ /*wide_ok=*/true);
 
-  /* A `)' completes the static assertion.  */
-  if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
-cp_parser_skip_to_closing_parenthesis (parser, 
-   /*recovering=*/true, 
-   /*or_comma=*/false,
-  /*consume_paren=*/true);
+  /* A `)' completes the static assertion.  */
+  if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
+   cp_parser_skip_to_closing_parenthesis (parser, 
+   /*recovering=*/true, 
+   /*or_comma=*/false,
+  /*consume_paren=*/true);
+}
 
   /* A semicolon terminates the declaration.  */
   cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
Index: cp/semantics.c
===
--- cp/semantics.c  (revision 222723)
+++ cp/semantics.c  (working copy)
@@ -7184,8 +7184,17 @@
   input_location = location;
   if (TREE_CODE (condition) == INTEGER_CST 
   && integer_zerop (condition))
-/* Report the error. */
-error ("static assertion failed: %s", TREE_STRING_POINTER (message));
+   {
+ int sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT
+(TREE_TYPE (TREE_TYPE (message;
+ int len = TREE_STRING_LENGTH (message) / sz - 1;
+  /* Report the error. */
+ if (len == 0)
+error ("static assertion failed");
+ else
+error ("static assertion failed: %s",
+  TREE_STRING_POINTER (message));
+   }
   else if (condition && condition != error_mark_node)
{
  error ("non-constant condition for static assertion");
Index: testsuite/g++.dg/cpp0x/static_assert12.C
===

  1   2   3   4   >