[PATCH, libstdc++] Add the logistic distribution as an extension

2014-07-10 Thread Ed Smith-Rowland

The title says it all.

I've been bootstrapping and testing with this on x86_64-linux for a month.

OK?

Ed


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

Add the logistic_distribution as an extension.
* include/ext/random: Add the logistic_distribution.
* include/ext/random.tcc: Add the logistic_distribution.
* testsuite/ext/random/logistic_distribution/cons/parms.cc: New.
* testsuite/ext/random/logistic_distribution/cons/default.cc: New.
* testsuite/ext/random/logistic_distribution/requirements/typedefs.cc:
New.
* testsuite/ext/random/logistic_distribution/operators/inequal.cc: New.
* testsuite/ext/random/logistic_distribution/operators/equal.cc: New.
* testsuite/ext/random/logistic_distribution/operators/serialize.cc:
New.

Index: include/ext/random
===
--- include/ext/random  (revision 212391)
+++ include/ext/random  (working copy)
@@ -3106,6 +3106,246 @@
   const __gnu_cxx::hypergeometric_distribution_UIntType __d2)
 { return !(__d1 == __d2); }
 
+  /**
+   * @brief A logistic continuous distribution for random numbers.
+   *
+   * The formula for the logistic probability density function is
+   * @f[
+   * p(x|\a,\b) = \frac{e^{(x - a)/b}}{b[1 + e^{(x - a)/b}]^2}
+   * @f]
+   * where @f$b  0@f$.
+   *
+   * The formula for the logistic probability function is
+   * @f[
+   * cdf(x|\a,\b) = \frac{e^{(x - a)/b}}{1 + e^{(x - a)/b}}
+   * @f]
+   * where @f$b  0@f$.
+   *
+   * table border=1 cellpadding=10 cellspacing=0
+   * caption align=topDistribution Statistics/caption
+   * trtdMean/tdtd@f$a@f$/td/tr
+   * trtdVariance/tdtd@f$b^2\pi^2/3@f$/td/tr
+   * trtdRange/tdtd@f$[0, \infty)@f$/td/tr
+   * /table
+   */
+  templatetypename _RealType = double
+class
+logistic_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 logistic_distributionresult_type 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_b  result_type(0));
+   }
+
+   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
+  logistic_distribution(result_type __a = result_type(0),
+   result_type __b = result_type(1))
+  : _M_param(__a, __b)
+  { }
+
+  explicit
+  logistic_distribution(const param_type __p)
+  : _M_param(__p)
+  { }
+
+  /**
+   * @brief Resets the distribution state.
+   */
+  void
+  reset()
+  { }
+
+  /**
+   * @brief Return the parameters of the distribution.
+   */
+  result_type
+  a() const
+  { return _M_param.a(); }
+
+  result_type
+  b() const
+  { return _M_param.b(); }
+
+  /**
+   * @brief Returns the parameter set of the distribution.
+   */
+  param_type
+  param() const
+  { return _M_param; }
+
+  /**
+   * @brief Sets the parameter set of the distribution.
+   * @param __param The new parameter set of the distribution.
+   */
+  void
+  param(const param_type __param)
+  { _M_param = __param; }
+
+  /**
+   * @brief Returns the greatest lower bound value of the distribution.
+   */
+  result_type
+  min() const
+  { return -std::numeric_limitsresult_type::max(); }
+
+  /**
+   * @brief Returns the least upper bound value of the distribution.
+   */
+  result_type
+  max() const
+  { return std::numeric_limitsresult_type::max(); }
+
+  /**
+   * @brief Generating functions.
+   */
+  templatetypename _UniformRandomNumberGenerator
+   result_type
+   operator()(_UniformRandomNumberGenerator __urng)
+   {
+ std::__detail::_Adaptor_UniformRandomNumberGenerator, result_type
+   __aurng(__urng);
+
+ result_type __arg = result_type(1);
+ while (__arg == result_type(1) || __arg == result_type(0))
+   __arg = __aurng();
+ return this-param().a()
+  + this-param().b() * std::log(__arg / (result_type(1) - __arg));
+   }
+
+  templatetypename _UniformRandomNumberGenerator
+ 

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

2014-07-10 Thread Ed Smith-Rowland
Here are some C++ versioning changes reflecting C++14 status and adding 
c++1z. It is a followup to Jason's patch on 2014-06-26 adding std=c++1z, 
etc.


This will allow us to start making C++1z changes to the preprocessor 
(n3981 remove trigraphs).


In fact, I made trigraphs opt-in for both c++1z and gnu++1z.

I did not change c-family/c.opt to change wording on options and 
aliasing to document C++14.  Should we do that too?



libcpp/

2014-07-10  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.


gcc/c-family/

2014-07-10  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-07-10  Edward Smith-Rowland  3dw...@verizon.net

* decl.c (compute_array_index_type, grokdeclarator,
undeduced_auto_decl): Change from cxx1y to cxx14.
* 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.
* typeck.c (comp_template_parms_position, cxx_sizeof_or_alignof_type,
cp_build_addr_expr_1, maybe_warn_about_useless_cast): Ditto.
Index: libcpp/include/cpplib.h
===
--- libcpp/include/cpplib.h (revision 212346)
+++ libcpp/include/cpplib.h (working copy)
@@ -166,7 +166,7 @@
 enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11,
 CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11,
 CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11,
-CLK_GNUCXX1Y, CLK_CXX1Y, CLK_ASM};
+CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX1Z, CLK_CXX1Z, CLK_ASM};
 
 /* Payload of a NUMBER, STRING, CHAR or COMMENT token.  */
 struct GTY(()) cpp_string {
Index: libcpp/init.c
===
--- libcpp/init.c   (revision 212346)
+++ libcpp/init.c   (working copy)
@@ -90,26 +90,29 @@
   char user_literals;
   char binary_constants;
   char digit_separators;
+  char trigraphs;
 };
 
 static const struct lang_flags lang_defaults[] =
-{ /*  c99 c++ xnum xid c11 std  //   digr ulit rlit udlit bin_cst 
dig_sep */
-  /* GNUC89   */  { 0,  0,  1,   0,  0,  0,   1,   1,   0,   0,   0,0, 
 0 },
-  /* GNUC99   */  { 1,  0,  1,   0,  0,  0,   1,   1,   1,   1,   0,0, 
 0 },
-  /* GNUC11   */  { 1,  0,  1,   0,  1,  0,   1,   1,   1,   1,   0,0, 
 0 },
-  /* STDC89   */  { 0,  0,  0,   0,  0,  1,   0,   0,   0,   0,   0,0, 
 0 },
-  /* STDC94   */  { 0,  0,  0,   0,  0,  1,   0,   1,   0,   0,   0,0, 
 0 },
-  /* 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 },
-  /* 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 },
-  /* CXX1Y*/  { 1,  1,  1,   0,  1,  1,   1,   1,   1,   1,   1,1, 
 1 },
-  /* ASM  */  { 0,  0,  1,   0,  0,  0,   1,   0,   0,   0,   0,0, 
 0 }
+{ /*  c99 c++ xnum xid c11 std // digr ulit rlit udlit bincst 
digsep trig */
+  /* GNUC89   */  { 0,  0,  1,  0,  0,  0,  1,  1,  0,   0,   0,0, 0,  
   0 },
+  /* GNUC99   */  { 1,  0,  1,  0,  0,  0,  1,  1,  1,   1,   0,0, 0,  
   0 },
+  /* GNUC11   */  { 1,  0,  1,  0,  1,  0,  1,  1,  1,   1,   0,0, 0,  
   0 },
+  /* STDC89   */  { 0,  0,  0,  0,  0,  1,  0,  0,  0,   0,   0,0, 0,  
   1 },
+  /* STDC94   */  { 0,  0,  0,  0,  0,  1,  0,  1,  0,   0,   0,0, 0,  
   1 },
+  /* STDC99   */  { 1,  0,  1,  0,  0,  1,  1,  1,  0,   0,   0,0, 0,  
   1 },
+  /* STDC11   */  { 1,  0,  1,  0,  1,  1, 

[PATCH preprocessor/61389] - libcpp diagnostics shouldn't talk about ISO C99 for C++ input files

2014-07-10 Thread Ed Smith-Rowland
Here is a preprocessor patch to make error messages show C++11 and other 
relevant C++ language instead of C99.


Built and tested on x86_64-linux.

OK?

libcpp/


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

PR CPP/61389
* macro.c (_cpp_arguments_ok, parse_params, create_iso_definition):
Warning messages mention C++11 in c++ mode and C99 in c mode.
* lex.c (lex_identifier_intern, lex_identifier): Ditto
Index: libcpp/macro.c
===
--- libcpp/macro.c  (revision 212423)
+++ libcpp/macro.c  (working copy)
@@ -713,19 +713,27 @@
 
   if (argc  macro-paramc)
 {
-  /* As an extension, a rest argument is allowed to not appear in
+  /* As an extension, variadic arguments are allowed to not appear in
 the invocation at all.
 e.g. #define debug(format, args...) something
 debug(string);
 
-This is exactly the same as if there had been an empty rest
-argument - debug(string, ).  */
+This is exactly the same as if an empty variadic list had been
+supplied - debug(string, ).  */
 
   if (argc + 1 == macro-paramc  macro-variadic)
{
  if (CPP_PEDANTIC (pfile)  ! macro-syshdr)
-   cpp_error (pfile, CPP_DL_PEDWARN,
-  ISO C99 requires rest arguments to be used);
+   {
+ if (CPP_OPTION (pfile, cplusplus))
+   cpp_error (pfile, CPP_DL_PEDWARN,
+  ISO C++11 requires at least one argument 
+  for the \...\ in a variadic macro);
+ else
+   cpp_error (pfile, CPP_DL_PEDWARN,
+  ISO C99 requires at least one argument 
+  for the \...\ in a variadic macro);
+   }
  return true;
}
 
@@ -1748,12 +1756,20 @@
! CPP_OPTION (pfile, c99)
! cpp_in_system_header (pfile))
{
- cpp_error (pfile, CPP_DL_PEDWARN,
-invoking macro %s argument %d: 
-empty macro arguments are undefined
- in ISO C90 and ISO C++98,
-NODE_NAME (node),
-src-val.macro_arg.arg_no);
+ if (CPP_OPTION (pfile, cplusplus))
+   cpp_error (pfile, CPP_DL_PEDWARN,
+  invoking macro %s argument %d: 
+  empty macro arguments are undefined
+   in ISO C++98,
+  NODE_NAME (node),
+  src-val.macro_arg.arg_no);
+ else
+   cpp_error (pfile, CPP_DL_PEDWARN,
+  invoking macro %s argument %d: 
+  empty macro arguments are undefined
+   in ISO C90,
+  NODE_NAME (node),
+  src-val.macro_arg.arg_no);
}
 
   /* Avoid paste on RHS (even case count == 0).  */
@@ -2798,14 +2814,27 @@
  if (! CPP_OPTION (pfile, c99)
   CPP_OPTION (pfile, cpp_pedantic)
   CPP_OPTION (pfile, warn_variadic_macros))
-   cpp_pedwarning
-  (pfile, CPP_W_VARIADIC_MACROS,
-  anonymous variadic macros were introduced in C99);
+   {
+ if (CPP_OPTION (pfile, cplusplus))
+   cpp_pedwarning
+   (pfile, CPP_W_VARIADIC_MACROS,
+   anonymous variadic macros were introduced in C++11);
+ else
+   cpp_pedwarning
+   (pfile, CPP_W_VARIADIC_MACROS,
+   anonymous variadic macros were introduced in C99);
+   }
}
  else if (CPP_OPTION (pfile, cpp_pedantic)
CPP_OPTION (pfile, warn_variadic_macros))
-   cpp_pedwarning (pfile, CPP_W_VARIADIC_MACROS,
+   {
+ if (CPP_OPTION (pfile, cplusplus))
+   cpp_pedwarning (pfile, CPP_W_VARIADIC_MACROS,
+   ISO C++ does not permit named variadic macros);
+ else
+   cpp_pedwarning (pfile, CPP_W_VARIADIC_MACROS,
ISO C does not permit named variadic macros);
+   }
 
  /* We're at the end, and just expect a closing parenthesis.  */
  token = _cpp_lex_token (pfile);
@@ -2894,11 +2923,17 @@
   else if (ctoken-type != CPP_EOF  !(ctoken-flags  PREV_WHITE))
 {
   /* While ISO C99 requires whitespace before replacement text
-in a macro definition, ISO C90 with TC1 allows there characters
-from the basic source character set.  */
+in a macro definition, ISO C90 with TC1 allows characters
+from the basic source character set there.  */
   if (CPP_OPTION (pfile, c99))
-   cpp_error (pfile, CPP_DL_PEDWARN,
-  ISO C99 requires whitespace after the 

[PATCH libstdc++] Buglet in gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C

2014-07-10 Thread Ed Smith-Rowland

Index: gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C
===
--- gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C(revision 212440)
+++ gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C(working copy)
@@ -7,7 +7,7 @@
   i = 1048''576; // { dg-error adjacent digit separators }
   i = 0X'10; // { dg-error digit separator after base indicator }
   i = 0x'10; // { dg-error digit separator after base indicator }
-  i = 0004''000'000); // { dg-error adjacent digit separators }
+  i = 0004''000'000; // { dg-error adjacent digit separators }
   i = 0B1'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0; // OK
   i = 0b'0001'''''; // { dg-error digit separator 
after base indicator }
   i = 0b0001''''''; // { dg-error digit separator 
outside digit sequence }


Stray paste-o right paren.
Fixed as obvious.



[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
barBAZ
#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
+
+barBAZ
+
+R(
+  bar
+)BAZ
+
+#endif


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 %operator% 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 = TREE_INT_CST_LOW 

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 paolo.carlini at oracle dot com ---
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  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.

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 char...
-   or typename CharT, CharT...,
-  decl);
+   {
+ if (cxx_dialect = cxx1y)
+   error (literal operator template %qD has invalid parameter list.
+Expected non-type template argument pack char...
+   or typename CharT, CharT...,
+  decl);
+ else
+   error (literal operator template %qD has invalid parameter list.
+Expected non-type template argument pack char...,
+  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 cstddef
+
+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 iostream
+using namespace std;
+
+// constant
+templatetypename T, T x
+  struct meta_value
+  {
+typedef meta_value type;
+typedef T value_type;
+static const T value = x;
+  };
+
+// array
+templatetypename T, T... data
+  struct meta_array
+  {
+typedef meta_array type;
+typedef T item_type;
+  };
+
+// static array - runtime array conversion utility
+templatetypename T
+  struct array_gen;
+
+templatetypename T, 

[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 char...
-   or typename CharT, CharT...,
-  decl);
+   {
+ if (cxx_dialect = cxx1y)
+   error (literal operator template %qD has invalid parameter list.
+Expected non-type template argument pack char...
+   or typename CharT, CharT...,
+  decl);
+ else
+   error (literal operator template %qD has invalid parameter list.
+Expected non-type template argument pack char...,
+  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 cstddef
+
+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 iostream
+using namespace std;
+
+// constant
+templatetypename T, T x
+  struct meta_value
+  {
+typedef meta_value type;
+typedef T value_type;
+static const T value = x;
+  };
+
+// array
+templatetypename T, T... data

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: [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-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


[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 *pfile, enum include_type type)
+{
+  cpp_num result;
+  bool paren = false;
+  cpp_hashnode *node = 0;
+  const cpp_token *token;
+  bool bracket = false;
+  char *fname = 0

[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 plusvoid
 {
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
+
   templatetypename _Tp
 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 bits/c++0x_warning.h
 #else
 
+#undef __cpp_lib_constexpr_functions
+#define __cpp_lib_constexpr_functions 201210
+
 #include stdexcept
 #include bits/stl_algobase.h
 #include bits/range_access.h
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::complexfloat
   operatorif(long double __num)
   { return std::complexfloat{0.0F, static_castfloat(__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 testinc }
+
+// Begin C++11 tests.
+
+#ifndef __cpp_unicode_characters
+#  error __cpp_unicode_characters
+#endif
+
+#ifndef __cpp_raw_strings
+#  error __cpp_raw_strings
+#endif
+
+#ifndef __cpp_unicode_literals
+#  error __cpp_unicode_literals
+#endif
+
+#ifndef __cpp_user_defined_literals
+#  error __cpp_user_defined_literals
+#endif
+
+#ifndef __cpp_lambdas
+#  error __cpp_lambdas
+#endif
+
+#ifndef __cpp_constexpr
+#  error __cpp_constexpr
+#endif
+
+#ifndef __cpp_static_assert
+#  error __cpp_static_assert
+#endif
+
+#ifndef

[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 locale
+#if __cplusplus  201103L
+#include sstream // 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.
  */
 templatetypename _String, typename _CharT
   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
  */
 templatetypename _CharT, typename _Traits
   auto
@@ -372,21 +376,24 @@
   operator(std::basic_ostream_CharT, _Traits __os,
 const _Quoted_stringconst _CharT*, _CharT __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
  */
 templatetypename _CharT, typename _Traits, typename _String
   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 sstream
+#include iomanip
+#include testsuite_hooks.h
+
+void
+test01()
+{
+  bool test [[gnu::unused]] = true;
+
+  std::ostringstream ssx;
+  ssx  [  std::left  std::setfill('x')  std::setw(20)  R(AB 
\CD\ EF)  ];
+  VERIFY( ssx.str() == R([AB

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 locale
+#include sstream // used in quoted.


We really only need sstream 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\ EFxx]
  //  Gives: [AB \CD\ EFxx]
  std::cout  [  std::left  std::setfill('x')  std::setw(20) 
 R(AB \CD\ EF)  ]  std::endl;

  //  Should be: [GH \IJ\ KLyy]
  //  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\ EFxx]
[

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 locale
+#if __cplusplus  201103L
+#include sstream // 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.
  */
 templatetypename _String, typename _CharT
   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
  */
 templatetypename _CharT, typename _Traits
   auto
@@ -372,21 +376,24 @@
   operator(std::basic_ostream_CharT, _Traits __os,
 const _Quoted_stringconst _CharT*, _CharT __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
  */
 templatetypename _CharT, typename _Traits, typename _String
   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 sstream
+#include iomanip
+#include testsuite_hooks.h
+
+void
+test01()
+{
+  bool test [[gnu::unused]] = true;
+
+  std::ostringstream ssx;
+  ssx  [  std::left  std::setfill('x')  std::setw(20)  R(AB 
\CD\ EF)  ];
+  VERIFY( ssx.str() == R([AB \CD\ EFxx]) );
+
+  std::ostringstream ssy;
+  ssy  [  std::left  std::setfill('y')  std::setw(20)  
std::quoted(R(GH IJ KL

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  rguent...@suse.de

 * 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 locale
+#include sstream // used in quoted.


We really only need sstream 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 locale
+#if __cplusplus  201103L
+#include sstream // 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.
  */
 templatetypename _String, typename _CharT
   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
  */
 templatetypename _CharT, typename _Traits
   auto
@@ -372,21 +376,24 @@
   operator(std::basic_ostream_CharT, _Traits __os,
 const _Quoted_stringconst _CharT*, _CharT __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
  */
 templatetypename _CharT, typename _Traits, typename _String
   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 option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even

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






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

2014-05-30 Thread Ed Smith-Rowland
A group within the C++ standards committee was charged with the 
responibility of coming up with a way for users to test a C++ compiler 
and runtime for the availability of new features.  These features are 
intended to aid users in a time of intense C++ evolution.  These 
features are not really part of the C++ standard and probably can't be 
really.


The latest paper is:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4030.htm

Also, an earlier version is supplied as a standing document on the 
isocpp website:

https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations

The current patch implements __has_include and many of the language 
feature and library version macros outlined in these documents.


I builds and tests clean on x86_64-linux.

I anticipate that the next C++ meeting will see some additions (new 
library and language macros and a __has_cpp_attribute).  I will add 
these as a separate patch if needed.


I took the liberty of adding __has_include_next.  clang has both 
__has_include and __has_include_next.  Also, while the underlying cpp 
builtin that supports __has_include, __has_include__, is available to C 
and C++ in all language versions, the macro __has_include is only 
available for C++11 onwards.  One could however anticipate that this 
feature has utility for all C/C++ users.  What do you think?


Ed



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

2014-05-30 Thread Ed Smith-Rowland
This is the c-family part: Setting the language feature macos and 
defining the __has_include macro.



c-family:

2014-05-31  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.


libstdc++:

2014-05-31  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: c-family/c-cppbuiltin.c
===
--- c-family/c-cppbuiltin.c (revision 211078)
+++ c-family/c-cppbuiltin.c (working copy)
@@ -805,7 +805,43 @@
   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, __has_include(STR)=__has_include__(STR));
+ cpp_define (pfile,
+ __has_include_next(STR)=__has_include_next__(STR));
+
+ 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.  */
Index: testsuite/g++.dg/cpp1y/feat-cxx11-neg.C
===
--- testsuite/g++.dg/cpp1y/feat-cxx11-neg.C (revision 0)
+++ testsuite/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: testsuite/g++.dg/cpp1y/feat-cxx11.C
===
--- testsuite/g++.dg/cpp1y/feat-cxx11.C (revision 0)
+++ testsuite/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

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

2014-05-30 Thread Ed Smith-Rowland

Here is the libcpp portion.

2014-05-31  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: directives.c
===
--- directives.c(revision 211078)
+++ 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 211078)
+++ 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 *pfile, enum include_type type)
+{
+  cpp_num result;
+  bool paren = false;
+  cpp_hashnode *node = 0;
+  const cpp_token *token;
+  bool bracket = false;
+  char *fname = 0;
+
+  result.unsignedp = false;
+  result.high = 0;
+  result.overflow = false;
+  result.low = 0;
+
+  pfile-state.in__has_include__++;
+
+  token = cpp_get_token (pfile);
+  if (token-type == CPP_OPEN_PAREN)
+{
+  paren = true;
+  token = cpp_get_token (pfile);
+}
+  if (token-type == CPP_STRING || token-type == CPP_HEADER_NAME)
+{
+  if (token-type == CPP_HEADER_NAME)
+   bracket = true;
+  fname = XNEWVEC (char, token-val.str.len - 1);
+  memcpy (fname, token-val.str.text + 1, token-val.str.len - 2);
+  fname[token-val.str.len - 2] = '\0';
+  node = token-val.node.node;
+}
+  else if (token-type == CPP_LESS)
+{
+  bracket = true;
+  fname = _cpp_bracket_include (pfile);
+}
+  else
+cpp_error (pfile, CPP_DL_ERROR,
+  operator \__has_include__\ requires a header string);
+
+  if (fname)
+{
+  int angle_brackets = (bracket ? 1 : 0);
+
+  if (_cpp_has_header (pfile, fname, angle_brackets, type))
+   result.low = 0;
+  else
+   result.low = 1;
+
+  XDELETEVEC (fname);
+}
+
+  if (paren  cpp_get_token (pfile)-type != CPP_CLOSE_PAREN)
+cpp_error (pfile, CPP_DL_ERROR,
+  missing ')' after \__has_include__\);
+
+  /* A possible controlling macro of the form #if !__has_include__ ().
+ _cpp_parse_expr checks there was no other junk on the line.  */
+  if (node)
+pfile-mi_ind_cmacro = node;
+
+  pfile-state.in__has_include__--;
+
+  return result;
+}
Index: files.c
===
--- files.c (revision 211078)
+++ files.c (working copy)
@@ -1029,6 +1029,9 @@
   int sysp = pfile-line_table

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

2014-05-30 Thread Ed Smith-Rowland

This is the libstdc++ and libstdc++ testsuite part.

2014-05-31  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.
Index: include/bits/basic_string.h
===
--- include/bits/basic_string.h (revision 211078)
+++ 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 211078)
+++ 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 211078)
+++ 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 plusvoid
 {
Index: include/bits/unique_ptr.h
===
--- include/bits/unique_ptr.h   (revision 211078)
+++ include/bits/unique_ptr.h   (working copy)
@@ -743,6 +743,9 @@
 };
 
 #if __cplusplus  201103L
+
+#define __cpp_lib_make_unique 201304
+
   templatetypename _Tp
 struct _MakeUniq
 { typedef unique_ptr_Tp __single_object; };
Index: include/std/array
===
--- include/std/array   (revision 211078)
+++ include/std/array   (working copy)
@@ -35,6 +35,8 @@
 # include bits/c++0x_warning.h
 #else
 
+#define __cpp_lib_constexpr_functions 201210
+
 #include stdexcept
 #include bits/stl_algobase.h
 #include bits/range_access.h
Index: include/std/chrono
===
--- include/std/chrono  (revision 211078)
+++ include/std/chrono  (working copy)
@@ -43,6 +43,8 @@
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
 
+#define __cpp_lib_constexpr_functions 201210
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
   /**
@@ -782,6 +784,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 211078)
+++ include/std/complex (working copy)
@@ -1929,6 +1929,8 @@
 inline namespace literals {
 inline namespace complex_literals {
 
+#define __cpp_lib_complex_udls 201309
+
   constexpr std::complexfloat
   operatorif(long double __num)
   { return std::complexfloat{0.0F, static_castfloat(__num)}; }
Index: include/std/iomanip
===
--- include/std/iomanip (revision 211078)
+++ include/std/iomanip (working copy)
@@ -336,6 +336,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
===
--- include/std/mutex   (revision 211078)
+++ include/std/mutex   (working copy)
@@ -35,6 +35,9 @@
 # include bits/c++0x_warning.h
 #else
 
+// For backwards compatibility of SD-6.
+#define __cpp_lib_shared_mutex 201304
+
 #include tuple
 #include chrono
 #include exception
Index: include/std/shared_mutex
===
--- include/std/shared_mutex(revision 211078)
+++ 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_mutex 201402
+
   /// shared_timed_mutex
   class shared_timed_mutex
   {
Index: include/std/tuple
===
--- include/std/tuple   (revision 211078)
+++ include/std/tuple   (working copy)
@@ -744,6

Re: [PATCH, libstdc++/61166] overflow when parse number in std::duration operator

2014-05-15 Thread Ed Smith-Rowland

On 05/15/2014 03:03 PM, Jonathan Wakely wrote:

Here's a finished patch to simplify bits/parse_numbers.h

Tested x86_64-linux. Ed, any objection to this version?


This looks great, thanks!

Having done that should we actually stop using it as suggested in the 
bug trail? ;-)




[PATCH, libstdc++/61166] overflow when parse number in std::duration operator

2014-05-14 Thread Ed Smith-Rowland

Make the machinery in bits/parse_number.h unsigned long long.
I had actually noticed this a while back but we were in stage 4. Then I 
forgot.. :-/


Built and tested on x84_64-linux.

OK?


2014-05-14  Ed Smith-Rowland  3dw...@verizon.net

libstdc++/61166 overflow when parse number in std::duration operator
* include/bits/parse_numbers.h: Make the machinery unsigned long long.
* testsuite/20_util/duration/literals/pr61166.cc: New.
Index: include/bits/parse_numbers.h
===
--- include/bits/parse_numbers.h(revision 210315)
+++ include/bits/parse_numbers.h(working copy)
@@ -27,8 +27,8 @@
  *  Do not attempt to use it directly. @headername{chrono}
  */
 
-#ifndef _PARSE_NUMBERS_H
-#define _PARSE_NUMBERS_H 1
+#ifndef _GLIBCXX_PARSE_NUMBERS_H
+#define _GLIBCXX_PARSE_NUMBERS_H 1
 
 #pragma GCC system_header
 
@@ -36,262 +36,278 @@
 
 #if __cplusplus  201103L
 
+#include limits
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-namespace __parse_int {
+namespace __parse_int
+{
 
-  templateunsigned _Base, char _Dig
+  templateunsigned long long _Base, char _Dig
 struct _Digit;
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '0'
 {
   static constexpr bool valid{true};
-  static constexpr unsigned value{0};
+  static constexpr unsigned long long value{0};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '1'
 {
   static constexpr bool valid{true};
-  static constexpr unsigned value{1};
+  static constexpr unsigned long long value{1};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '2'
 {
   static_assert(_Base  2, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{2};
+  static constexpr unsigned long long value{2};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '3'
 {
   static_assert(_Base  3, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{3};
+  static constexpr unsigned long long value{3};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '4'
 {
   static_assert(_Base  4, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{4};
+  static constexpr unsigned long long value{4};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '5'
 {
   static_assert(_Base  5, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{5};
+  static constexpr unsigned long long value{5};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '6'
 {
   static_assert(_Base  6, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{6};
+  static constexpr unsigned long long value{6};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '7'
 {
   static_assert(_Base  7, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{7};
+  static constexpr unsigned long long value{7};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '8'
 {
   static_assert(_Base  8, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{8};
+  static constexpr unsigned long long value{8};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, '9'
 {
   static_assert(_Base  9, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{9};
+  static constexpr unsigned long long value{9};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, 'a'
 {
   static_assert(_Base  0xa, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{0xa};
+  static constexpr unsigned long long value{0xa};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, 'A'
 {
   static_assert(_Base  0xa, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{0xa};
+  static constexpr unsigned long long value{0xa};
 };
 
-  templateunsigned _Base
+  templateunsigned long long _Base
 struct _Digit_Base, 'b'
 {
   static_assert(_Base  0xb, invalid digit);
   static constexpr bool valid{true};
-  static constexpr unsigned value{0xb};
+  static constexpr unsigned long long value{0xb};
 };
 
-  templateunsigned _Base

Re: [PATCH, libstdc++/61166] overflow when parse number in std::duration operator

2014-05-14 Thread Ed Smith-Rowland

On 05/14/2014 09:59 AM, Daniel Krügler wrote:

2014-05-14 15:38 GMT+02:00 Ed Smith-Rowland 3dw...@verizon.net:

Make the machinery in bits/parse_number.h unsigned long long.
I had actually noticed this a while back but we were in stage 4. Then I
forgot.. :-/

Built and tested on x84_64-linux.

OK?

I understand the reason why the corresponding static members value got
type unsigned long long, but why did the template parameter _Base also
require the same update?

Another question: Presumably value indded requires no uglification,
but what about the member valid? I would expect that this is no name
reserved by the library.

- Daniel



You're right, _Base doesn't need that - only 2, 8, 10, 16 allowed (could 
do base64 someday, but still).  Change all got me.


I should uglify the valid members.
But in keeping with, say, our extension type traits and such maybe i 
should uglify value as well.




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

2014-05-13 Thread Ed Smith-Rowland

On 05/13/2014 01:29 PM, Joseph S. Myers wrote:

On Mon, 12 May 2014, Ed Smith-Rowland wrote:


This patch is really a libcpp patch.  But UDLs are like that ;-)

Add string user-defined literals and char user-defined literals to the list of
things to look out for while escaping strings in macro args.

I'm not sure how to test this really.  we want to write out *.ii files and
verify that internal quotes are escaped.

You should be able to check the results of stringizing twice, e.g.:

extern C int strcmp (const char *, const char *);
extern C void abort (void);
extern C void exit (int);

void operator  _s(const char *, unsigned long)
{
}

#define QUOTE(s) #s
#define QQUOTE(s) QUOTE(s)

const char *s = QQUOTE(QUOTE(hello_s));
const char *t = QUOTE(\hello\_s);

int main()
{
   if (strcmp(s, t) == 0)
 exit(0);
   else
 abort();
}

(at least, this fails for me with unmodified GCC, and I think it should
pass).


Thank you Joe!

Here is a new patch with a proper test case.

Built and tested on x86_64-linux.

OK?

Ed

Index: macro.c
===
--- macro.c (revision 210315)
+++ macro.c (working copy)
@@ -494,6 +494,9 @@
   || token-type == CPP_STRING16 || token-type == CPP_CHAR16
   || token-type == CPP_UTF8STRING);
 
+  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);
Index: ../gcc/testsuite/g++.dg/cpp0x/pr61038.C
===
--- ../gcc/testsuite/g++.dg/cpp0x/pr61038.C (revision 0)
+++ ../gcc/testsuite/g++.dg/cpp0x/pr61038.C (working copy)
@@ -0,0 +1,40 @@
+// PR c++/61038
+// { dg-do compile { target c++11 } }
+
+#include cstring
+#include cstdlib
+
+void
+operator  _s(const char *, unsigned long)
+{ }
+
+void
+operator  _t(const char)
+{ }
+
+#define QUOTE(s) #s
+#define QQUOTE(s) QUOTE(s)
+
+int
+main()
+{
+  const char *s = QQUOTE(QUOTE(hello_s));
+  const char *t = QUOTE(\hello\_s);
+  if (strcmp(s, t) != 0)
+abort();
+
+  const char *c = QQUOTE(QUOTE(''_t));
+  const char *d = QUOTE('\'_t);
+  if (strcmp(c, d) != 0)
+abort();
+
+  const char *e = QQUOTE(QUOTE('\''_t));
+  const char *f = QUOTE('\\''_t);
+  if (strcmp(e, f) != 0)
+abort();
+
+  const char *g = QQUOTE(QUOTE('\\'_t));
+  const char *h = QUOTE(''_t);
+  if (strcmp(g, h) != 0)
+abort();
+}

libcpp/

2014-05-12  Edward Smith-Rowland  3dw...@verizon.net

PR C++/61038
* macro.c (stringify_arg (cpp_reader *, macro_arg *)):
Check for user-defined literal strings and user-defined literal chars
to escape necessary characters.


gcc/testsuite/

2014-05-12  Edward Smith-Rowland  3dw...@verizon.net

PR C++/61038
* g++.dg/cpp0x/pr61038.C: New.



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

2014-05-12 Thread Ed Smith-Rowland

This patch is really a libcpp patch.  But UDLs are like that ;-)

Add string user-defined literals and char user-defined literals to the 
list of things to look out for while escaping strings in macro args.


I'm not sure how to test this really.  we want to write out *.ii files 
and verify that internal quotes are escaped.


Built and tested on x86_64-linux.
OK?


libcpp/

2014-05-12  Edward Smith-Rowland  3dw...@verizon.net

PR C++/61038
* macro.c (stringify_arg (cpp_reader *, macro_arg *)):
Check for user-defined literal strings and user-defined literal chars
to escape necessary characters.


gcc/testsuite/

2014-05-12  Edward Smith-Rowland  3dw...@verizon.net

PR C++/61038
* g++.dg/cpp0x/pr61038.C: New.

Index: macro.c
===
--- macro.c (revision 210315)
+++ macro.c (working copy)
@@ -494,6 +494,9 @@
   || token-type == CPP_STRING16 || token-type == CPP_CHAR16
   || token-type == CPP_UTF8STRING);
 
+  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);
Index: ../gcc/testsuite/g++.dg/cpp0x/pr61038.C
===
--- ../gcc/testsuite/g++.dg/cpp0x/pr61038.C (revision 0)
+++ ../gcc/testsuite/g++.dg/cpp0x/pr61038.C (working copy)
@@ -0,0 +1,23 @@
+// PR c++/61038
+// { dg-do compile { target c++11 } }
+// { dg-options -E }
+
+void
+operator  _s(const char *, unsigned long)
+{ }
+
+void
+operator  _t(const char)
+{ }
+
+#define QUOTE(s) #s
+
+int
+main()
+{
+  QUOTE(hello_s);
+
+  QUOTE(''_t);
+  QUOTE('\''_t);
+  QUOTE('\\'_t);
+}


Re: Make string_view operations involving CharT* *not* noexcept and consistent beween string_view and string_view.tcc.

2014-04-16 Thread Ed Smith-Rowland

On 04/15/2014 03:06 PM, Jonathan Wakely wrote:

On 29/03/14 14:54 -0400, Ed Smith-Rowland wrote:

All,

In string_view I botched the noexcept specification of operations 
like find and friends with CharT* arguments.


I'm a little surprised the inconsistency between string_view and 
string_view.tcc didn't error.  In fact, in one repo thats a little 
behind trunk it does.  I'll continue to look after that issue 
separately.


I'm fixing this differently, by strengthening the exception specs as
Marc suggested. I haven't addressed Marc's other comments, but we
should do.

Tested x86_64-linux, committed to trunk.

Thanks,

The latest library fundamentals paper has a lot of changes coming - a 
lot of constexpr in the find type functions.  Unfortunately, most of 
that will wave to wait until we get C++14 constexpr.


Also, if the built-in strlen is or could be made constexpr then all the 
char* ctors could be constexpr as well.




Re: Try to catch up _GLIBCXX_RESOLVE_LIB_DEFECTS comments and documentation.

2014-03-16 Thread Ed Smith-Rowland

On 03/16/2014 08:43 AM, Jonathan Wakely wrote:

On 15 March 2014 14:46, Ed Smith-Rowland wrote:

I'm resending this because I forgot to dupe to gcc-patches and I'd like one
thread.

This should be pure commentary and documentation.

I hope I got all these.  I grepped for DR and added
_GLIBCXX_RESOLVE_LIB_DEFECTS where it seemed needed.
I did not add in cases where DR mentions were more commentary.

Then I added the new _GLIBCXX_RESOLVE_LIB_DEFECTS to the xml intro page.

OK?  Can anyone think of one I left out?

In many of these cases I'd actually prefer to remove the comment
mentioning a DR, rather than add the RESOLVE_LIB_DEFECTS marker.

For example:

DR 1204: this says we don't need to check for self-move-assignment. It
applies to every move assignment operator in the library. It is not a
defect against C++03, and the resolution is part of the final C++11
standard, so I don't think we should document that we implement it.

DR 1261: another one with C++11 status, meaning it was included in
the C++11 standard, and this one also isn't relevant to C++03, so of
course we implement it, and we shouldn't even mention it in comments
or docs.

DR 675, DR 776: these aren't relevant to C++03, and are part of C++11
(since the CD1 draft)

So I think adding RESOLVE_LIB_DEFECTS is the wrong thing to do, I'd
rather not touch them.  Personally I'm in favour of completely remove
any mention of DRs that are fixes to C++0x drafts, not post-C++11
fixes, but that might be more controversial.

OK, thinking further on it I actually agree with not mentioning DRs on a 
partially baked standard.  We advertise that support for new standards 
is experimental.


This whole thing is less of a deal now that the standard is moving so 
quickly and problems are easily incorporated into the next standard.


I'll put something new out tonight or tomorrow.



Try to catch up _GLIBCXX_RESOLVE_LIB_DEFECTS comments and documentation.

2014-03-15 Thread Ed Smith-Rowland
I'm resending this because I forgot to dupe to gcc-patches and I'd like 
one thread.


This should be pure commentary and documentation.

I hope I got all these.  I grepped for DR and added 
_GLIBCXX_RESOLVE_LIB_DEFECTS where it seemed needed.

I did not add in cases where DR mentions were more commentary.

Then I added the new _GLIBCXX_RESOLVE_LIB_DEFECTS to the xml intro page.

OK?  Can anyone think of one I left out?

Ed


2014-03-15  Ed Smith-Rowland  3dw...@verizon.net

* include/bits/allocator.h: Add CL_GLIBCXX_RESOLVE_LIB_DEFECTS.
* include/bits/basic_string.h: Ditto.
* include/bits/hashtable.h: Ditto.
* include/bits/istream.tcc: Ditto.
* include/bits/stl_algo.h: Ditto.
* include/bits/stl_algobase.h: Ditto.
* include/bits/stl_bvector.h: Ditto.
* include/bits/stl_deque.h: Ditto.
* include/std/array: Ditto.
* include/std/bitset: Ditto.
* include/std/chrono: Ditto.
* include/std/complex: Ditto.
* include/std/condition_variable: Ditto.
* include/std/system_error: Ditto.
* include/std/thread: Ditto.
* include/std/tuple: Ditto.
* include/std/type_traits: Ditto.
* doc/xml/manual/intro.xml: Add implemented DRs to Standard Bugs list.


Index: include/bits/allocator.h
===
--- include/bits/allocator.h(revision 208526)
+++ include/bits/allocator.h(working copy)
@@ -155,6 +155,7 @@
   // Undefine.
 #undef __allocator_base
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // To implement Option 3 of DR 431.
   templatetypename _Alloc, bool = __is_empty(_Alloc)
 struct __alloc_swap
Index: include/bits/basic_string.h
===
--- include/bits/basic_string.h (revision 208526)
+++ include/bits/basic_string.h (working copy)
@@ -588,6 +588,7 @@
   basic_string
   operator=(basic_string __str)
   {
+   // _GLIBCXX_RESOLVE_LIB_DEFECTS
// NB: DR 1204.
this-swap(__str);
return *this;
@@ -2878,6 +2879,7 @@
 
   // NB: (v)snprintf vs sprintf.
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // DR 1261.
   inline string
   to_string(int __val)
@@ -2979,6 +2981,7 @@
   stold(const wstring __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(std::wcstold, stold, __str.c_str(), __idx); }
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // DR 1261.
   inline wstring
   to_wstring(int __val)
@@ -3055,6 +3058,7 @@
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // DR 1182.
 
 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
Index: include/bits/hashtable.h
===
--- include/bits/hashtable.h(revision 208526)
+++ include/bits/hashtable.h(working copy)
@@ -527,6 +527,7 @@
   end(size_type __n) const
   { return const_local_iterator(*this, nullptr, __n, _M_bucket_count); }
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // DR 691.
   const_local_iterator
   cbegin(size_type __n) const
@@ -723,6 +724,7 @@
   // Set number of buckets to be appropriate for container of n element.
   void rehash(size_type __n);
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // DR 1189.
   // reserve, if present, comes from _Rehash_base.
 
Index: include/bits/istream.tcc
===
--- include/bits/istream.tcc(revision 208526)
+++ include/bits/istream.tcc(working copy)
@@ -781,7 +781,7 @@
 sync(void)
 {
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
-  // DR60.  Do not change _M_gcount.
+  // DR 60.  Do not change _M_gcount.
   int __ret = -1;
   sentry __cerb(*this, true);
   if (__cerb)
@@ -817,7 +817,7 @@
 tellg(void)
 {
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
-  // DR60.  Do not change _M_gcount.
+  // DR 60.  Do not change _M_gcount.
   pos_type __ret = pos_type(-1);
   sentry __cerb(*this, true);
   if (__cerb)
@@ -845,7 +845,7 @@
 seekg(pos_type __pos)
 {
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
-  // DR60.  Do not change _M_gcount.
+  // DR 60.  Do not change _M_gcount.
   // Clear eofbit per N3168.
   this-clear(this-rdstate()  ~ios_base::eofbit);
   sentry __cerb(*this, true);
@@ -884,7 +884,7 @@
 seekg(off_type __off, ios_base::seekdir __dir)
 {
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
-  // DR60.  Do not change _M_gcount.
+  // DR 60.  Do not change _M_gcount.
   // Clear eofbit per N3168.
   this-clear(this-rdstate()  ~ios_base::eofbit);
   sentry __cerb(*this, true);
Index: include/bits/stl_algo.h
===
--- include/bits/stl_algo.h (revision 208526)
+++ include/bits/stl_algo.h (working copy)
@@ -3433,6 +3433,7 @@
   __gnu_cxx::__ops::__iter_comp_iter(__comp

PATCH to add -std=c++14

2014-03-11 Thread Ed Smith-Rowland

Why not also -std=gnu++14?



[C++ Patch] PR 50025 - [DR 1288] C++0x initialization syntax doesn't work for class members of reference type

2014-03-01 Thread Ed Smith-Rowland

Built and tested on x86-64-linux.

This is just a test case.

2014-03-01  Edward Smith-Rowland  3dw...@verizon.net

PR c++/50025
* g++.dg/cpp0x/pr50025.C: New.

Index: g++.dg/cpp0x/pr50025.C
===
--- g++.dg/cpp0x/pr50025.C  (revision 0)
+++ g++.dg/cpp0x/pr50025.C  (working copy)
@@ -0,0 +1,40 @@
+// { dg-options -std=gnu++11 }
+
+#include utility
+
+class A
+{
+public:
+
+  A(int a, int b, int c)
+  : m_a{a},
+m_b{b},
+m_c{std::move(c)}
+  {}
+
+private:
+
+  int m_a;
+  int m_b;
+  int m_c;
+};
+
+
+struct X {};
+
+class B
+{
+public:
+
+  B(X q, X r, const X s)
+  : m_q{q},
+m_r{std::move(r)},
+m_s{s}
+  {}
+
+private:
+
+  X m_q;
+  X m_r;
+  const X m_s;
+};


[libstdc++-v3] Move shared_mutex to shared_timed_mutex - late C++14 change (n3891)

2014-02-21 Thread Ed Smith-Rowland

This are the patches as applied

Built and tested x86_64-linux.

2014-02-20  Ed Smith-Rowland  3dw...@verizon.net

Rename shared_mutex to shared_timed_mutex per C++14 acceptance of N3891.
* include/std/shared_mutex: Rename shared_mutex to shared_timed_mutex.
* testsuite/30_threads/shared_lock/locking/2.cc: Ditto.
* testsuite/30_threads/shared_lock/locking/4.cc: Ditto.
* testsuite/30_threads/shared_lock/locking/1.cc: Ditto.
* testsuite/30_threads/shared_lock/locking/3.cc: Ditto.
* testsuite/30_threads/shared_lock/requirements/
explicit_instantiation.cc: Ditto.
* testsuite/30_threads/shared_lock/requirements/typedefs.cc: Ditto.
* testsuite/30_threads/shared_lock/cons/2.cc: Ditto.
* testsuite/30_threads/shared_lock/cons/4.cc: Ditto.
* testsuite/30_threads/shared_lock/cons/1.cc: Ditto.
* testsuite/30_threads/shared_lock/cons/6.cc: Ditto.
* testsuite/30_threads/shared_lock/cons/3.cc: Ditto.
* testsuite/30_threads/shared_lock/cons/5.cc: Ditto.
* testsuite/30_threads/shared_lock/modifiers/2.cc: Ditto.
* testsuite/30_threads/shared_lock/modifiers/1.cc: Ditto.
* testsuite/30_threads/shared_mutex/requirements/
standard_layout.cc: Ditto.
* testsuite/30_threads/shared_mutex/cons/copy_neg.cc: Ditto.
* testsuite/30_threads/shared_mutex/cons/1.cc: Ditto.
* testsuite/30_threads/shared_mutex/cons/assign_neg.cc: Ditto.
* testsuite/30_threads/shared_mutex/try_lock/2.cc: Ditto.
* testsuite/30_threads/shared_mutex/try_lock/1.cc: Ditto.
2014-02-21  Ed Smith-Rowland  3dw...@verizon.net

Rename testsuite directory shared_mutex to shared_timed_mutex
for consistency.
* testsuite/30_threads/shared_mutex: Moved to...
* testsuite/30_threads/shared_timed_mutex: ...here
Index: include/std/shared_mutex
===
--- include/std/shared_mutex(revision 207061)
+++ include/std/shared_mutex(working copy)
@@ -52,8 +52,8 @@
*/
 
 #if defined(_GLIBCXX_HAS_GTHREADS)  defined(_GLIBCXX_USE_C99_STDINT_TR1)
-  /// shared_mutex
-  class shared_mutex
+  /// shared_timed_mutex
+  class shared_timed_mutex
   {
 #if _GTHREAD_USE_MUTEX_TIMEDLOCK
 struct _Mutex : mutex, __timed_mutex_impl_Mutex
@@ -84,15 +84,15 @@
 static constexpr unsigned _M_n_readers = ~_S_write_entered;
 
   public:
-shared_mutex() : _M_state(0) {}
+shared_timed_mutex() : _M_state(0) {}
 
-~shared_mutex()
+~shared_timed_mutex()
 {
   _GLIBCXX_DEBUG_ASSERT( _M_state == 0 );
 }
 
-shared_mutex(const shared_mutex) = delete;
-shared_mutex operator=(const shared_mutex) = delete;
+shared_timed_mutex(const shared_timed_mutex) = delete;
+shared_timed_mutex operator=(const shared_timed_mutex) = delete;
 
 // Exclusive ownership
 
Index: testsuite/30_threads/shared_lock/locking/2.cc
===
--- testsuite/30_threads/shared_lock/locking/2.cc   (revision 205961)
+++ testsuite/30_threads/shared_lock/locking/2.cc   (working copy)
@@ -30,7 +30,7 @@
 void test01()
 {
   bool test __attribute__((unused)) = true;
-  typedef std::shared_mutex mutex_type;
+  typedef std::shared_timed_mutex mutex_type;
   typedef std::shared_lockmutex_type lock_type;
 
   try
@@ -66,7 +66,7 @@
 void test02()
 {
   bool test __attribute__((unused)) = true;
-  typedef std::shared_mutex mutex_type;
+  typedef std::shared_timed_mutex mutex_type;
   typedef std::shared_lockmutex_type lock_type;
 
   try
Index: testsuite/30_threads/shared_lock/locking/4.cc
===
--- testsuite/30_threads/shared_lock/locking/4.cc   (revision 205961)
+++ testsuite/30_threads/shared_lock/locking/4.cc   (working copy)
@@ -31,7 +31,7 @@
 int main()
 {
   bool test __attribute__((unused)) = true;
-  typedef std::shared_mutex mutex_type;
+  typedef std::shared_timed_mutex mutex_type;
   typedef std::shared_lockmutex_type lock_type;
   typedef std::chrono::system_clock clock_type;
 
Index: testsuite/30_threads/shared_lock/locking/1.cc
===
--- testsuite/30_threads/shared_lock/locking/1.cc   (revision 205961)
+++ testsuite/30_threads/shared_lock/locking/1.cc   (working copy)
@@ -30,7 +30,7 @@
 int main()
 {
   bool test __attribute__((unused)) = true;
-  typedef std::shared_mutex mutex_type;
+  typedef std::shared_timed_mutex mutex_type;
   typedef std::shared_lockmutex_type lock_type;
 
   try
Index: testsuite/30_threads/shared_lock/locking/3.cc
===
--- testsuite/30_threads/shared_lock/locking/3.cc   (revision 205961)
+++ testsuite/30_threads/shared_lock/locking/3.cc   (working copy)
@@ -31,7 +31,7 @@
 int main()
 {
   bool test

PR libstdc++/59529, 59530,59531 Various string_view bugs.

2014-01-24 Thread Ed Smith-Rowland

As committed:

Same patch as discussed before all the holidays.

Built and tested x86_64-linux.

2014-01-24  Ed Smith-Rowland  3dw...@verizon.net
Peter A. Bigot p...@pabigot.com

PR libstdc++/59529
* include/experimental/string_view
(basic_string_view(const _CharT*, size_type)): Don't care if len == 0.
* testsuite/experimental/string_view/operations/substr/char/1.cc:
Comment out catch of out_of_range; No terminating null
in basic_string_view.  Check begin == end.
* testsuite/experimental/string_view/operations/substr/wchar_t/1.cc:
Ditto.

2014-01-24  Ed Smith-Rowland  3dw...@verizon.net
Peter A. Bigot p...@pabigot.com

PR libstdc++/59530
* include/experimental/string_view (operator[](size_type) const):
Fix one-off index error in debug check.
* testsuite/experimental/string_view/element_access/char/1.cc: Don't
test basic_string_view at size().
* testsuite/experimental/string_view/element_access/wchar_t/1.cc: Ditto.

2014-01-24  Ed Smith-Rowland  3dw...@verizon.net

PR libstdc++/59531
* testsuite/experimental/string_view/operations/copy/char/1.cc: New.
* testsuite/experimental/string_view/operations/copy/wchar_t/1.cc: New.


2014-01-24  Ed Smith-Rowland  3dw...@verizon.net
Peter A. Bigot p...@pabigot.com

PR libstdc++/59531
* include/experimental/string_view
(copy(_CharT*, size_type, size_type) const): Correct throw string.
Correct copy start location.

Index: include/experimental/string_view
===
--- include/experimental/string_view(revision 207027)
+++ include/experimental/string_view(working copy)
@@ -117,7 +117,7 @@
 
   constexpr basic_string_view(const _CharT* __str, size_type __len)
   : _M_len{__str == nullptr ? 0 :__len},
-_M_str{__str == nullptr || __len == 0 ? _S_empty_str : __str}
+_M_str{__str == nullptr ? _S_empty_str : __str}
   { }
 
   basic_string_view
@@ -277,11 +277,11 @@
   constexpr basic_string_view
   substr(size_type __pos, size_type __n=npos) const
   {
-   return __pos  this-_M_len
+   return __pos = this-_M_len
 ? basic_string_view{this-_M_str + __pos,
std::min(__n, size_type{this-_M_len  - __pos})}
-: (__throw_out_of_range_fmt(__N(basic_string_view::at: __pos 
-(which is %zu) = this-size() 
+: (__throw_out_of_range_fmt(__N(basic_string_view::substr: __pos 
+(which is %zu)  this-size() 
 (which is %zu)),
 __pos, this-size()), basic_string_view{});
   }
Index: testsuite/experimental/string_view/operations/substr/char/1.cc
===
--- testsuite/experimental/string_view/operations/substr/char/1.cc  
(revision 207027)
+++ testsuite/experimental/string_view/operations/substr/char/1.cc  
(working copy)
@@ -63,11 +63,9 @@
   {
 str02 = str01.substr(csz01);
 VERIFY( str02.size() == 0 );
+VERIFY( str02.begin() == str01.end() );
+VERIFY( true );
   }
-  catch(std::out_of_range fail)
-  {
-VERIFY( true ); // No terminating null in basic_string_view
-  }
   catch(...)
   {
 VERIFY( false );
Index: testsuite/experimental/string_view/operations/substr/wchar_t/1.cc
===
--- testsuite/experimental/string_view/operations/substr/wchar_t/1.cc   
(revision 207027)
+++ testsuite/experimental/string_view/operations/substr/wchar_t/1.cc   
(working copy)
@@ -63,11 +63,9 @@
   {
 str02 = str01.substr(csz01);
 VERIFY( str02.size() == 0 );
+VERIFY( str02.begin() == str01.end() );
+VERIFY( true );
   }
-  catch(std::out_of_range fail)
-  {
-VERIFY( true ); // No terminating null in basic_string_view
-  }
   catch(...)
   {
 VERIFY( false );
Index: include/experimental/string_view
===
--- include/experimental/string_view(revision 207027)
+++ include/experimental/string_view(working copy)
@@ -182,7 +182,7 @@
   operator[](size_type __pos) const
   {
// TODO: Assert to restore in a way compatible with the constexpr.
-   // _GLIBCXX_DEBUG_ASSERT(__pos = this-_M_len);
+   // _GLIBCXX_DEBUG_ASSERT(__pos  this-_M_len);
return *(this-_M_str + __pos);
   }
 
Index: testsuite/experimental/string_view/element_access/char/1.cc
===
--- testsuite/experimental/string_view/element_access/char/1.cc (revision 
207027)
+++ testsuite/experimental/string_view/element_access/char/1.cc (working copy)
@@ -41,8 +41,9 @@
   csz01

[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: [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.



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 jwakely@gmail.com 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 @@

ul
  lia 
href=http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2011;
-   Improved support for C++11/a, including support for lt;regexgt;.
+   Improved support for C++11/a, including support for
codelt;regexgt;/code.
  /li
+liExperimental support for most C++1y library features, including:
+  ul
+liUser-defined literals for strings, durations and complex
numbers./li
+liAdditional overloads for codestd::equal/code,
codestd::mismatch/code
+and codestd::is_permutation/code./li
+licodestd::make_unique/code/li
+licodestd::quoted/code/li
+licodestd::shared_lock/code/li
+licodestd::integer_sequence/code/li
+  /ul
+/li
+liAn implementation of codestd::experimental::optional/code./li
  liThe non-standard function codestd::copy_exception/code
has been deprecated
  and will be removed in a future version.
codestd::make_exception_ptr/code
  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
   tda href=http://isocpp.org/files/papers/n3760.htm;N3760/a/td
   td class=unsupported align=centerNo/td
---
   tda 
 href=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html;N3760/a/td
   td class=supported align=center
 a href=../gcc-4.9/changes.html#cxx4.9/a (N3797)/td
118,119c119,121
   tda href=http://isocpp.org/files/papers/N3781.pdf;N3781/a/td
   td class=unsupported align=centerNo/td
---
   tda 
 href=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf;N3781/a/td
   td class=supported align=center
 a href=../gcc-4.9/changes.html#cxx4.9/a (N3797)/td
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
   li
 G++ supports the a href=../projects/cxx1y.htmlC++1y/a [[deprecated]]
 attribute modulo bugs in the underying [[gnu::deprecated]] attribute.  
 Classes
 and functions can be marked deprecated and 
 blockquotepre
 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
 /pre/blockquote
   /li
   li
 G++ supports a href=../projects/cxx1y.htmlC++1y/a digit separators.
 Long numeric literals can be subdivided with a single quote ' to enhance 
 readability:
 blockquotepre
   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;
 /pre/blockquote
   /li
157c190
Improved support for C++11/a, including support for lt;regexgt;.
---
Improved support for C++11/a, including support for 
 codelt;regexgt;/code.
158a192,217
 lia 
 href=http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014;
Improved experimental support for the upcoming ISO C++ standard, 
 C++14/a,
including:
   ul
 li fixing codeconstexpr/code member functions without 
 codeconst/code; /li
 li implementation of the codestd::exchange()/code utility 
 function; /li
 li addressing tuples by type; /li
 li implemention of codestd::make_unique/code; /li
 li implemention of codestd::shared_lock/code; /li
 li making codestd::result_of/code SFINAE-friendly; /li
 li adding codeoperator()/code to 
 

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
   tda href=http://isocpp.org/files/papers/n3760.htm;N3760/a/td
   td class=unsupported align=centerNo/td
---
   tda 
 href=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html;N3760/a/td
   td class=supported align=center
 a href=../gcc-4.9/changes.html#cxx4.9/a (N3797)/td
118,119c119,121
   tda href=http://isocpp.org/files/papers/N3781.pdf;N3781/a/td
   td class=unsupported align=centerNo/td
---
   tda 
 href=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf;N3781/a/td
   td class=supported align=center
 a href=../gcc-4.9/changes.html#cxx4.9/a (N3797)/td


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
   tda href=http://isocpp.org/files/papers/n3760.htm;N3760/a/td
   td class=unsupported align=centerNo/td
---
   tda 
 href=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html;N3760/a/td
   td class=supported align=center
 a href=../gcc-4.9/changes.html#cxx4.9/a (N3797)/td
118,119c119,121
   tda href=http://isocpp.org/files/papers/N3781.pdf;N3781/a/td
   td class=unsupported align=centerNo/td
---
   tda 
 href=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf;N3781/a/td
   td class=supported align=center
 a href=../gcc-4.9/changes.html#cxx4.9/a (N3797)/td
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 a href=../projects/cxx1y.htmlC++1y/a [[deprecated]]
 attribute modulo bugs in the underying [[gnu::deprecated]] attribute.  
 Classes
 and functions can be marked deprecated and 
 blockquotepre
 /pre/blockquote
   li
 class A {};
 #if __cplusplus  201103:
 class A [[deprecated(A is deprecated in C++14; Use B instead)]];
 class B {};
 #endif
   /li
   li
 blockquotepre
   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;
 /pre/blockquote
   /li
158a183,205
 lia 
 href=http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014;
Improved experimental support for the upcoming ISO C++ standard, 
 C++14/a,
including:
   ul
 li fixing codeconstexpr/code member functions without 
 codeconst/code; /li
 li implementation of the codeexchange()/code utility function; 
 /li
 li addressing tuples by type; /li
 li implemention of codemake_unique/code; /li
 li making codestd::result_of/code SFINAE-friendly; /li
 li adding codeoperator()/code to 
 codeintegral_constant/code; /li
 li adding user-defined literals for standard library types
  /codestring/code, /codechrono/code, and 
 /codecomplex/code; /li
 li adding two range overloads to non-modifying sequence oprations; 
 /li
 li adding IO manipulators for quoted strings; /li
 li adding codeconstexpr/code members to utilities, 
 codecomplex/code,
  codechrono/code, and some containers; /li
 li adding compile-time codeinteger_sequence/codes; /li
 li adding cleaner transformation traits; /li
 li adding a class for codeoptional/code types; /li
 li making codefunctional/codes operator functors easier to use 
 and
  more generic; /li
   /ul
 /li


[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
   tda href=http://isocpp.org/files/papers/n3760.htm;N3760/a/td
   td class=unsupported align=centerNo/td
---
   tda 
 href=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html;N3760/a/td
   td class=supported align=center
 a href=../gcc-4.9/changes.html#cxx4.9/a (N3797)/td
118,119c119,121
   tda href=http://isocpp.org/files/papers/N3781.pdf;N3781/a/td
   td class=unsupported align=centerNo/td
---
   tda 
 href=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf;N3781/a/td
   td class=supported align=center
 a href=../gcc-4.9/changes.html#cxx4.9/a (N3797)/td
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 a href=../projects/cxx1y.htmlC++1y/a [[deprecated]]
 attribute modulo bugs in the underying [[gnu::deprecated]] attribute.  
 Classes
 and functions can be marked deprecated and 
 blockquotepre
 /pre/blockquote
   li
 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
   /li
   li
 G++ supports a href=../projects/cxx1y.htmlC++1y/a digit separators.
 Long numeric literals can be subdivided with a single quote ' to enhance 
 readability:
 blockquotepre
   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;
 /pre/blockquote
   /li
158a191,213
 lia 
 href=http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014;
Improved experimental support for the upcoming ISO C++ standard, 
 C++14/a,
including:
   ul
 li fixing codeconstexpr/code member functions without 
 codeconst/code; /li
 li implementation of the codeexchange()/code utility function; 
 /li
 li addressing tuples by type; /li
 li implemention of codemake_unique/code; /li
 li making codestd::result_of/code SFINAE-friendly; /li
 li adding codeoperator()/code to 
 codeintegral_constant/code; /li
 li adding user-defined literals for standard library types
  /codestring/code, /codechrono/code, and 
 /codecomplex/code; /li
 li adding two range overloads to non-modifying sequence oprations; 
 /li
 li adding IO manipulators for quoted strings; /li
 li adding codeconstexpr/code members to utilities, 
 codecomplex/code,
  codechrono/code, and some containers; /li
 li adding compile-time codeinteger_sequence/codes; /li
 li adding cleaner transformation traits; /li
 li adding a class for codeoptional/code types; /li
 li making codefunctional/codes operator functors easier to use 
 and
  more generic; /li
   /ul
 /li


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 }
+
+templatetypename _Tp, _Tp __v
+  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; }
+  };
+
+templatetypename _Tp, _Tp __v
+  constexpr _Tp integral_constant_Tp, __v::value;
+
+typedef integral_constantbool, true true_type;
+
+typedef integral_constantbool, falsefalse_type;
+
+templatetypename, typename
+  struct is_same
+  : public false_type { };
+
+templatetypename _Tp
+  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_sameT, T {
   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 }
+
+templatetypename, typename
+  struct is_same
+  {
+static constexpr bool value = false;
+  };
+
+templatetypename _Tp
+  struct is_same_Tp, _Tp
+  {
+static constexpr bool value = true;
+  };
+
+templatetypename CharT, CharT... Str
+  struct Foo
+  {
+using char_type = CharT;
+char_type chars[sizeof...(Str)]{Str...};
+  };
+
+templatetypename CharT, CharT... Str
+  FooCharT, Str...
+  operator_foo()
+  {
+return FooCharT, Str...();
+  }
+
+int
+main()
+{
+  auto fooU = U\x1\x10001\x10002_foo;
+  if (is_samedecltype(fooU)::char_type, char32_t::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

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_digit_sep  float_flag != AFTER_EXPON)
+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,16 +551,28 @@
 
  /* Exponent is decimal, even if string is a hex float.  */
  if (!ISDIGIT (*str

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_ERROR_AT (virtual_location,
  

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 array
+#include vector
+#include type_traits
+#include testsuite_hooks.h
are you sure you want these includes in a C++ front-end testcase? Even 
testsuite_hooks.h instead of cassert? What about something more 
minimal, not including large headers like vector, 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 type_traits
+
+struct Foo
+{
+  bool type[4];
+  bool const_type[4];
+  int chars[10];
+};
+
+templatetypename CharT, CharT... str
+Foo
+operator_foo()
+{
+  CharT arr[]{str...};
+
+  Foo foo;
+
+  foo.type[0] = std::is_sameCharT, char::value;
+  foo.type[1] = std::is_sameCharT, wchar_t::value;
+  foo.type[2] = std::is_sameCharT, char16_t::value;
+  foo.type[3] = std::is_sameCharT, char32_t::value;
+  foo.const_type[0] = std::is_sameCharT, const char::value;
+  foo.const_type[1] = std::is_sameCharT, const wchar_t::value;
+  foo.const_type[2] = std::is_sameCharT, const char16_t::value;
+  foo.const_type[3] = std::is_sameCharT, const char32_t::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

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 type_traits 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 }
+
+templatetypename _Tp, _Tp __v
+  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; }
+  };
+
+templatetypename _Tp, _Tp __v
+  constexpr _Tp integral_constant_Tp, __v::value;
+
+typedef integral_constantbool, true true_type;
+
+typedef integral_constantbool, falsefalse_type;
+
+templatetypename, typename
+  struct is_same
+  : public false_type { };
+
+templatetypename _Tp
+  struct is_same_Tp, _Tp
+  : public true_type { };
+
+struct Foo
+{
+  bool type[4];
+  bool const_type[4];
+  int chars[10];
+};
+
+templatetypename CharT, CharT... str
+Foo
+operator_foo()
+{
+  CharT arr[]{str...};
+
+  Foo foo;
+
+  foo.type[0] = is_sameCharT, char::value;
+  foo.type[1] = is_sameCharT, wchar_t::value;
+  foo.type[2] = is_sameCharT, char16_t::value;
+  foo.type[3] = is_sameCharT, char32_t::value;
+  foo.const_type[0] = is_sameCharT, const char::value;
+  foo.const_type[1] = is_sameCharT, const wchar_t::value;
+  foo.const_type[2] = is_sameCharT, const char16_t::value;
+  foo.const_type[3] = is_sameCharT, const char32_t::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

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 type_traits 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



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



[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: 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_castblock_type(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().


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_limitsblock_type::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.
-  templatetypename _WordT, typename _Alloc
-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));
-   }
-}
-
-  templatetypename _WordT, typename _Alloc
-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));
-   }
-}
-
-  templatetypename _WordT, typename _Alloc
-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 

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 array
+#include vector
+#include type_traits
+#include testsuite_hooks.h
+
+struct Foo
+{
+  std::arraybool, 4 type;
+  std::arraybool, 4 const_type;
+  std::vectorint chars;
+};
+
+templatetypename CharT, CharT... str
+Foo
+operator_foo()
+{
+  CharT arr[]{str...};
+
+  Foo foo;
+
+  foo.type[0] = std::is_sameCharT, char::value;
+  foo.type[1] = std::is_sameCharT, wchar_t::value;
+  foo.type[2] = std::is_sameCharT, char16_t::value;
+  foo.type[3] = std::is_sameCharT, char32_t::value;
+  foo.const_type[0] = std::is_sameCharT, const char::value;
+  foo.const_type[1] = std::is_sameCharT, const wchar_t::value;
+  foo.const_type[2] = std::is_sameCharT, const char16_t::value;
+  foo.const_type[3] = std::is_sameCharT, const char32_t::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);
+}


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
  operatorabc(...)
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::complexfloat
+  operatorif(long double __num)
+  { return std::complexfloat{0.0F, static_castfloat(__num)}; }
+
+  inline constexpr std::complexfloat
+  operatorif(unsigned long long __num)
+  { return std::complexfloat{0.0F, static_castfloat(__num)}; }
+
+  inline constexpr std::complexdouble
+  operatori(long double __num)
+  { return std::complexdouble{0.0, static_castdouble(__num)}; }
+
+  inline constexpr std::complexdouble
+  operatori(unsigned long long __num)
+  { return std::complexdouble{0.0, static_castdouble(__num)}; }
+
+  inline constexpr std::complexlong double
+  operatoril(long double __num)
+  { return std::complexlong double{0.0L, __num}; }
+
+  inline constexpr std::complexlong double
+  operatoril(unsigned long long __num)
+  { return std::complexlong double{0.0L, static_castlong double(__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 complex
+#include type_traits
+
+void
+test02()
+{
+  using namespace std::literals::complex_literals;
+
+  static_assert(std::is_samedecltype(1.0if), std::complexfloat::value,
+   1.0if is std::complexfloat);
+
+  static_assert(std::is_samedecltype(1if), std::complexfloat::value,
+   1if is std::complexfloat);
+
+  static_assert(std::is_samedecltype(1.0i), std::complexdouble::value,
+   1.0i is std::complexdouble);
+
+  static_assert(std::is_samedecltype(1i), std::complexdouble::value,
+   1i is std::complexdouble);
+
+  static_assert(std::is_samedecltype(1.0il), std::complexlong 
double::value,
+   1.0il is std::complexlong double);
+
+  static_assert(std::is_samedecltype(1il), std::complexlong double::value,
+   1il is std::complexlong double);
+}
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

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 paolo.carl...@oracle.com 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*!

regex 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



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_traitschar 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 regex
 #include testsuite_hooks.h
 
-// Tests the value() function of the regex_traitschar class.
+// Tests the value() function of the regex_traitswchar_t class.
 void test01()
 {
   bool test __attribute__((unused)) = true;
-  std::regex_traitschar 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_traitswchar_t 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'.


[PR c++/58072][C++11]

2013-08-04 Thread Ed Smith-Rowland
This was a bug concerning reporting of compiler errors involving 
user-defined literals.

The error messages would appear with token names 'CPP_STRING_USERDEF', etc.
This is very cryptic for the user.

This patch just catches user-defined literal tokens in 
c-family/c-common.c/c_parse_error() and inserts useful phrases in the 
error messages.


Built and tested on x86-64-linux.

OK?

Ed


gcc/c-family:

2013-08-04  Ed Smith-Rowland  3dw...@verizon.net

PR c++/58072
* c-common.c (c_parse_error): Catch user-defined literal tokens and
provide useful error strings.


gcc/testsuite:

PR c++/58072
* g++.dg/cpp0x/pr58072.C: New.
Index: c-family/c-common.c
===
--- c-family/c-common.c (revision 201466)
+++ c-family/c-common.c (working copy)
@@ -9352,6 +9352,18 @@
   free (message);
   message = NULL;
 }
+  else if (token_type == CPP_CHAR_USERDEF
+  || token_type == CPP_WCHAR_USERDEF
+  || token_type == CPP_CHAR16_USERDEF
+  || token_type == CPP_CHAR32_USERDEF)
+message = catenate_messages (gmsgid,
+ before user-defined character literal);
+  else if (token_type == CPP_STRING_USERDEF
+  || token_type == CPP_WSTRING_USERDEF
+  || token_type == CPP_STRING16_USERDEF
+  || token_type == CPP_STRING32_USERDEF
+  || token_type == CPP_UTF8STRING_USERDEF)
+message = catenate_messages (gmsgid,  before user-defined string 
literal);
   else if (token_type == CPP_STRING
   || token_type == CPP_WSTRING
   || token_type == CPP_STRING16
Index: testsuite/g++.dg/cpp0x/pr58072.C
===
--- testsuite/g++.dg/cpp0x/pr58072.C(revision 0)
+++ testsuite/g++.dg/cpp0x/pr58072.C(working copy)
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-options -std=c++11 }
+
+// PR c++/58072
+
+extern 'c'void*blah(void*); // { dg-error expected unqualified-id before 
user-defined character literal }
+extern L'c'void*Lblah(void*); // { dg-error expected unqualified-id before 
user-defined character literal }
+extern u'c'void*ublah(void*); // { dg-error expected unqualified-id before 
user-defined character literal }
+extern U'c'void*Ublah(void*); // { dg-error expected unqualified-id before 
user-defined character literal }
+
+extern cvoid*strblah(void*); // { dg-error expected unqualified-id before 
user-defined string literal }
+extern Lcvoid*Lstrblah(void*); // { dg-error expected unqualified-id before 
user-defined string literal }
+extern ucvoid*ustrblah(void*); // { dg-error expected unqualified-id before 
user-defined string literal }
+extern Ucvoid*Ustrblah(void*); // { dg-error expected unqualified-id before 
user-defined string literal }
+extern u8cvoid*u8strblah(void*); // { dg-error expected unqualified-id 
before user-defined string literal }
+
+extern 123void*ULLblah(void*); // { dg-error expected unqualified-id before 
numeric constant }
+extern 123.456void*Ldblblah(void*); // { dg-error expected unqualified-id 
before numeric constant }


Re: [patch] regex_traits implementation

2013-07-09 Thread Ed Smith-Rowland

On 07/09/2013 06:17 AM, Jonathan Wakely wrote:

On 9 July 2013 11:13, Tim Shen wrote:

On Tue, Jul 9, 2013 at 4:35 PM, Jonathan Wakely jwakely@gmail.com wrote:

Sorry for the delay, I missed this latest version - it looks excellent
and is fine to commit. Do you have svn write access or do you need
someone to commit it for you?

I don't have svn write access. Should I make a request of it, or ask
someone(say Stephen, my GSoC mentor) to commit for me?

It probably makes sense to get access but for now I can commit your
most recent patch this evening, UK time (unless someone beats me to
it.)


Applied (with two small trailing whitespace corrections) ;-)

And a hearty *Thank You* to Tim Shen for picking this up!

Ed



[PING] Re: C++ 2014 status page for libstdc++

2013-07-03 Thread Ed Smith-Rowland

On 06/27/2013 11:24 PM, Ed Smith-Rowland wrote:

On 06/27/2013 07:01 AM, Jonathan Wakely wrote:

On 26 June 2013 02:28, Ed Smith-Rowland wrote:

On 06/25/2013 11:59 AM, Jonathan Wakely wrote:

On 25 June 2013 16:45, 3dw...@verizon.net wrote:

Here is a C++2014 status page for fun and profit.

Excellent, thanks!


Tested with xmllint.  Are there any other tests I should do?

The makefile target to check the docbook manual is:
make doc-xml-validate-docbook

Checked clean.


It should also be linked from doc/xml/manual/intro.xml so it appears
as part of the manual.

Done.


The first paragraph says the table is based on the table of contents
of the CD, but it isn't.  I agree with only showing the C++14 changes,
but the first paragraph should be changed (or removed.)


Just removed this paragraph.

Applied.
That patch is definitely OK, but please wait for approval before 
applying!

Will do.  Sorry.


Thanks again for doing this - I'll try to find time to finish the WIP
stuff I'm W'ing on :)


Cool!

I should have waited because I thought it would be better to have 
links for the papers.


Also, how does one regenerate html?  Do you do that?

Finally, should we put a line for thins in the 4.9 changes page?



PING!  Is adding links to the C++2014 library page OK?



Re: [C++] DR1473 - let literal operators be defined with empty user-defined string literal

2013-06-29 Thread Ed Smith-Rowland

On 06/26/2013 05:01 PM, Jason Merrill wrote:

On 06/26/2013 09:43 AM, Ed Smith-Rowland wrote:

+  if (bad_encoding_prefix)
+error (invalid encoding prefix in literal operator);
+  {
+tree string_tree = USERDEF_LITERAL_VALUE (token-u.value);


No need to open a nested block for a declaration now that we're 
compiling as C++.


Otherwise, OK.

Jason


Here is the applied patch.  I was unable to remove the code braces 
because the jump to default crosses the initialization.


Also, this has a much better detection of macros for Wstring-literal 
(which test broke with my previous patch).



Index: gcc/cp/cp-tree.h
===
--- gcc/cp/cp-tree.h(revision 200562)
+++ gcc/cp/cp-tree.h(working copy)
@@ -4404,7 +4404,7 @@
 #define LAMBDANAME_PREFIX __lambda
 #define LAMBDANAME_FORMAT LAMBDANAME_PREFIX %d
 
-#define UDLIT_OP_ANSI_PREFIX operator\\ 
+#define UDLIT_OP_ANSI_PREFIX operator\\
 #define UDLIT_OP_ANSI_FORMAT UDLIT_OP_ANSI_PREFIX %s
 #define UDLIT_OP_MANGLED_PREFIX li
 #define UDLIT_OP_MANGLED_FORMAT UDLIT_OP_MANGLED_PREFIX %s
Index: libcpp/lex.c
===
--- libcpp/lex.c(revision 200562)
+++ libcpp/lex.c(working copy)
@@ -1334,6 +1334,33 @@
   *last_buff_p = last_buff;
 }
 
+
+/* Returns true if a macro has been defined.
+   This might not work if compile with -save-temps,
+   or preprocess separately from compilation.  */
+
+static bool
+is_macro(cpp_reader *pfile, const uchar *base)
+{
+  const uchar *cur = base;
+  if (! ISIDST (*cur))
+return false;
+  unsigned int hash = HT_HASHSTEP (0, *cur);
+  ++cur;
+  while (ISIDNUM (*cur))
+{
+  hash = HT_HASHSTEP (hash, *cur);
+  ++cur;
+}
+  hash = HT_HASHFINISH (hash, cur - base);
+
+  cpp_hashnode *result = CPP_HASHNODE (ht_lookup_with_hash (pfile-hash_table,
+   base, cur - base, hash, HT_NO_INSERT));
+
+  return !result ? false : (result-type == NT_MACRO);
+}
+
+
 /* Lexes a raw string.  The stored string contains the spelling, including
double quotes, delimiter string, '(' and ')', any leading
'L', 'u', 'U' or 'u8' and 'R' modifier.  It returns the type of the
@@ -1556,22 +1583,18 @@
 
   if (CPP_OPTION (pfile, user_literals))
 {
-  /* According to C++11 [lex.ext]p10, a ud-suffix not starting with an
-underscore is ill-formed.  Since this breaks programs using macros
-from inttypes.h, we generate a warning and treat the ud-suffix as a
-separate preprocessing token.  This approach is under discussion by
-the standards committee, and has been adopted as a conforming
-extension by other front ends such as clang.
- A special exception is made for the suffix 's' which will be
-standardized as a user-defined literal suffix for strings.  */
-  if (ISALPHA (*cur)  *cur != 's')
+  /* If a string format macro, say from inttypes.h, is placed touching
+a string literal it could be parsed as a C++11 user-defined string
+literal thus breaking the program.
+Try to identify macros with is_macro. A warning is issued. */
+  if (is_macro (pfile, cur))
{
  /* Raise a warning, but do not consume subsequent tokens.  */
  if (CPP_OPTION (pfile, warn_literal_suffix))
cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX,
   token-src_loc, 0,
   invalid suffix on literal; C++11 requires 
-  a space between literal and identifier);
+  a space between literal and string macro);
}
   /* Grab user defined literal suffix.  */
   else if (ISIDST (*cur))
@@ -1689,22 +1712,18 @@
 
   if (CPP_OPTION (pfile, user_literals))
 {
-  /* According to C++11 [lex.ext]p10, a ud-suffix not starting with an
-underscore is ill-formed.  Since this breaks programs using macros
-from inttypes.h, we generate a warning and treat the ud-suffix as a
-separate preprocessing token.  This approach is under discussion by
-the standards committee, and has been adopted as a conforming
-extension by other front ends such as clang.
- A special exception is made for the suffix 's' which will be
-standardized as a user-defined literal suffix for strings.  */
-  if (ISALPHA (*cur)  *cur != 's')
+  /* If a string format macro, say from inttypes.h, is placed touching
+a string literal it could be parsed as a C++11 user-defined string
+literal thus breaking the program.
+Try to identify macros with is_macro. A warning is issued. */
+  if (is_macro (pfile, cur))
{
  /* Raise a warning, but do not consume subsequent tokens.  */
  if (CPP_OPTION (pfile, warn_literal_suffix))
cpp_warning_with_line

Re: C++ 2014 status page for libstdc++

2013-06-27 Thread Ed Smith-Rowland

On 06/27/2013 07:01 AM, Jonathan Wakely wrote:

On 26 June 2013 02:28, Ed Smith-Rowland wrote:

On 06/25/2013 11:59 AM, Jonathan Wakely wrote:

On 25 June 2013 16:45,  3dw...@verizon.net wrote:

Here is a C++2014 status page for fun and profit.

Excellent, thanks!


Tested with xmllint.  Are there any other tests I should do?

The makefile target to check the docbook manual is:
make doc-xml-validate-docbook

Checked clean.


It should also be linked from doc/xml/manual/intro.xml so it appears
as part of the manual.

Done.


The first paragraph says the table is based on the table of contents
of the CD, but it isn't.  I agree with only showing the C++14 changes,
but the first paragraph should be changed (or removed.)


Just removed this paragraph.

Applied.

That patch is definitely OK, but please wait for approval before applying!

Will do.  Sorry.


Thanks again for doing this - I'll try to find time to finish the WIP
stuff I'm W'ing on :)


Cool!

I should have waited because I thought it would be better to have links 
for the papers.


Also, how does one regenerate html?  Do you do that?

Finally, should we put a line for thins in the 4.9 changes page?


Index: doc/xml/manual/status_cxx2014.xml
===
--- doc/xml/manual/status_cxx2014.xml   (revision 200429)
+++ doc/xml/manual/status_cxx2014.xml   (working copy)
@@ -44,63 +44,99 @@
   tbody
 
 row
-  entryN3669/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3669.pdf;
+ N3669
+   /link
+  /entry
   entryFixing constexpr member functions without const/entry
   entryY/entry
   entry/
 /row
 
 row
-  entryN3668/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3668.html;
+ N3668
+   /link
+  /entry
   entrycodeexchange()/code utility function/entry
   entryY/entry
   entry/
 /row
 
 row
-  entryN3670/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3670.html;
+ N3670
+   /link
+  /entry
   entryWording for Addressing Tuples by Type/entry
   entryY/entry
   entry/
 /row
 
 row
-  entryN3656/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3656.htm;
+ N3656
+   /link
+  /entry
   entrycodemake_unique/code/entry
   entryY/entry
   entry/
 /row
 
 row
-  entryN3462/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2012/n3462.html;
+ N3462
+   /link
+  /entry
   entrycodestd::result_of/code and SFINAE/entry
   entryY/entry
   entry/
 /row
 
 row
-  entryN3545/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3545.pdf;
+ N3545
+   /link
+  /entry
   entryAn Incremental Improvement to 
codeintegral_constant/code/entry
   entryY/entry
   entry/
 /row
 
 row
-  entryN3642/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3642.pdf;
+ N3642
+   /link
+  /entry
   entryUser-defined Literals for Standard Library Types/entry
   entryY/entry
   entry/
 /row
 
 row
-  entryN3671/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3671.html;
+ N3671
+   /link
+  /entry
   entryMaking non-modifying sequence operations more robust/entry
   entryY/entry
   entry/
 /row
 
 row
-  entryN3654/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3654.html;
+ N3654
+   /link
+  /entry
   entryQuoted Strings Library Proposal/entry
   entryY/entry
   entry/
@@ -108,21 +144,33 @@
 
 
 row
-  entryN3469/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2012/n3469.html;
+ N3469
+   /link
+  /entry
   entryConstexpr Library Additions: chrono/entry
   entryY/entry
   entry/
 /row
 
 row
-  entryN3470/entry
+  entry
+   link xmlns:xlink=http://www.w3.org/1999/xlink; 
xlink:href=http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2012/n3470.html;
+ N3470
+   /link
+  /entry
   entryConstexpr Library

Re: [C++] DR1473 - let literal operators be defined with empty user-defined string literal

2013-06-26 Thread Ed Smith-Rowland

On 06/25/2013 08:50 AM, Jason Merrill wrote:

I had missed a few files in my patch anyway (I was doing too much at once).


On 06/25/2013 08:27 AM, Ed Smith-Rowland wrote:

+  else if (token-type == CPP_KEYWORD)
+{
+  error (unexpected keyword;
+  Remove space between quotes and suffix identifier);
+  return error_mark_node;
+}


Lower-case 'r' after a semicolon.

Done.


After giving the error, let's try to handle it properly anyway to 
avoid cascading errors.



+if (TREE_STRING_LENGTH (string_tree)  2)


Why 2?  I would expect TREE_STRING_LENGTH for  to be 1 (the NUL).

The string length is the two quotes (and, as you'll see, the encoding 
prefix length).

+error (expected empty string after %operator% keyword);
+return error_mark_node;


And let's continue after the error here, too.


+  error (invalid encoding prefix in literal operator);
   return error_mark_node;


And here.
I the patch I am sending you now, I don't return error mark node very 
often.  I go on, nonempty strings and bad encoding notwithstanding, and 
produce the correct operator ID which gets returned.  Correct?


Jason


I'm still testing and I might have to tweak the error lines and such.

OK in principal though?

Ed

libcpp:

2013-06-25  Ed Smith-Rowland  3dw...@verizon.net

* lex.c: Constrain suffixes treated as concatenated literal and macro
to just the patterns found in inttypes.h.


gcc/cp:

2013-06-25  Ed Smith-Rowland  3dw...@verizon.net

* cp-tree.h (UDLIT_OP_ANSI_PREFIX): Remove space.
* parser.c (cp_parser_operator()): Parse user-defined string
literal as literal operator.


gcc/testsuite:

2013-06-25  Ed Smith-Rowland  3dw...@verizon.net

* g++.dg/cpp0x/udlit-nospace-neg.C: Adjust.
* g++.dg/cpp1y/udlit-enc-prefix-neg.C: New.
* g++.dg/cpp1y/udlit-userdef-string.C: New.
* g++.dg/cpp1y/complex_literals.h: New.
Index: gcc/cp/cp-tree.h
===
--- gcc/cp/cp-tree.h(revision 200414)
+++ gcc/cp/cp-tree.h(working copy)
@@ -4404,7 +4404,7 @@
 #define LAMBDANAME_PREFIX __lambda
 #define LAMBDANAME_FORMAT LAMBDANAME_PREFIX %d
 
-#define UDLIT_OP_ANSI_PREFIX operator\\ 
+#define UDLIT_OP_ANSI_PREFIX operator\\
 #define UDLIT_OP_ANSI_FORMAT UDLIT_OP_ANSI_PREFIX %s
 #define UDLIT_OP_MANGLED_PREFIX li
 #define UDLIT_OP_MANGLED_FORMAT UDLIT_OP_MANGLED_PREFIX %s
Index: libcpp/lex.c
===
--- libcpp/lex.c(revision 200414)
+++ libcpp/lex.c(working copy)
@@ -1556,22 +1556,21 @@
 
   if (CPP_OPTION (pfile, user_literals))
 {
-  /* According to C++11 [lex.ext]p10, a ud-suffix not starting with an
-underscore is ill-formed.  Since this breaks programs using macros
-from inttypes.h, we generate a warning and treat the ud-suffix as a
-separate preprocessing token.  This approach is under discussion by
-the standards committee, and has been adopted as a conforming
-extension by other front ends such as clang.
- A special exception is made for the suffix 's' which will be
-standardized as a user-defined literal suffix for strings.  */
-  if (ISALPHA (*cur)  *cur != 's')
+  /* If a string format macro, say from inttypes.h, is placed touching
+a string literal it could be parsed as a C++11 user-defined string
+literal thus breaking the program.
+Since all format macros in inttypes.h start with PRI or SCN
+suffixes beginning with these will be interpreted as macros and the
+string and the macro parsed as separate tokens. A warning is issued. */
+  if (ustrcmp (cur, (const unsigned char *) PRI) == 0
+   || ustrcmp (cur, (const unsigned char *) SCN) == 0)
{
  /* Raise a warning, but do not consume subsequent tokens.  */
  if (CPP_OPTION (pfile, warn_literal_suffix))
cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX,
   token-src_loc, 0,
   invalid suffix on literal; C++11 requires 
-  a space between literal and identifier);
+  a space between literal and string macro);
}
   /* Grab user defined literal suffix.  */
   else if (ISIDST (*cur))
@@ -1689,22 +1688,21 @@
 
   if (CPP_OPTION (pfile, user_literals))
 {
-  /* According to C++11 [lex.ext]p10, a ud-suffix not starting with an
-underscore is ill-formed.  Since this breaks programs using macros
-from inttypes.h, we generate a warning and treat the ud-suffix as a
-separate preprocessing token.  This approach is under discussion by
-the standards committee, and has been adopted as a conforming
-extension by other front ends such as clang.
- A special exception is made

[C++ PR57640] Explicit call of system literal operator complains about leading underscore

2013-06-25 Thread Ed Smith-Rowland
This little nit was certainly latent all along but was only exposed once 
we got literal ops into the std library.
A user who calls a operator explicitly get yelled at for not having 
anunderscore.


OK after testing completes on x86_64-linux?

Ed

gcc/cp:

2013-06-25  Ed Smith-Rowland  3dw...@verizon.net

PR c++/57640
* parser.c (cp_parser_unqualified_id): Add declarator_p to checks
to trigger warning, (cp_literal_operator_id): Remove bogus TODO comment.


gcc/testsuite:

2013-06-25  Ed Smith-Rowland  3dw...@verizon.net

PR c++/57640
* g++.dg/cpp1y/pr57640.C: New.
Index: gcc/cp/parser.c
===
--- gcc/cp/parser.c (revision 200342)
+++ gcc/cp/parser.c (working copy)
@@ -5000,7 +4999,7 @@
{
  /* 17.6.3.3.5  */
  const char *name = UDLIT_OP_SUFFIX (id);
- if (name[0] != '_'  !in_system_header)
+ if (name[0] != '_'  !in_system_header  declarator_p)
warning (0, literal operator suffixes not preceded by %_%
 are reserved for future standardization);
}
@@ -12346,7 +12345,6 @@
  + strlen (name) + 10);
   sprintf (buffer, UDLIT_OP_ANSI_FORMAT, name);
   identifier = get_identifier (buffer);
-  /*IDENTIFIER_UDLIT_OPNAME_P (identifier) = 1; If we get a flag someday. */
 
   return identifier;
 }
Index: gcc/testsuite/g++.dg/cpp1y/pr57640.C
===
--- gcc/testsuite/g++.dg/cpp1y/pr57640.C(revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/pr57640.C(working copy)
@@ -0,0 +1,8 @@
+// { dg-options -std=c++1y }
+// { dg-do compile }
+
+#include chrono
+
+using namespace std::literals::chrono_literals;
+
+auto blooper = operator min(45.0L);


[C++] DR1473 - let literal operators be defined with empty user-defined string literal

2013-06-25 Thread Ed Smith-Rowland

This will allow such things as
  constexpr std::complexfloat
  operatorif(long double imag);

OK after testing completes on x86_64-linux.

Ed

gcc/cp:

2013-06-25  Ed Smith-Rowland  3dw...@verizon.net

* gcc/cp/parser.c (cp_parser_operator()): Parse user-defined string
literal as literal operator.


gcc/testsuite:

2013-06-25  Ed Smith-Rowland  3dw...@verizon.net

* gcc/testsuite/g++.dg/cpp0x/udlit-nospace-neg.C: Adjust.
* gcc/testsuite/g++.dg/cpp1y/udlit-enc-prefix-neg.C: New.
* gcc/testsuite/g++.dg/cpp1y/udlit-userdef-string.C: New.
Index: gcc/cp/parser.c
===
--- gcc/cp/parser.c (revision 200342)
+++ gcc/cp/parser.c (working copy)
@@ -12591,6 +12589,12 @@
  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);
@@ -12598,7 +12602,32 @@
}
 
 case CPP_STRING_USERDEF:
-  error (missing space between %\\% and suffix identifier);
+  if (cxx_dialect == cxx98)
+   maybe_warn_cpp0x (CPP0X_USER_DEFINED_LITERALS);
+  {
+   tree string_tree = USERDEF_LITERAL_VALUE (token-u.value);
+   if (TREE_STRING_LENGTH (string_tree)  2)
+ {
+   error (expected empty string after %operator% keyword);
+   return error_mark_node;
+ }
+   id = USERDEF_LITERAL_SUFFIX_ID (token-u.value);
+   /* Consume the user-defined string literal.  */
+   cp_lexer_consume_token (parser-lexer);
+   if (id != error_mark_node)
+ {
+   const char *name = IDENTIFIER_POINTER (id);
+   return cp_literal_operator_id (name);
+ }
+   else
+ return error_mark_node;
+  }
+
+case CPP_WSTRING_USERDEF:
+case CPP_STRING16_USERDEF:
+case CPP_STRING32_USERDEF:
+case CPP_UTF8STRING_USERDEF:
+  error (invalid encoding prefix in literal operator);
   return error_mark_node;
 
 default:
Index: gcc/testsuite/g++.dg/cpp0x/udlit-nospace-neg.C
===
--- gcc/testsuite/g++.dg/cpp0x/udlit-nospace-neg.C  (revision 200342)
+++ gcc/testsuite/g++.dg/cpp0x/udlit-nospace-neg.C  (working copy)
@@ -1,3 +1,5 @@
 // { dg-options -std=c++0x }
 
-float operator _abc(const char*); // { dg-error missing space between|and 
suffix identifier }
+float operator _abc(const char*);
+
+int operator_def(long double);
Index: gcc/testsuite/g++.dg/cpp1y/udlit-enc-prefix-neg.C
===
--- gcc/testsuite/g++.dg/cpp1y/udlit-enc-prefix-neg.C   (revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/udlit-enc-prefix-neg.C   (working copy)
@@ -0,0 +1,17 @@
+// { dg-options -std=c++1y }
+
+int
+operator LLs(unsigned long long) // { dg-error invalid encoding prefix in 
literal operator }
+{ return 0; }
+
+int
+operator us16(unsigned long long) // { dg-error invalid encoding prefix in 
literal operator }
+{ return 0; }
+
+int
+operator Us32(unsigned long long) // { dg-error invalid encoding prefix in 
literal operator }
+{ return 0; }
+
+int
+operator u8u8s(unsigned long long) // { dg-error invalid encoding prefix in 
literal operator }
+{ return 0; }
Index: gcc/testsuite/g++.dg/cpp1y/udlit-userdef-string.C
===
--- gcc/testsuite/g++.dg/cpp1y/udlit-userdef-string.C   (revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/udlit-userdef-string.C   (working copy)
@@ -0,0 +1,7 @@
+// { dg-options -std=c++1y }
+
+#include complex_literals.h
+
+auto cx = 1.1if;
+
+auto cn = 123if;


Re: C++ 2014 status page for libstdc++

2013-06-25 Thread Ed Smith-Rowland

On 06/25/2013 11:59 AM, Jonathan Wakely wrote:

On 25 June 2013 16:45,  3dw...@verizon.net wrote:

Here is a C++2014 status page for fun and profit.

Excellent, thanks!


Tested with xmllint.  Are there any other tests I should do?

The makefile target to check the docbook manual is:
make doc-xml-validate-docbook

Checked clean.


It should also be linked from doc/xml/manual/intro.xml so it appears
as part of the manual.

Done.


The first paragraph says the table is based on the table of contents
of the CD, but it isn't.  I agree with only showing the C++14 changes,
but the first paragraph should be changed (or removed.)


Just removed this paragraph.

Applied.

Ed

2013-06-25  Ed Smith-Rowland  3dw...@verizon.net

Status page for C++2014 library features
* doc/xml/faq.xml: Add link to new C++14 status page.
* doc/xml/manual/intro.xml: Ditto.
* doc/xml/manual/status_cxx2014.xml: New.

Index: doc/xml/faq.xml
===
--- doc/xml/faq.xml (revision 200378)
+++ doc/xml/faq.xml (working copy)
@@ -694,6 +694,7 @@
 link linkend=status.iso.1998C++98/link,
 link linkend=status.iso.tr1TR1/link, and 
 link linkend=status.iso.2011C++11/link.
+link linkend=status.iso.2014C++14/link.
 /para 
   /answer
 /qandaentry
Index: doc/xml/manual/intro.xml
===
--- doc/xml/manual/intro.xml(revision 200378)
+++ doc/xml/manual/intro.xml(working copy)
@@ -29,11 +29,15 @@
 xi:include xmlns:xi=http://www.w3.org/2001/XInclude; parse=xml 
href=status_cxx2011.xml
 /xi:include
 
-!-- Section 01.3 : Status C++ TR1 --
+!-- Section 01.3 : Status C++ 2014 --
+xi:include xmlns:xi=http://www.w3.org/2001/XInclude; parse=xml 
href=status_cxx2014.xml
+/xi:include
+
+!-- Section 01.4 : Status C++ TR1 --
 xi:include xmlns:xi=http://www.w3.org/2001/XInclude; parse=xml 
href=status_cxxtr1.xml
 /xi:include
 
-!-- Section 01.4 : Status C++ TR24733 --
+!-- Section 01.5 : Status C++ TR24733 --
 xi:include xmlns:xi=http://www.w3.org/2001/XInclude; parse=xml 
href=status_cxxtr24733.xml
 /xi:include
   /section
Index: doc/xml/manual/status_cxx2014.xml
===
--- doc/xml/manual/status_cxx2014.xml   (revision 0)
+++ doc/xml/manual/status_cxx2014.xml   (revision 0)
@@ -0,0 +1,201 @@
+section xmlns=http://docbook.org/ns/docbook; version=5.0 
+xml:id=status.iso.2014 xreflabel=Status C++ 2014
+?dbhtml filename=status_iso_cxx2014.html?
+
+infotitleC++ 2014/title
+  keywordset
+keywordISO C++/keyword
+keyword2014/keyword
+  /keywordset
+/info
+
+para
+In this implementation literal-std=gnu++1y/literal or
+literal-std=c++1y/literal flags must be used to enable language
+and library
+features. See link linkend=manual.intro.using.flagsdialect/link
+options. The pre-defined symbol
+constant__cplusplus/constant is used to check for the
+presence of the required flag.
+/para
+
+para
+This page describes the C++14 support in mainline GCC SVN, not in any
+particular release.
+/para
+
+table frame=all
+titleC++ 2014 Implementation Status/title
+
+tgroup cols=4 align=left colsep=0 rowsep=1
+colspec colname=c1/
+colspec colname=c2/
+colspec colname=c3/
+colspec colname=c4/
+  thead
+row
+  entryPaper/entry
+  entryTitle/entry
+  entryStatus/entry
+  entryComments/entry
+/row
+  /thead
+
+  tbody
+
+row
+  entryN3669/entry
+  entryFixing constexpr member functions without const/entry
+  entryY/entry
+  entry/
+/row
+
+row
+  entryN3668/entry
+  entrycodeexchange()/code utility function/entry
+  entryY/entry
+  entry/
+/row
+
+row
+  entryN3670/entry
+  entryWording for Addressing Tuples by Type/entry
+  entryY/entry
+  entry/
+/row
+
+row
+  entryN3656/entry
+  entrycodemake_unique/code/entry
+  entryY/entry
+  entry/
+/row
+
+row
+  entryN3462/entry
+  entrycodestd::result_of/code and SFINAE/entry
+  entryY/entry
+  entry/
+/row
+
+row
+  entryN3545/entry
+  entryAn Incremental Improvement to 
codeintegral_constant/code/entry
+  entryY/entry
+  entry/
+/row
+
+row
+  entryN3642/entry
+  entryUser-defined Literals for Standard Library Types/entry
+  entryY/entry
+  entry/
+/row
+
+row
+  entryN3671/entry
+  entryMaking non-modifying sequence operations more robust/entry
+  entryY/entry
+  entry/
+/row
+
+row
+  entryN3654/entry
+  entryQuoted Strings Library Proposal/entry
+  entryY/entry
+  entry/
+/row
+
+
+row
+  entryN3469/entry
+  entryConstexpr Library Additions: chrono/entry
+  entryY/entry
+  entry/
+/row
+
+row
+  entryN3470/entry
+  entryConstexpr Library Additions: containers

Re: [Bug libstdc++/56430] In __airy: return-statement with a value, in function returning 'void'.

2013-06-13 Thread Ed Smith-Rowland

On 06/13/2013 04:30 AM, Paolo Carlini wrote:

On 06/13/2013 02:38 AM, Paolo Carlini wrote:
If we really have to add a testcase - I'm not sure - please double 
check that it passes testing with -Wall, no unused vars.
Patch as went in had still the testcase wrong, triggering at least 3 
warnings with -Wall. All in all, I decided to also remove the 
additional functions: it doesn't make sense to add *now* functions to 
tr1, which otherwise is deeply in regression fixes only mode. And 
certainly not under a completely unrelated PR.


Paolo.


1. Fine. I get fixing just the PR and not conflating things.

2. How do you test with Wall?  Do you just test just the library with 
Wall or the whole build?
I've tried several 'make check-libstdc++ RUNTESTFLAGS=-Wall', etc. and 
no dice.

Obviously I should have hit the test with wall.  Sorry.

3. I would like to implement TR29123 which adds the TR1 math functions 
to std.  I obviously would like to make cleanups to the algorithms there.
We could either copy the math libs to bits and maintain separate files 
for the same functions or we could keep the math headers in one place.  
If we don't add anything to the math it seems like splitting the 
implementation would be a waste.  There would be a lot of overlap.  
OTOH, cleaning up TR29123 in, say, bits and totally leaving tr1 alone 
would encourage people to switch up (especially with guidance to that 
effect).


4. I would like some way to add experimental support for new math 
functions that appear in std proposal papers (airy_ai, etc.).  I suppose 
tr2 or ext.  Any ideas which you'd prefer?




Re: [Bug libstdc++/56430] In __airy: return-statement with a value, in function returning 'void'.

2013-06-12 Thread Ed Smith-Rowland




 Original Message 
Subject: 	Re: [Bug libstdc++/56430] In __airy: return-statement with a 
value, in function returning 'void'.

Date:   Wed, 12 Jun 2013 20:02:27 -0400
From:   Ed Smith-Rowland 3dw...@verizon.net
To: 	libstd...@gcc.gnu.org libstd...@gcc.gnu.org, gcc-patches 
gcc-patches@gcc.gnu.org







 Original Message 
Subject: 	Re: [Bug libstdc++/56430] In __airy: return-statement with a 
value, in function returning 'void'.

Date:   Wed, 12 Jun 2013 19:57:13 -0400
From:   Ed Smith-Rowland 3dw...@verizon.net
To: Paolo Carlini paolo.carl...@oracle.com



On 06/12/2013 05:31 PM, Paolo Carlini wrote:

Hi,

On 06/12/2013 10:28 PM,3dw...@verizon.net  wrote:

Here is an overdue patch for the Airy function.
I repair the void function and I out two Airy functions as C++
extensions.

Built and tested on x86_64-linux.

OK?

The functions are unused, please remove them and close the PR.

Thanks,
Paolo.


The point of the patch is to fix the base function and then offer access
to the function as a gcc extension.  boost has these functions.  These
have been offered in C++ library papers extending TR 29123.

Or is the point you would rather us remove the function to fix the PR.
Then add extensions separately?

My eventual goal is to fix this and several other issues in the maths
stuff, then implement TR 29123 (Push most TR1 maths to namespace std).

Ed







Clean up after standard literals patch.

2013-06-07 Thread Ed Smith-Rowland

Greetings,

Jonathan had asked if I could make some simplifications to the 
organization of C++ versioning macros and namespaces in my standard 
literals patch.  I plum forgot to do it before I put in the patch.


Also, I noticed I had picked up some garbage comments in the test cases.

This patch cleans all that up.

Built and tested on x86_64-linux.

Thanks,
Ed Smith-Rowland


2013-06-07  Ed Smith-Rowland  3dw...@verizon.net

Simplify and clean up library literals.
* include/std/chrono: Simplify namespace and versioning management.
* include/bits/basic_string.h: Ditto.
* testsuite/20_util/duration/literals/types.cc: Remove bogus comment.
* testsuite/20_util/duration/literals/values.cc: Ditto.
* testsuite/21_strings/basic_string/literals/types.cc: Ditto.
* testsuite/21_strings/basic_string/literals/values.cc: Ditto.

Index: include/std/chrono
===
--- include/std/chrono  (revision 199730)
+++ include/std/chrono  (working copy)
@@ -713,7 +713,7 @@
  *
  *  Time returned represents wall time from the system-wide clock.
 */
- struct system_clock
+struct system_clock
 {
   typedef chrono::nanoseconds  duration;
   typedef duration::reprep;
@@ -775,148 +775,137 @@
 */
 using high_resolution_clock = system_clock;
 
-  } // end inline namespace _V2
+} // end inline namespace _V2
 
   _GLIBCXX_END_NAMESPACE_VERSION
   } // namespace chrono
 
-  // @} group chrono
-} // namespace
+#if __cplusplus  201103L
 
-#endif //_GLIBCXX_USE_C99_STDINT_TR1
+  inline namespace literals {
+  inline namespace chrono_literals {
 
-#endif // C++11
+namespace __detail {
 
-#if __cplusplus  201103L
+  using namespace __parse_int;
 
-#ifdef _GLIBCXX_USE_C99_STDINT_TR1
+  templateunsigned long long _Val, typename _Dur
+   struct _Select_type
+   : conditional
+   _Val = static_castunsigned long long
+ (numeric_limitstypename _Dur::rep::max()),
+   _Dur, void
+   {
+ static constexpr typename _Select_type::type
+   value{static_casttypename _Select_type::type(_Val)};
+   };
 
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  templateunsigned long long _Val, typename _Dur
+   constexpr typename _Select_type_Val, _Dur::type
+   _Select_type_Val, _Dur::value;
 
-inline namespace literals {
-inline namespace chrono_literals {
+} // __detail
 
-  namespace __detail {
+constexpr chrono::durationlong double, ratio3600,1
+operator h(long double __hours)
+{ return chrono::durationlong double, ratio3600,1{__hours}; }
 
-using namespace __parse_int;
-
-templateunsigned long long _Val, typename _Dur
-  struct _Select_type
-  : conditional
- _Val = static_castunsigned long long
-   (numeric_limitstypename _Dur::rep::max()),
- _Dur, void
+template char... _Digits
+  constexpr typename
+  __detail::_Select_type__select_int::_Select_int_Digits...::value,
+chrono::hours::type
+  operator h()
   {
-   static constexpr typename _Select_type::type
- value{static_casttypename _Select_type::type(_Val)};
-  };
+   return __detail::_Select_type
+ __select_int::_Select_int_Digits...::value,
+ chrono::hours::value;
+  }
 
-templateunsigned long long _Val, typename _Dur
-  constexpr typename _Select_type_Val, _Dur::type
-  _Select_type_Val, _Dur::value;
+constexpr chrono::durationlong double, ratio60,1
+operator min(long double __mins)
+{ return chrono::durationlong double, ratio60,1{__mins}; }
 
-  } // __detail
+template char... _Digits
+  constexpr typename
+  __detail::_Select_type__select_int::_Select_int_Digits...::value,
+chrono::minutes::type
+  operator min()
+  {
+   return __detail::_Select_type
+ __select_int::_Select_int_Digits...::value,
+ chrono::minutes::value;
+  }
 
-  constexpr chrono::durationlong double, ratio3600,1
-  operator h(long double __hours)
-  { return chrono::durationlong double, ratio3600,1{__hours}; }
+constexpr chrono::durationlong double
+operator s(long double __secs)
+{ return chrono::durationlong double{__secs}; }
 
-  template char... _Digits
-constexpr typename
-__detail::_Select_type__select_int::_Select_int_Digits...::value,
-  chrono::hours::type
-operator h()
-{
-  return __detail::_Select_type
-   __select_int::_Select_int_Digits...::value,
-   chrono::hours::value;
-}
+template char... _Digits
+  constexpr typename
+  __detail

Re: [libstdc++-v3][C++14] Implement N3654 - Quoted Strings

2013-06-07 Thread Ed Smith-Rowland

On 06/06/2013 10:55 AM, Ed Smith-Rowland wrote:

On 06/05/2013 04:01 PM, Jonathan Wakely wrote:

On 5 June 2013 20:18, Ed Smith-Rowland wrote:

Greetings,
This patch implements quoted string manipulators for C++14.

27.7.6 - Quoted manipulators[quoted.manip].

The idea is to allow round trip insert and extract of strings with 
spaces.


   std::stringstream ss;
   std::string original = thing1  thing1;
   std::string round_trip;
   ss  std::quoted(original);
   ss  std::quoted(round_trip);
   assert( original == round_trip );

Builds and tests clean on x86-64-linux.

As I suggested for your literals patch, couldn't the test for:
#if __cplusplus  201103L
go inside the existing one?

i.e.

#if __cplusplus = 201103L
[...]
#if __cplusplus  201103L
[...]
#endif
#endif
Certainly.  I forgot that in the last literals patch.  I'll fix that 
after I finish this one. (I just noticed junk comments in the 
testcases for literals also).



_Quoted_string appears to do two copies of the string, one for the
constructor argument and one for the member variable, do they
definitely get elided?
I looks that way.  But all used of the template parm String are either 
references or pointers so these operations should be efficient.

_Quoted_string should be used as a non-owning string thing.


The members of _Quoted_string should be named _M_xxx not __xxx, to
follow the coding style guidelines.

Done.


What is __delim2 for?

What if the first extraction in the operator fails, is doing
__is.unget() the right thing to do?

Thanks. I'll return with __is rather than attempting to continue reading.


You could simplify the quoted() overloads by using auto return type
deduction, is it an intentional choice not to use that?
For some reason I forgot about auto return type in C++14.  It sure 
cleans things up nicely.  Done.

Rebuilt and retested on x86_64



OK, I added a static_assert to check that _String is only reference or 
pointer.
I also added a tests that check the case where _String is 'const 
basic_string'.


Built and tested on x86_64-linux.

OK?

Ed


2013-06-08  Ed Smith-Rowland  3dw...@verizon.net

Implement N3654 - Quoted Strings Library Proposal
* include/std/iomanip: Add quoted(String, Char delim, Char escape)
manipulators and supporting machinery in c++1y mode.
* testsuite/27_io/manipulators/standard/char/quoted.cc: New.
* testsuite/27_io/manipulators/standard/wchar_t/quoted.cc: New.
Index: include/std/iomanip
===
--- include/std/iomanip (revision 199730)
+++ include/std/iomanip (working copy)
@@ -334,8 +334,161 @@
   return __os; 
 }
 
-#endif
+#if __cplusplus  201103L
 
+  namespace __detail {
+
+/**
+ * @brief Struct for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _String, typename _CharT
+  struct _Quoted_string
+  {
+   static_assert(is_reference_String::value
+  || is_pointer_String::value,
+ String type must be pointer or reference);
+
+   _Quoted_string(_String __str, _CharT __del, _CharT __esc)
+   : _M_string(__str), _M_delim{__del}, _M_escape{__esc}
+   { }
+
+   _Quoted_string
+   operator=(_Quoted_string) = delete;
+
+   _String _M_string;
+   _CharT _M_delim;
+   _CharT _M_escape;
+  };
+
+/**
+ * @brief Inserter for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _CharT, typename _Traits
+  auto
+  operator(std::basic_ostream_CharT, _Traits __os,
+const _Quoted_stringconst _CharT*, _CharT __str)
+  {
+   __os  __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;
+ }
+   __os  __str._M_delim;
+
+   return __os;
+  }
+
+/**
+ * @brief Inserter for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _CharT, typename _Traits, typename _String
+  auto
+  operator(std::basic_ostream_CharT, _Traits __os,
+const _Quoted_string_String, _CharT __str)
+  {
+   __os  __str._M_delim;
+   for (auto __c : __str._M_string)
+ {
+   if (__c == __str._M_delim || __c == __str._M_escape)
+ __os  __str._M_escape;
+   __os  __c;
+ }
+   __os  __str._M_delim;
+
+   return __os;
+  }
+
+/**
+ * @brief Extractor for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _CharT, typename _Traits, typename _Alloc
+  auto
+  operator(std::basic_istream_CharT, _Traits __is,
+const _Quoted_stringbasic_string_CharT, _Traits

Re: [libstdc++-v3][C++14] Implement N3654 - Quoted Strings

2013-06-06 Thread Ed Smith-Rowland

On 06/05/2013 04:01 PM, Jonathan Wakely wrote:

On 5 June 2013 20:18, Ed Smith-Rowland wrote:

Greetings,
This patch implements quoted string manipulators for C++14.

27.7.6 - Quoted manipulators[quoted.manip].

The idea is to allow round trip insert and extract of strings with spaces.

   std::stringstream ss;
   std::string original = thing1  thing1;
   std::string round_trip;
   ss  std::quoted(original);
   ss  std::quoted(round_trip);
   assert( original == round_trip );

Builds and tests clean on x86-64-linux.

As I suggested for your literals patch, couldn't the test for:
#if __cplusplus  201103L
go inside the existing one?

i.e.

#if __cplusplus = 201103L
[...]
#if __cplusplus  201103L
[...]
#endif
#endif
Certainly.  I forgot that in the last literals patch.  I'll fix that 
after I finish this one. (I just noticed junk comments in the testcases 
for literals also).



_Quoted_string appears to do two copies of the string, one for the
constructor argument and one for the member variable, do they
definitely get elided?
I looks that way.  But all used of the template parm String are either 
references or pointers so these operations should be efficient.

_Quoted_string should be used as a non-owning string thing.


The members of _Quoted_string should be named _M_xxx not __xxx, to
follow the coding style guidelines.

Done.


What is __delim2 for?

What if the first extraction in the operator fails, is doing
__is.unget() the right thing to do?

Thanks. I'll return with __is rather than attempting to continue reading.


You could simplify the quoted() overloads by using auto return type
deduction, is it an intentional choice not to use that?
For some reason I forgot about auto return type in C++14.  It sure 
cleans things up nicely.  Done.

Rebuilt and retested on x86_64


2013-06-05  Ed Smith-Rowland  3dw...@verizon.net

Implement N3654 - Quoted Strings Library Proposal
* include/std/iomanip: Add quoted(String, Char delim, Char escape)
manipulators and supporting machinery in c++1y mode.
* testsuite/27_io/manipulators/standard/char/quoted.cc: New.
* testsuite/27_io/manipulators/standard/wchar_t/quoted.cc: New.
Index: include/std/iomanip
===
--- include/std/iomanip (revision 199730)
+++ include/std/iomanip (working copy)
@@ -334,8 +334,157 @@
   return __os; 
 }
 
-#endif
+#if __cplusplus  201103L
 
+  namespace __detail {
+
+/**
+ * @brief Struct for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _String, typename _CharT
+  struct _Quoted_string
+  {
+   _Quoted_string(_String __str, _CharT __del, _CharT __esc)
+   : _M_string(__str), _M_delim{__del}, _M_escape{__esc}
+   { }
+
+   _Quoted_string
+   operator=(_Quoted_string) = delete;
+
+   _String _M_string;
+   _CharT _M_delim;
+   _CharT _M_escape;
+  };
+
+/**
+ * @brief Inserter for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _CharT, typename _Traits
+  auto
+  operator(std::basic_ostream_CharT, _Traits __os,
+const _Quoted_stringconst _CharT*, _CharT __str)
+  {
+   __os  __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;
+ }
+   __os  __str._M_delim;
+
+   return __os;
+  }
+
+/**
+ * @brief Inserter for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _CharT, typename _Traits, typename _String
+  auto
+  operator(std::basic_ostream_CharT, _Traits __os,
+const _Quoted_string_String, _CharT __str)
+  {
+   __os  __str._M_delim;
+   for (auto __c : __str._M_string)
+ {
+   if (__c == __str._M_delim || __c == __str._M_escape)
+ __os  __str._M_escape;
+   __os  __c;
+ }
+   __os  __str._M_delim;
+
+   return __os;
+  }
+
+/**
+ * @brief Extractor for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _CharT, typename _Traits, typename _Alloc
+  auto
+  operator(std::basic_istream_CharT, _Traits __is,
+const _Quoted_stringbasic_string_CharT, _Traits, _Alloc,
+ _CharT __str)
+  {
+   __str._M_string.clear();
+
+   _CharT __c;
+   __is  __c;
+   if (!__is.good())
+ return __is;
+   if (__c != __str._M_delim)
+ {
+   __is.unget();
+   __is  __str._M_string;
+   return __is;
+ }
+   std::ios_base::fmtflags __flags
+ = __is.flags(__is.flags()  ~std

[libstdc++-v3][C++14] Implement N3654 - Quoted Strings

2013-06-05 Thread Ed Smith-Rowland

Greetings,
This patch implements quoted string manipulators for C++14.

27.7.6 - Quoted manipulators[quoted.manip].

The idea is to allow round trip insert and extract of strings with spaces.

  std::stringstream ss;
  std::string original = thing1  thing1;
  std::string round_trip;
  ss  std::quoted(original);
  ss  std::quoted(round_trip);
  assert( original == round_trip );

Builds and tests clean on x86-64-linux.

Ed Smith-Rowland


2013-06-05  Ed Smith-Rowland  3dw...@verizon.net

Implement N3654 - Quoted Strings Library Proposal
* include/std/iomanip: Add quoted(String, Char delim, Char escape)
manipulators and supporting machinery in c++1y mode.
* testsuite/27_io/manipulators/standard/char/quoted.cc: New.
* testsuite/27_io/manipulators/standard/wchar_t/quoted.cc: New.
Index: include/std/iomanip
===
--- include/std/iomanip (revision 199583)
+++ include/std/iomanip (working copy)
@@ -336,6 +336,160 @@
 
 #endif
 
+#if __cplusplus  201103L
+
+  namespace __detail {
+
+/**
+ * @brief Struct for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _String, typename _CharT
+  struct _Quoted_string
+  {
+   _Quoted_string(_String __str, _CharT __del, _CharT __esc)
+   : __string(__str), __delim{__del}, __escape{__esc}, __delim2{__del}
+   { }
+
+   _Quoted_string(_String __str, _CharT __del, _CharT __esc,
+  _CharT __del2)
+   : __string(__str), __delim{__del}, __escape{__esc}, __delim2{__del2}
+   { }
+
+   _Quoted_string
+   operator=(_Quoted_string) = delete;
+
+   _String __string;
+   _CharT __delim;
+   _CharT __escape;
+   _CharT __delim2;
+  };
+
+/**
+ * @brief Inserter for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _CharT, typename _Traits
+  std::basic_ostream_CharT, _Traits
+  operator(std::basic_ostream_CharT, _Traits __os,
+const _Quoted_stringconst _CharT*, _CharT __str)
+  {
+   __os  __str.__delim;
+   for (const _CharT* __c = __str.__string; *__c; ++__c)
+ {
+   if (*__c == __str.__delim || *__c == __str.__escape)
+ __os  __str.__escape;
+   __os  *__c;
+ }
+   __os  __str.__delim2;
+
+   return __os;
+  }
+
+/**
+ * @brief Inserter for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _CharT, typename _Traits, typename _String
+  std::basic_ostream_CharT, _Traits
+  operator(std::basic_ostream_CharT, _Traits __os,
+const _Quoted_string_String, _CharT __str)
+  {
+   __os  __str.__delim;
+   for (auto __c : __str.__string)
+ {
+   if (__c == __str.__delim || __c == __str.__escape)
+ __os  __str.__escape;
+   __os  __c;
+ }
+   __os  __str.__delim2;
+
+   return __os;
+  }
+
+/**
+ * @brief Extractor for delimited strings.
+ *The left and right delimiters can be different.
+ */
+templatetypename _CharT, typename _Traits, typename _Alloc
+  std::basic_istream_CharT, _Traits
+  operator(std::basic_istream_CharT, _Traits __is,
+const _Quoted_stringbasic_string_CharT, _Traits, _Alloc,
+ _CharT __str)
+  {
+   __str.__string.clear();
+
+   _CharT __c;
+   __is  __c;
+   if (__c != __str.__delim)
+ {
+   __is.unget();
+   __is  __str.__string;
+   return __is;
+ }
+   std::ios_base::fmtflags __flags
+ = __is.flags(__is.flags()  ~std::ios_base::skipws);
+   do
+ {
+   __is  __c;
+   if (!__is.good())
+ break;
+   if (__c == __str.__escape)
+ {
+   __is  __c;
+   if (!__is.good())
+ break;
+ }
+   else if (__c == __str.__delim2)
+ break;
+   __str.__string += __c;
+ }
+   while (true);
+   __is.setf(__flags);
+
+   return __is;
+  }
+
+  } // namespace __detail
+
+  /**
+   * @brief Manipulator for quoted strings.
+   * @param __strString to quote.
+   * @param __delim  Character to quote string with.
+   * @param __escape Escape character to escape itself or quote character.
+   */
+  templatetypename _CharT
+__detail::_Quoted_stringconst _CharT*, _CharT
+inline quoted(const _CharT* __str,
+  _CharT __delim = _CharT(''), _CharT __escape = _CharT('\\'))
+{
+  return __detail::_Quoted_stringconst _CharT*, _CharT(__str, __delim,
+__escape);
+}
+
+  templatetypename _CharT, typename _Traits, typename _Alloc

Re: Implement N3642 - User-defined Literals for Standard Library Types

2013-06-01 Thread Ed Smith-Rowland

Committed the following...


2013-05-30  Ed Smith-Rowland  3dw...@verizon.net

Implement N3642 - User-defined Literals for Standard Library Types
* include/bits/parse_numbers.h: New.
* include/std/chrono: Add duration literal operators.
* include/bits/basic_string.h: Add string literal operators.
* include/Makefile.in: Add parse_numbers.h.
* include/Makefile.am: Ditto.
* testsuite/20_util/duration/literals/values.cc: New.
* testsuite/20_util/duration/literals/types.cc: New.
* 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/21_strings/basic_string/literals/values.cc: New.
* testsuite/21_strings/basic_string/literals/types.cc: New.

Index: include/bits/parse_numbers.h
===
--- include/bits/parse_numbers.h(revision 0)
+++ include/bits/parse_numbers.h(working copy)
@@ -0,0 +1,417 @@
+// Components for compile-time parsing of numbers -*- C++ -*-
+
+// 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.
+
+// 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
+// http://www.gnu.org/licenses/.
+
+/** @file bits/parse_numbers.h
+ *  This is an internal header file, included by other library headers.
+ *  Do not attempt to use it directly. @headername{chrono}
+ */
+
+#ifndef _PARSE_NUMBERS_H
+#define _PARSE_NUMBERS_H 1
+
+#pragma GCC system_header
+
+// From n3642.pdf except I added binary literals and digit separator '`'.
+
+#if __cplusplus  201103L
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+namespace __parse_int {
+
+  templateunsigned _Base, char _Dig
+struct _Digit;
+
+  templateunsigned _Base
+struct _Digit_Base, '0'
+{
+  static constexpr bool valid{true};
+  static constexpr unsigned value{0};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '1'
+{
+  static constexpr bool valid{true};
+  static constexpr unsigned value{1};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '2'
+{
+  static_assert(_Base  2, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{2};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '3'
+{
+  static_assert(_Base  3, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{3};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '4'
+{
+  static_assert(_Base  4, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{4};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '5'
+{
+  static_assert(_Base  5, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{5};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '6'
+{
+  static_assert(_Base  6, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{6};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '7'
+{
+  static_assert(_Base  7, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{7};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '8'
+{
+  static_assert(_Base  8, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{8};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '9'
+{
+  static_assert(_Base  9, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{9};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, 'a'
+{
+  static_assert(_Base  0xa, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{0xa};
+};
+
+  templateunsigned _Base
+struct _Digit_Base

[libstdc++-v3] Collapse redundant 'inline' from 'inline constexpr'.

2013-06-01 Thread Ed Smith-Rowland

All,

Paolo Carlini pointed out that I introduced a number of 'inline 
constexpr' in my last std literals patch.
Section 7.1.5/2: constexpr functions and constexpr constructors are 
implicitly inline (7.1.2).


I noticed that there are two other headers that have this.

Does anyone mind if i just clean this up?

Builds and tests clean on x86_64-linux.

Ed


2013-06-01  Ed Smith-Rowland  3dw...@verizon.net

include/std/chrono: Collapse redundant 'inline' from 'inline constexpr'.
include/std/tuple: Ditto.
include/bits/move.h: Ditto.
Index: include/std/chrono
===
--- include/std/chrono  (revision 199584)
+++ include/std/chrono  (working copy)
@@ -819,12 +819,12 @@
 
   } // __detail
 
-  inline constexpr chrono::durationlong double, ratio3600,1
+  constexpr chrono::durationlong double, ratio3600,1
   operator h(long double __hours)
   { return chrono::durationlong double, ratio3600,1{__hours}; }
 
   template char... _Digits
-inline constexpr typename
+constexpr typename
 __detail::_Select_type__select_int::_Select_int_Digits...::value,
   chrono::hours::type
 operator h()
@@ -834,12 +834,12 @@
chrono::hours::value;
 }
 
-  inline constexpr chrono::durationlong double, ratio60,1
+  constexpr chrono::durationlong double, ratio60,1
   operator min(long double __mins)
   { return chrono::durationlong double, ratio60,1{__mins}; }
 
   template char... _Digits
-inline constexpr typename
+constexpr typename
 __detail::_Select_type__select_int::_Select_int_Digits...::value,
   chrono::minutes::type
 operator min()
@@ -849,12 +849,12 @@
chrono::minutes::value;
 }
 
-  inline constexpr chrono::durationlong double
+  constexpr chrono::durationlong double
   operator s(long double __secs)
   { return chrono::durationlong double{__secs}; }
 
   template char... _Digits
-inline constexpr typename
+constexpr typename
 __detail::_Select_type__select_int::_Select_int_Digits...::value,
   chrono::seconds::type
 operator s()
@@ -864,12 +864,12 @@
chrono::seconds::value;
 }
 
-  inline constexpr chrono::durationlong double, milli
+  constexpr chrono::durationlong double, milli
   operator ms(long double __msecs)
   { return chrono::durationlong double, milli{__msecs}; }
 
   template char... _Digits
-inline constexpr typename
+constexpr typename
 __detail::_Select_type__select_int::_Select_int_Digits...::value,
   chrono::milliseconds::type
 operator ms()
@@ -879,12 +879,12 @@
chrono::milliseconds::value;
 }
 
-  inline constexpr chrono::durationlong double, micro
+  constexpr chrono::durationlong double, micro
   operator us(long double __usecs)
   { return chrono::durationlong double, micro{__usecs}; }
 
   template char... _Digits
-inline constexpr typename
+constexpr typename
 __detail::_Select_type__select_int::_Select_int_Digits...::value,
   chrono::microseconds::type
 operator us()
@@ -894,12 +894,12 @@
chrono::microseconds::value;
 }
 
-  inline constexpr chrono::durationlong double, nano
+  constexpr chrono::durationlong double, nano
   operator ns(long double __nsecs)
   { return chrono::durationlong double, nano{__nsecs}; }
 
   template char... _Digits
-inline constexpr typename
+constexpr typename
 __detail::_Select_type__select_int::_Select_int_Digits...::value,
   chrono::nanoseconds::type
 operator ns()
Index: include/std/tuple
===
--- include/std/tuple   (revision 199583)
+++ include/std/tuple   (working copy)
@@ -856,25 +856,25 @@
 }
 
   templatetypename... _TElements, typename... _UElements
-inline constexpr bool
+constexpr bool
 operator!=(const tuple_TElements... __t,
   const tuple_UElements... __u)
 { return !(__t == __u); }
 
   templatetypename... _TElements, typename... _UElements
-inline constexpr bool
+constexpr bool
 operator(const tuple_TElements... __t,
  const tuple_UElements... __u)
 { return __u  __t; }
 
   templatetypename... _TElements, typename... _UElements
-inline constexpr bool
+constexpr bool
 operator=(const tuple_TElements... __t,
   const tuple_UElements... __u)
 { return !(__u  __t); }
 
   templatetypename... _TElements, typename... _UElements
-inline constexpr bool
+constexpr bool
 operator=(const tuple_TElements... __t,
   const tuple_UElements... __u)
 { return !(__t  __u); }
Index: include/bits/move.h
===
--- include/bits/move.h (revision 199583)
+++ include/bits/move.h

Re: [libstdc++-v3] Collapse redundant 'inline' from 'inline constexpr'.

2013-06-01 Thread Ed Smith-Rowland

On 06/01/2013 05:29 PM, Gabriel Dos Reis wrote:

please go ahead.

-- Gaby


Done.



Implement N3642 - User-defined Literals for Standard Library Types

2013-05-31 Thread Ed Smith-Rowland

Greetings,

This patch implements N3642 - User-defined literals for 
std::chrono::duration and std::basic_string

and N3660 - User-defined literals for std::complex.

User-defined literals were separated into two papers because of some 
controversy about noexcept for complex literals.
If desired, I could split the patch into two bits for the two 
proposals.  OTOH, I'm pretty sure complex literals will make it in.


The patch includes a utility for compile-time parsing of integers which 
is a modified version of that suggested in N3642.
Support for binary literals of the form 0b01010 and support for a digit 
separator are added relative to that paper.

The digit parsing is used in the chrono literals.

One bit: I would like someone to look over my treatment of namespace 
versioning and tell me if that's OK

and/or whether I need to mess with gnu-versioned-namespace.ver.

Otherwise, this builds and tests clean on x86_64-linux.

Thanks,
Ed


2013-05-30  Ed Smith-Rowland  3dw...@verizon.net

Implement N3642 - User-defined Literals for Standard Library Types
Implement N3660 - User-defined Literals for std::complex,
part 2 of UDL for Standard Library Types
* include/bits/parse_numbers.h: New.
* include/std/chrono: Add duration literal operators.
* include/bits/basic_string.h: Add string literal operators.
* include/std/complex: Add complex literal operators.
* include/Makefile.in: Add parse_numbers.h.
* include/Makefile.am: Ditto.
* testsuite/20_util/duration/literals/values.cc: New.
* testsuite/20_util/duration/literals/types.cc: New.
* 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/21_strings/basic_string/literals/values.cc: New.
* testsuite/21_strings/basic_string/literals/types.cc: New.
* testsuite/26_numerics/complex/literals/types.cc: New.
* testsuite/26_numerics/complex/literals/values.cc: New.
* config/abi/pre/gnu.ver: Add literal operator symbols.
Index: include/bits/parse_numbers.h
===
--- include/bits/parse_numbers.h(revision 0)
+++ include/bits/parse_numbers.h(working copy)
@@ -0,0 +1,417 @@
+// Components for compile-time parsing of numbers -*- C++ -*-
+
+// 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.
+
+// 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
+// http://www.gnu.org/licenses/.
+
+/** @file bits/parse_numbers.h
+ *  This is an internal header file, included by other library headers.
+ *  Do not attempt to use it directly. @headername{chrono}
+ */
+
+#ifndef _PARSE_NUMBERS_H
+#define _PARSE_NUMBERS_H 1
+
+#pragma GCC system_header
+
+// From n3642.pdf except I added binary literals and digit separator '`'.
+
+#if __cplusplus  201103L
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+namespace __parse_int {
+
+  templateunsigned _Base, char _Dig
+struct _Digit;
+
+  templateunsigned _Base
+struct _Digit_Base, '0'
+{
+  static constexpr bool valid{true};
+  static constexpr unsigned value{0};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '1'
+{
+  static constexpr bool valid{true};
+  static constexpr unsigned value{1};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '2'
+{
+  static_assert(_Base  2, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{2};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '3'
+{
+  static_assert(_Base  3, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{3};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '4'
+{
+  static_assert(_Base  4, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{4

Re: Implement N3642 - User-defined Literals for Standard Library Types

2013-05-31 Thread Ed Smith-Rowland

On 05/31/2013 10:41 AM, Daniel Krügler wrote:

2013/5/31 Ed Smith-Rowland 3dw...@verizon.net:

Greetings,

This patch implements N3642 - User-defined literals for
std::chrono::duration and std::basic_string
and N3660 - User-defined literals for std::complex.

  N3660 was rejected during the Bristol meeting, the main reason being
the ugliness of the complex-float literal and giving it some time to
find a possible sore language solution. Is there still the idea to add
this now?

- Daniel

I would offer a modification of the lower-case rule for standard literal 
operators (I know this is bikeshed but I think such things are important 
and obviously prevent ideas from being adopted).


I would say:

  1. Put the precision first in upper case.  As a matter of style I 
prefer 123456L to 123456l for normal literals anyway.  Also, the 
precision snuggles next to the number - then you modify it.  That seems 
logical to me.  Also, if we involve decimal in this someday, those 
literals *have* to be all caps (for the old literals).  It seems using 
lower case precision indicators for decimal would be inconsistent.


  2. Use lower case for the other characters except...

  3. If the name derives from a proper name, such as SI unit Farad use 
capitals.  This will make literal operators for units match SI and the 
expectation of users most likely to use such literals.


For complex this gives us:

  std::complexfloat
operator Fi(long double imag) noexcept;

  std::complexfloat
operator Fi(unsigned long long imag) noexcept;

std::complexdouble
operator i(long double imag) noexcept;

std::complexdouble
operator i(unsigned long long imag) noexcept;

std::complexlong double
operator Li(long double imag) noexcept;

std::complexlong double
operator Li(unsigned long long imag) noexcept;

This avoids the i_f, and seems more logical to me.

For the issue at hand, I split the patch.

Ed

Index: include/bits/parse_numbers.h
===
--- include/bits/parse_numbers.h(revision 0)
+++ include/bits/parse_numbers.h(working copy)
@@ -0,0 +1,417 @@
+// Components for compile-time parsing of numbers -*- C++ -*-
+
+// 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.
+
+// 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
+// http://www.gnu.org/licenses/.
+
+/** @file bits/parse_numbers.h
+ *  This is an internal header file, included by other library headers.
+ *  Do not attempt to use it directly. @headername{chrono}
+ */
+
+#ifndef _PARSE_NUMBERS_H
+#define _PARSE_NUMBERS_H 1
+
+#pragma GCC system_header
+
+// From n3642.pdf except I added binary literals and digit separator '`'.
+
+#if __cplusplus  201103L
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+namespace __parse_int {
+
+  templateunsigned _Base, char _Dig
+struct _Digit;
+
+  templateunsigned _Base
+struct _Digit_Base, '0'
+{
+  static constexpr bool valid{true};
+  static constexpr unsigned value{0};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '1'
+{
+  static constexpr bool valid{true};
+  static constexpr unsigned value{1};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '2'
+{
+  static_assert(_Base  2, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{2};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '3'
+{
+  static_assert(_Base  3, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{3};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '4'
+{
+  static_assert(_Base  4, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{4};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '5'
+{
+  static_assert(_Base  5, invalid digit);
+  static constexpr bool valid{true};
+  static constexpr unsigned value{5};
+};
+
+  templateunsigned _Base
+struct _Digit_Base, '6'
+{
+  static_assert(_Base

Re: [wwwdocs] C++14 support for binary literals says Noinstead of Yes

2013-04-28 Thread Ed Smith-Rowland

On 04/27/2013 02:59 AM, Jakub Jelinek wrote:

On Sat, Apr 27, 2013 at 01:03:17AM -0400, Ed Smith-Rowland wrote:

In htdocs/projects/cxx1y.html it says no for support of binary
literals.  I think that's a Yes actually.

Here is a little patchlet.

Am I missing something?
So yes... ;-)  I had tested on g++-4.1 and I guess pedantic let that go 
through back then. I swear -pedantic gave nothing...  Oh well.


I like the patch.  It compiled and tested clean on x86_64-linux.

I'm working on a little proposal to add std::bin manipulator and related 
stuff in analogy to std::hex, etc. to the library.  i think you should 
be able to write and extract binary literals.



Given
./xg++ -B ./ a.C -std=c++1y -pedantic-errors -S
a.C:1:9: error: binary constants are a GCC extension
  int i = 0b110101;
  ^

I'd say the fact that it is available as a GNU extension isn't sufficient to
mark this as supported.  I think you need something like (untested so far
except for make check-g++ RUNTESTFLAGS=*binary_const*):

2013-04-27  Jakub Jelinekja...@redhat.com

N3472 binary constants
* include/cpplib.h (struct cpp_options): Fix a typo in user_literals
field comment.  Add binary_constants field.
* init.c (struct lang_flags): Add binary_constants field.
(lang_defaults): Add bin_cst column to the table.
(cpp_set_lang): Initialize CPP_OPTION (pfile, binary_constants).
* expr.c (cpp_classify_number): Talk about C++11 instead of C++0x
in diagnostics.  Accept binary constants if
CPP_OPTION (pfile, binary_constants) even when pedantic.  Adjust
pedwarn message.

* g++.dg/cpp/limits.C: Adjust warning wording.
* g++.dg/system-binary-constants-1.C: Likewise.
* g++.dg/cpp1y/system-binary-constants-1.C: New test.

--- libcpp/include/cpplib.h.jj  2013-04-25 23:47:58.0 +0200
+++ libcpp/include/cpplib.h 2013-04-27 08:31:52.349122712 +0200
@@ -423,7 +423,7 @@ struct cpp_options
/* True for traditional preprocessing.  */
unsigned char traditional;
  
-  /* Nonzero for C++ 2011 Standard user-defnied literals.  */

+  /* Nonzero for C++ 2011 Standard user-defined literals.  */
unsigned char user_literals;
  
/* Nonzero means warn when a string or character literal is followed by a

@@ -434,6 +434,9 @@ struct cpp_options
   literal number suffixes as user-defined literal number suffixes.  */
unsigned char ext_numeric_literals;
  
+  /* Nonzero for C++ 2014 Standard binary constants.  */

+  unsigned char binary_constants;
+
/* Holds the name of the target (execution) character set.  */
const char *narrow_charset;
  
--- libcpp/init.c.jj	2013-04-25 23:47:58.0 +0200

+++ libcpp/init.c   2013-04-27 08:34:54.103120530 +0200
@@ -83,24 +83,25 @@ struct lang_flags
char uliterals;
char rliterals;
char user_literals;
+  char binary_constants;
  };
  
  static const struct lang_flags lang_defaults[] =

-{ /*  c99 c++ xnum xid std  //   digr ulit rlit user_literals */
-  /* GNUC89   */  { 0,  0,  1,   0,  0,   1,   1,   0,   0,0 },
-  /* GNUC99   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,0 },
-  /* GNUC11   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,0 },
-  /* STDC89   */  { 0,  0,  0,   0,  1,   0,   0,   0,   0,0 },
-  /* STDC94   */  { 0,  0,  0,   0,  1,   0,   1,   0,   0,0 },
-  /* STDC99   */  { 1,  0,  1,   0,  1,   1,   1,   0,   0,0 },
-  /* STDC11   */  { 1,  0,  1,   0,  1,   1,   1,   1,   0,0 },
-  /* GNUCXX   */  { 0,  1,  1,   0,  0,   1,   1,   0,   0,0 },
-  /* CXX98*/  { 0,  1,  1,   0,  1,   1,   1,   0,   0,0 },
-  /* GNUCXX11 */  { 1,  1,  1,   0,  0,   1,   1,   1,   1,1 },
-  /* CXX11*/  { 1,  1,  1,   0,  1,   1,   1,   1,   1,1 },
-  /* GNUCXX1Y */  { 1,  1,  1,   0,  0,   1,   1,   1,   1,1 },
-  /* CXX1Y*/  { 1,  1,  1,   0,  1,   1,   1,   1,   1,1 },
-  /* ASM  */  { 0,  0,  1,   0,  0,   1,   0,   0,   0,0 }
+{ /*  c99 c++ xnum xid std  //   digr ulit rlit udlit bin_cst */
+  /* GNUC89   */  { 0,  0,  1,   0,  0,   1,   1,   0,   0,   0,0 },
+  /* GNUC99   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,   0,0 },
+  /* GNUC11   */  { 1,  0,  1,   0,  0,   1,   1,   1,   1,   0,0 },
+  /* STDC89   */  { 0,  0,  0,   0,  1,   0,   0,   0,   0,   0,0 },
+  /* STDC94   */  { 0,  0,  0,   0,  1,   0,   1,   0,   0,   0,0 },
+  /* STDC99   */  { 1,  0,  1,   0,  1,   1,   1,   0,   0,   0,0 },
+  /* STDC11   */  { 1,  0,  1,   0,  1,   1,   1,   1,   0,   0,0 },
+  /* GNUCXX   */  { 0,  1,  1,   0,  0,   1,   1,   0,   0,   0,0 },
+  /* CXX98*/  { 0,  1,  1,   0,  1,   1,   1,   0,   0,   0,0 },
+  /* GNUCXX11 */  { 1,  1,  1,   0,  0,   1,   1,   1,   1,   1,0 },
+  /* CXX11*/  { 1,  1,  1,   0,  1,   1,   1,   1,   1,   1,0 },
+  /* GNUCXX1Y */  { 1,  1,  1,   0,  0,   1,   1,   1,   1,   1,1 },
+  /* CXX1Y

[wwwdocs] C++14 support for binary literals says Noinstead of Yes

2013-04-26 Thread Ed Smith-Rowland
In htdocs/projects/cxx1y.html it says no for support of binary 
literals.  I think that's a Yes actually.


Here is a little patchlet.

Am I missing something?

Index: htdocs/projects/cxx1y.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.1
diff -r1.1 cxx1y.html
56c56
   td class=unsupported align=centerNo/td
---
   td class=supported align=centerYes/td


[C++1y] Support n3599 - Literal operator templates for strings for C++1y

2013-04-16 Thread Ed Smith-Rowland
-options -std=c++11 }
+
+templatetypename CharT, CharT... String
+  int
+  operator _script()
+  { return 42; } // { dg-error literal operator template|has invalid 
parameter list }
+
+int i = hi!_script;
gcc/cp:

2013-04-17  Ed Smith-Rowland  3dw...@verizon.net

Implement n3599 - Literal operator templates for strings.
* parser.c (make_string_pack (tree value)): New function.
(cp_parser_userdef_string_literal (cp_token *)): Use it
to construct calls to character string literal operator templates.
(cp_parser_template_declaration_after_export): Check for new string
literal operator template parameter form.


gcc/testsuite:

2013-04-17  Ed Smith-Rowland  3dw...@verizon.net

Implement n3599 - Literal operator templates for strings.
* g++.dg/cpp1y/udlit-char-template.C: New test.
* g++.dg/cpp1y/udlit-char-template-neg.C: New test.


[C++11] There can be only one ref qualifier at most.

2013-04-04 Thread Ed Smith-Rowland

This is a minor nit on the C++ reference qualifiers.
Obviously, ref quals are not a sequence.
Adding multiple ref quals did error out but this patch cleans up the 
error from a few unexpected tokens to one root cause.

Also _seq is removed from te cp_parser function name.

builds and passes all tests on x86_64-linux.

Ed

Index: gcc/cp/parser.c
===
--- gcc/cp/parser.c (revision 197464)
+++ gcc/cp/parser.c (working copy)
@@ -2020,7 +2020,7 @@
   (cp_parser *);
 static cp_virt_specifiers cp_parser_virt_specifier_seq_opt
   (cp_parser *);
-static cp_ref_qualifier cp_parser_ref_qualifier_seq_opt
+static cp_ref_qualifier cp_parser_ref_qualifier_opt
   (cp_parser *);
 static tree cp_parser_late_return_type_opt
   (cp_parser *, cp_cv_quals);
@@ -16463,7 +16463,7 @@
  /* Parse the cv-qualifier-seq.  */
  cv_quals = cp_parser_cv_qualifier_seq_opt (parser);
  /* Parse the ref-qualifier. */
- ref_qual = cp_parser_ref_qualifier_seq_opt (parser);
+ ref_qual = cp_parser_ref_qualifier_opt (parser);
  /* And the exception-specification.  */
  exception_specification
= cp_parser_exception_specification_opt (parser);
@@ -17031,25 +17031,46 @@
Returns cp_ref_qualifier representing ref-qualifier. */
 
 static cp_ref_qualifier
-cp_parser_ref_qualifier_seq_opt (cp_parser* parser)
+cp_parser_ref_qualifier_opt (cp_parser* parser)
 {
   cp_ref_qualifier ref_qual = REF_QUAL_NONE;
-  cp_token *token = cp_lexer_peek_token (parser-lexer);
-  switch (token-type)
+
+  while (true)
 {
-case CPP_AND:
-  ref_qual = REF_QUAL_LVALUE;
-  break;
-case CPP_AND_AND:
-  ref_qual = REF_QUAL_RVALUE;
-  break;
+  cp_ref_qualifier curr_ref_qual = REF_QUAL_NONE;
+  cp_token *token = cp_lexer_peek_token (parser-lexer);
+
+  switch (token-type)
+   {
+   case CPP_AND:
+ curr_ref_qual = REF_QUAL_LVALUE;
+ break;
+
+   case CPP_AND_AND:
+ curr_ref_qual = REF_QUAL_RVALUE;
+ break;
+
+   default:
+ curr_ref_qual = REF_QUAL_NONE;
+ break;
+   }
+
+  if (!curr_ref_qual)
+   break;
+  else if (ref_qual)
+   {
+ error_at (token-location, multiple ref-qualifiers);
+ cp_lexer_purge_token (parser-lexer);
+   }
+  else
+   {
+ ref_qual = curr_ref_qual;
+ cp_lexer_consume_token (parser-lexer);
+   }
 }
 
   if (ref_qual)
-{
-  maybe_warn_cpp0x (CPP0X_REF_QUALIFIER);
-  cp_lexer_consume_token (parser-lexer);
-}
+maybe_warn_cpp0x (CPP0X_REF_QUALIFIER);
 
   return ref_qual;
 }
Index: gcc/testsuite/g++.dg/cpp0x/ref-qual-multi-neg.C
===
--- gcc/testsuite/g++.dg/cpp0x/ref-qual-multi-neg.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/ref-qual-multi-neg.C (revision 0)
@@ -0,0 +1,7 @@
+// { dg-require-effective-target c++11 }
+
+class Foo
+{
+public:
+  void bar() const   { }  // { dg-error multiple ref-qualifiers }
+};
gcc/cp:

2013-04-05  Ed Smith-Rowland  3dw...@verizon.net

* parser.c (cp_parser_ref_qualifier_seq_opt): Move to
cp_parser_ref_qualifier_opt.  Error if more than one ref-qual found.

gcc/testsuite:

2013-04-05  Ed Smith-Rowland  3dw...@verizon.net

* g++.dg/cpp0x/ref-qual-multi-neg.C: New test.


Re: [PATCH][C++11][ PR55582] Let string literals starting with lower-case 's' be a user-defined literal instead of string + macro.

2013-02-13 Thread Ed Smith-Rowland

On 02/13/2013 01:40 PM, Jason Merrill wrote:
I just noticed this patch.  Since it was submitted well before the end 
of stage 3 and looks quite safe, it's OK to go in for 4.8. Please 
remember to CC/ping me for C++ patches.


Thanks,
Jason


Applied the following after build and test on x86_64-unknown-linux.

Ed

Index: gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.C
===
--- gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.C   (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.C   (revision 0)
@@ -0,0 +1,13 @@
+// { dg-options -std=c++11 }
+// { dg-require-effective-target stdint_types }
+// PR c++/55582
+
+#include udlit-string-literal.h
+
+using namespace my_string_literals;
+
+decltype(Hello, World!s) s;
+decltype(u8Hello, World!s) s8;
+decltype(LHello, World!s) ws;
+decltype(uHello, World!s) s16;
+decltype(UHello, World!s) s32;
Index: gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h
===
--- gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h   (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h   (revision 0)
@@ -0,0 +1,22 @@
+#pragma GCC system_header
+
+#include string
+
+inline namespace my_string_literals
+{
+  std::string
+  operator s(const char* str, std::size_t len)
+  { return std::string{str, len}; }
+
+  std::wstring
+  operator s(const wchar_t* str, std::size_t len)
+  { return std::wstring{str, len}; }
+
+  std::u16string
+  operator s(const char16_t* str, std::size_t len)
+  { return std::u16string{str, len}; }
+
+  std::u32string
+  operator s(const char32_t* str, std::size_t len)
+  { return std::u32string{str, len}; }
+}
Index: libcpp/lex.c
===
--- libcpp/lex.c(revision 196036)
+++ libcpp/lex.c(working copy)
@@ -1561,8 +1561,10 @@
 from inttypes.h, we generate a warning and treat the ud-suffix as a
 separate preprocessing token.  This approach is under discussion by
 the standards committee, and has been adopted as a conforming
-extension by other front ends such as clang. */
-  if (ISALPHA (*cur))
+extension by other front ends such as clang.
+ A special exception is made for the suffix 's' which will be
+standardized as a user-defined literal suffix for strings.  */
+  if (ISALPHA (*cur)  *cur != 's')
{
  /* Raise a warning, but do not consume subsequent tokens.  */
  if (CPP_OPTION (pfile, warn_literal_suffix))
@@ -1572,7 +1574,7 @@
   a space between literal and identifier);
}
   /* Grab user defined literal suffix.  */
-  else if (*cur == '_')
+  else if (ISIDST (*cur))
{
  type = cpp_userdef_string_add_type (type);
  ++cur;
@@ -1692,8 +1694,10 @@
 from inttypes.h, we generate a warning and treat the ud-suffix as a
 separate preprocessing token.  This approach is under discussion by
 the standards committee, and has been adopted as a conforming
-extension by other front ends such as clang. */
-  if (ISALPHA (*cur))
+extension by other front ends such as clang.
+ A special exception is made for the suffix 's' which will be
+standardized as a user-defined literal suffix for strings.  */
+  if (ISALPHA (*cur)  *cur != 's')
{
  /* Raise a warning, but do not consume subsequent tokens.  */
  if (CPP_OPTION (pfile, warn_literal_suffix))
@@ -1703,7 +1707,7 @@
   a space between literal and identifier);
}
   /* Grab user defined literal suffix.  */
-  else if (*cur == '_')
+  else if (ISIDST (*cur))
{
  type = cpp_userdef_char_add_type (type);
  type = cpp_userdef_string_add_type (type);
gcc/libcpp/

2013-02-13  Ed Smith-Rowland  3dw...@verizon.net

PR c++/55582
* libcpp/lex.c (lex_raw_string): Allow string literal with suffix
beginning with 's' to be parsed as a C++11 user-defined literal.


gcc/testsuite/

2013-02-13  Ed Smith-Rowland  3dw...@verizon.net

PR c++/55582
* g++.dg/cpp0x/udlit-string-literal.h: New.
* g++.dg/cpp0x/udlit-string-literal.C: New.



Re: [PATCH, PR] Crash of Bessel functions at x==0!

2013-02-08 Thread Ed Smith-Rowland

On 02/08/2013 08:18 AM, Paolo Carlini wrote:

On 02/08/2013 05:09 AM, Ed Smith-Rowland wrote:

Here is a reworked patch...  The asyptotic stuff is removed for now.
Builds and tests cleanon x86_64-unknown-linux.

Please add a:

bool test __attribute__((unused)) = true;

at the beginning of test01. Also , only for consistency, a:

return 0;

in the main.

Ok with these changes.

Thanks!
Paolo.



Committed this...
PR libstdc++/56216

2013-02-08  Edward Smith-Rowland  3dw...@verizon.net

PR libstdc++/56216
* include/tr1/special_function_util.h: Remove spurious const
from numeric arguments.
* include/tr1/riemann_zeta.tcc: Ditto.
* include/tr1/exp_integral.tcc: Ditto.
* include/tr1/bessel_function.tcc: Ditto.
* include/tr1/hypergeometric.tcc: Ditto.
* include/tr1/modified_bessel_func.tcc: Ditto.
* include/tr1/poly_laguerre.tcc: Ditto.
* include/tr1/gamma.tcc: Ditto.
* include/tr1/legendre_function.tcc: Ditto.
* include/tr1/poly_hermite.tcc: Ditto.
* include/tr1/ell_integral.tcc: Ditto.
* include/tr1/bessel_function.tcc (__cyl_bessel_ij_series):
If argument is zero return function value.
* 
testsuite/tr1/5_numerical_facilities/special_functions/08_cyl_bessel_i/pr56216.cc:
New file.
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.



Re: [PATCH, PR56193] - Wrong test operator for basic_ios in C++11

2013-02-07 Thread Ed Smith-Rowland

On 02/07/2013 04:18 AM, Jonathan Wakely wrote:

On 7 February 2013 03:05, Ed Smith-Rowland wrote:

greetings,

On SO someone noticed that g++ still has in the basic_ios class
   operator void*();
instead of
   explicit operator bool() const;
The old C++98 operator allows things like
   std::cout  std::cout;

This patch changes the stream test operator for C++11 and onwards.

This patch builds and tests clean on x86_64-unknown-linux.

Please use -std=gnu++11 in the test's dg-options and CC the
gcc-patches list too.
OK for trunk with that change, thanks.


Attached patch applied.

2013-02-06  Edward Smith-Rowland  3dw...@verizon.net

* include/bits/basic_ios.h: Replace operator void*() const
with explicit operator bool() const in C++11 and greater.
* testsuite/27_io/basic_ios/pr56193.cc: New file.

Index: include/bits/basic_ios.h
===
--- include/bits/basic_ios.h(revision 195747)
+++ include/bits/basic_ios.h(working copy)
@@ -112,8 +112,13 @@
*  This allows you to write constructs such as
*  codeif (!a_stream) .../code and codewhile (a_stream) .../code
   */
+#if __cplusplus = 201103L
+  explicit operator bool() const
+  { return !this-fail(); }
+#else
   operator void*() const
   { return this-fail() ? 0 : const_castbasic_ios*(this); }
+#endif
 
   bool
   operator!() const
Index: testsuite/27_io/basic_ios/pr56193.cc
===
--- testsuite/27_io/basic_ios/pr56193.cc(revision 0)
+++ testsuite/27_io/basic_ios/pr56193.cc(revision 0)
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options -std=gnu++11 }
+// Copyright (C) 2013 Free Software Foundation, Inc.
+
+#include iostream
+
+// PR libstdc++/56193
+
+int
+test01()
+{
+  std::cout  std::cout; // { dg-error cannot bind }
+}
+
+// { dg-error initializing argument  { target *-*-* } 602 }


[PATCH][C++11][ PR55582] Let string literals starting with lower-case 's' be a user-defined literal instead of string + macro.

2012-12-05 Thread Ed Smith-Rowland
There is a proposal to add several user-defined literals to the standard 
library that looks like it will probably go through:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3468.pdf

The proposed string literals
std::string hw = Hello, world!s;
will not parse as a literal in gcc.

This patch fixes this by modifying the lexing of stringXYZ 
user-defined literals as *two* tokens if the suffix starts with a letter 
*unless the letter is a lower-case 's'*.  i.e. don't parse as a 
user-defined literal but as a sequence of string and macro *unless 
starts with lower case 's'*.


The original code parsed all string literals with suffix beginning with 
any letter as a sequence of string and macro (two tokens, not one).


Thanks,

Index: libcpp/lex.c
===
--- libcpp/lex.c(revision 194178)
+++ libcpp/lex.c(working copy)
@@ -1562,8 +1562,10 @@
 from inttypes.h, we generate a warning and treat the ud-suffix as a
 separate preprocessing token.  This approach is under discussion by
 the standards committee, and has been adopted as a conforming
-extension by other front ends such as clang. */
-  if (ISALPHA (*cur))
+extension by other front ends such as clang.
+ A special exception is made for the suffix 's' which will be
+standardized as a user-defined literal suffix for strings.  */
+  if (ISALPHA (*cur)  *cur != 's')
{
  /* Raise a warning, but do not consume subsequent tokens.  */
  if (CPP_OPTION (pfile, warn_literal_suffix))
@@ -1573,7 +1575,7 @@
   a space between literal and identifier);
}
   /* Grab user defined literal suffix.  */
-  else if (*cur == '_')
+  else if (ISIDST (*cur))
{
  type = cpp_userdef_string_add_type (type);
  ++cur;
@@ -1693,8 +1695,10 @@
 from inttypes.h, we generate a warning and treat the ud-suffix as a
 separate preprocessing token.  This approach is under discussion by
 the standards committee, and has been adopted as a conforming
-extension by other front ends such as clang. */
-  if (ISALPHA (*cur))
+extension by other front ends such as clang.
+ A special exception is made for the suffix 's' which will be
+standardized as a user-defined literal suffix for strings.  */
+  if (ISALPHA (*cur)  *cur != 's')
{
  /* Raise a warning, but do not consume subsequent tokens.  */
  if (CPP_OPTION (pfile, warn_literal_suffix))
@@ -1704,7 +1708,7 @@
   a space between literal and identifier);
}
   /* Grab user defined literal suffix.  */
-  else if (*cur == '_')
+  else if (ISIDST (*cur))
{
  type = cpp_userdef_char_add_type (type);
  type = cpp_userdef_string_add_type (type);
Index: gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.C
===
--- gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.C   (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.C   (revision 0)
@@ -0,0 +1,12 @@
+// { dg-options -std=c++11 }
+// PR c++/55582
+
+#include udlit-string-literal.h
+
+using namespace my_string_literals;
+
+decltype(Hello, World!s) s;
+decltype(u8Hello, World!s) s8;
+decltype(LHello, World!s) ws;
+decltype(uHello, World!s) s16;
+decltype(UHello, World!s) s32;
Index: gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h
===
--- gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h   (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h   (revision 0)
@@ -0,0 +1,22 @@
+#pragma GCC system_header
+
+#include string
+
+inline namespace my_string_literals
+{
+  std::string
+  operator s(const char* str, std::size_t len)
+  { return std::string{str, len}; }
+
+  std::wstring
+  operator s(const wchar_t* str, std::size_t len)
+  { return std::wstring{str, len}; }
+
+  std::u16string
+  operator s(const char16_t* str, std::size_t len)
+  { return std::u16string{str, len}; }
+
+  std::u32string
+  operator s(const char32_t* str, std::size_t len)
+  { return std::u32string{str, len}; }
+}
gcc/libcpp/

2012-12-05  Ed Smith-Rowland  3dw...@verizon.net

PR c++/55582
* lex.c (lex_raw_string): Allow string literal with suffix starting with
lower-case 's' as a user-defined literal.
(lex_string): Ditto.


gcc/testsuite/

2012-12-05  Ed Smith-Rowland  3dw...@verizon.net

PR c++/55582
* g++.dg/cpp0x/udlit-string-literal.h: New.
* g++.dg/cpp0x/udlit-string-literal.C: New.


[PATCH, PR52654, C++11] Warn on overflow in user-defined literals

2012-11-27 Thread Ed Smith-Rowland
/g++.dg/cpp0x/udlit-overflow-neg.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/udlit-overflow-neg.C (revision 0)
@@ -0,0 +1,18 @@
+// { dg-options -std=c++0x -Woverflow }
+// PR c++/52654
+
+int
+operator _w(unsigned long long)
+{ return 0; }
+
+int
+operator _w(long double)
+{ return 0.0L; }
+
+int i = 12345678901234567890123456789012345678901234567890_w;
+int j = 12345678901234567890123456789.012345678901234567890e+1234567890_w;
+int k = 12345678901234567890123456789.012345678901234567890e-1234567890_w;
+
+// { dg-warning integer literal exceeds range of   { target *-*-* } 12 }
+// { dg-warning floating literal exceeds range of   { target *-*-* } 13 }
+// { dg-warning floating literal truncated to zero  { target *-*-* } 14 }
Index: gcc/cp/parser.c
===
--- gcc/cp/parser.c (revision 193844)
+++ gcc/cp/parser.c (working copy)
@@ -3529,7 +3529,8 @@
 
   if (have_suffix_p)
{
- tree literal = build_userdef_literal (suffix_id, value, NULL_TREE);
+ tree literal = build_userdef_literal (suffix_id, value,
+   OT_NONE, NULL_TREE);
  tok-u.value = literal;
  return cp_parser_userdef_string_literal (tok);
}
@@ -3661,6 +3662,7 @@
   tree literal = token-u.value;
   tree suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
   tree value = USERDEF_LITERAL_VALUE (literal);
+  int overflow = USERDEF_LITERAL_OVERFLOW (literal);
   tree num_string = USERDEF_LITERAL_NUM_STRING (literal);
   tree name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
   tree decl, result;
@@ -3676,6 +3678,20 @@
   result = finish_call_expr (decl, args, false, true, tf_none);
   if (result != error_mark_node)
{
+ if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE  overflow  0)
+   warning_at (token-location, OPT_Woverflow,
+   integer literal exceeds range of %qT type,
+   long_long_unsigned_type_node);
+ else
+   {
+ if (overflow  0)
+   warning_at (token-location, OPT_Woverflow,
+   floating literal exceeds range of %qT type,
+   long_double_type_node);
+ else if (overflow  0)
+   warning_at (token-location, OPT_Woverflow,
+   floating literal truncated to zero);
+   }
  release_tree_vector (args);
  return result;
}
2012-11-19  Ed Smith-Rowland  3dw...@verizon.net

PR c++/52654
* gcc/c-family/c-common.h (overflow_type): New enum.
(build_userdef_literal): Add overflow_type argument.
(tree_userdef_literal): Add overflow_type.
(USERDEF_LITERAL_OVERFLOW): New access macro.
* gcc/c-family/c-common.c (build_userdef_literal): Add overflow_type
argument.
* gcc/c-family/c-lex.c (c_lex_with_flags): Add overflow_type to
build_userdef_literal calls.
(interpret_integer, interpret_float): Add overflow_type argument.
* gcc/cp/parser.c (cp_parser_string_literal): Add overflow_type arg.
(cp_parser_userdef_numeric_literal): Warn on numeric overflow.
* gcc/testsuite/g++.dg/cpp0x/udlit-overflow.C: New.
* gcc/testsuite/g++.dg/cpp0x/udlit-overflow-neg.C: New.


Re: [Obj-C++] Found a small paste-o in parser.c?

2012-11-11 Thread Ed Smith-Rowland

On 11/12/2012 12:05 AM, Jason Merrill wrote:

OK.

Jason


Committed.

2012-11-12  Ed Smith-Rowland  3dw...@verizon.net

* parser.c (cp_parser_objc_class_ivars):
Index declspecs.locations by ds_typedef rather than ds_thread.

Index: parser.c
===
--- parser.c(revision 193380)
+++ parser.c(working copy)
@@ -24650,7 +24650,7 @@
   if (decl_spec_seq_has_spec_p (declspecs, ds_typedef))
{
  cp_parser_error (parser, invalid type for instance variable);
- declspecs.locations[ds_thread] = 0;
+ declspecs.locations[ds_typedef] = 0;
}
 
   prefix_attributes = declspecs.attributes;


[Obj-C++] Found a small paste-o in parser.c?

2012-11-10 Thread Ed Smith-Rowland
I found this suspicious looking line in cp/parser.c () while looking at 
__thread and thread_local.


Look at the patterns of the if blocks above the line in question to verify.

Built and tested on x86_64-linux.

Ed

2012-11-11  Ed Smith-Rowland  3dw...@verizon.net

* parser.c (cp_parser_objc_class_ivars):
Index declspecs.locations by ds_typedef rather than ds_thread.

Index: parser.c
===
--- parser.c(revision 193380)
+++ parser.c(working copy)
@@ -24650,7 +24650,7 @@
   if (decl_spec_seq_has_spec_p (declspecs, ds_typedef))
{
  cp_parser_error (parser, invalid type for instance variable);
- declspecs.locations[ds_thread] = 0;
+ declspecs.locations[ds_typedef] = 0;
}
 
   prefix_attributes = declspecs.attributes;


Re: libstdc++ PATCH to use __cplusplus rather than __GXX_EXPERIMENTAL_CXX0X__

2012-11-09 Thread Ed Smith-Rowland

On 11/09/2012 05:09 PM, Jason Merrill wrote:
Now that G++ uses the value of __cplusplus specified by the standard, 
we don't need the other macro anymore.


OK for trunk, or should I save it for the next stage 1?

Jason
This looks like a non-user-facing mechanical change that makes sense.  
FWIW I'm OK with it.


Paolo?

Ed



Re: [C++11] PR54413 Option for turning off compiler extensions for numeric literals.

2012-11-08 Thread Ed Smith-Rowland

On 11/07/2012 10:29 AM, Jakub Jelinek wrote:

On Wed, Nov 07, 2012 at 10:22:57AM -0500, Jason Merrill wrote:

I thought about that.  We'd need some machinery that would allow cpp to query 
what has been declared already.

Or alternately, always treat them as user-defined in C++ mode and
have the front end decide to use the built-in interpretation if no
literal operator is declared.

Yeah, I think that would be best.

Jakub


OK, this passes x86_64-linux.  This is my first rodeo with *.texi.

I just have one flag: -fext-numeric-literals.
It leaves gnu extension suffixes for std=gnu++*, and std=c++98.
I sets the flag off (use suffixes for user-defined literals) for std=c++11+.

Ed

libcpp

2012-11-09  Ed Smith-Rowland  3dw...@verizon.net

PR c++/54413
* include/cpplib.h (cpp_interpret_float_suffix): Add cpp_reader* arg.
(cpp_interpret_int_suffix): Add cpp_reader* arg.
* init.c (cpp_create_reader): Iitialize new flags.
* expr.c (interpret_float_suffix): Use new flags.
(cpp_interpret_float_suffix): Add cpp_reader* arg.
(interpret_int_suffix): Use new flags.
(cpp_interpret_int_suffix): Add cpp_reader* arg.
(cpp_classify_number): Adjust calls to interpret_x_suffix.


gcc/c-family

2012-11-09  Ed Smith-Rowland  3dw...@verizon.net

PR c++/54413
* c-opts.c (c_common_handle_option): Set new flags.
* c.opt: Describe new flags.


gcc/cp

2012-11-09  Ed Smith-Rowland  3dw...@verizon.net

PR c++/54413
* decl.c (grokfndecl): Adjust calls to interpret_x_suffix.


gcc/testsuite

2012-11-09  Ed Smith-Rowland  3dw...@verizon.net

PR c++/54413
* g++.dg/cpp0x/gnu_fext-numeric-literals.C: New.
* g++.dg/cpp0x/std_fext-numeric-literals.C: New.
* g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C: New.
* g++.dg/cpp0x/std_fno-ext-numeric-literals.C: New.


gcc

2012-11-09  Ed Smith-Rowland  3dw...@verizon.net

PR c++/54413
* doc/invoke.texi: Document f[no-]ext-numeric-literals flag.

Index: libcpp/include/cpplib.h
===
--- libcpp/include/cpplib.h (revision 193296)
+++ libcpp/include/cpplib.h (working copy)
@@ -431,6 +431,10 @@
  ud-suffix which does not beging with an underscore.  */
   unsigned char warn_literal_suffix;
 
+  /* Nonzero means interpret imaginary, fixed-point, or other gnu extension
+ literal number suffixes as user-defined literal number suffixes.  */
+  unsigned char ext_numeric_literals;
+
   /* Holds the name of the target (execution) character set.  */
   const char *narrow_charset;
 
@@ -854,10 +858,12 @@
 const char **, source_location);
 
 /* Return the classification flags for a float suffix.  */
-extern unsigned int cpp_interpret_float_suffix (const char *, size_t);
+extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *,
+   size_t);
 
 /* Return the classification flags for an int suffix.  */
-extern unsigned int cpp_interpret_int_suffix (const char *, size_t);
+extern unsigned int cpp_interpret_int_suffix (cpp_reader *, const char *,
+ size_t);
 
 /* Evaluate a token classified as category CPP_N_INTEGER.  */
 extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,
Index: libcpp/init.c
===
--- libcpp/init.c   (revision 193296)
+++ libcpp/init.c   (working copy)
@@ -182,6 +182,7 @@
   CPP_OPTION (pfile, track_macro_expansion) = 2;
   CPP_OPTION (pfile, warn_normalize) = normalized_C;
   CPP_OPTION (pfile, warn_literal_suffix) = 1;
+  CPP_OPTION (pfile, ext_numeric_literals) = 1;
 
   /* Default CPP arithmetic to something sensible for the host for the
  benefit of dumb users like fix-header.  */
Index: libcpp/expr.c
===
--- libcpp/expr.c   (revision 193296)
+++ libcpp/expr.c   (working copy)
@@ -61,8 +61,8 @@
 static cpp_num parse_defined (cpp_reader *);
 static cpp_num eval_token (cpp_reader *, const cpp_token *, source_location);
 static struct op *reduce (cpp_reader *, struct op *, enum cpp_ttype);
-static unsigned int interpret_float_suffix (const uchar *, size_t);
-static unsigned int interpret_int_suffix (const uchar *, size_t);
+static unsigned int interpret_float_suffix (cpp_reader *, const uchar *, 
size_t);
+static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
 static void check_promotion (cpp_reader *, const struct op *);
 
 /* Token type abuse to create unary plus and minus operators.  */
@@ -87,7 +87,7 @@
length LEN, possibly zero.  Returns 0 for an invalid suffix, or a
flag vector describing the suffix.  */
 static unsigned int
-interpret_float_suffix (const uchar *s, size_t len)
+interpret_float_suffix

[C++11] PR54413 Option for turning off compiler extensions for numeric literals.

2012-11-04 Thread Ed Smith-Rowland
There is a request to be able to turn off interpretation of several 
suffixes for gcc extension numeric literals to make way for C++-1Y or 
various std libraries to claim several suffixes currently used for gnu 
extensions.


This patch interprets the suffixes according to the current extension 
rules by default.  But if -std=c++1y is used as the C++ standard then 
the flags are off by default allowing use as C+11 user-defined literals.


I would like to get this into 4.8 if I can.

It passes on x86_64 linux.

Regards,
Ed

libcpp

2012-11-05  Ed Smith-Rowland  3dw...@verizon.net

PR c++/54413
* include/cpplib.h (cpp_interpret_float_suffix): Add cpp_reader* arg.
(cpp_interpret_int_suffix): Add cpp_reader* arg.
* init.c (cpp_create_reader): Iitialize new flags.
* expr.c (interpret_float_suffix): Use new flags.
(cpp_interpret_float_suffix): Add cpp_reader* arg.
(interpret_int_suffix): Use new flags.
(cpp_interpret_int_suffix): Add cpp_reader* arg.
(cpp_classify_number): Adjust calls to interpret_x_suffix.


gcc/c-family

2012-11-05  Ed Smith-Rowland  3dw...@verizon.net

PR c++/54413
* c-opts.c (c_common_handle_option): Set new flags.
* c.opt: Describe new flags.


gcc/cp

2012-11-05  Ed Smith-Rowland  3dw...@verizon.net

PR c++/54413
* decl.c (grokfndecl): Adjust calls to interpret_x_suffix.


gcc/testsuite

2012-11-05  Ed Smith-Rowland  3dw...@verizon.net

PR c++/54413
* g++.dg/cpp0x/fno-fixed-point-literals.C: New.
* g++.dg/cpp0x/fno-imaginary-literals.C: New.
* g++.dg/cpp0x/fno-machine-defined-literals.C: New.
* g++.dg/cpp0x/ffixed-point-literals.C: New.
* g++.dg/cpp0x/fimaginary-literals.C: New.
* g++.dg/cpp0x/fmachine-defined-literals.C: New.

Index: libcpp/include/cpplib.h
===
--- libcpp/include/cpplib.h (revision 192897)
+++ libcpp/include/cpplib.h (working copy)
@@ -431,6 +431,18 @@
  ud-suffix which does not beging with an underscore.  */
   unsigned char warn_literal_suffix;
 
+  /* Nonzero means interpret imaginary number suffix as an imaginary number
+ literal.  */
+  unsigned char imaginary_literals;
+
+  /* Nonzero means interpret fixed-point number suffix as a fixed-point number
+ literal.  */
+  unsigned char fixed_point_literals;
+
+  /* Nonzero means interpret fixed-point number suffix as amachine-defined
+ number literal.  */
+  unsigned char machine_defined_literals;
+
   /* Holds the name of the target (execution) character set.  */
   const char *narrow_charset;
 
@@ -854,10 +866,12 @@
 const char **, source_location);
 
 /* Return the classification flags for a float suffix.  */
-extern unsigned int cpp_interpret_float_suffix (const char *, size_t);
+extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *,
+   size_t);
 
 /* Return the classification flags for an int suffix.  */
-extern unsigned int cpp_interpret_int_suffix (const char *, size_t);
+extern unsigned int cpp_interpret_int_suffix (cpp_reader *, const char *,
+ size_t);
 
 /* Evaluate a token classified as category CPP_N_INTEGER.  */
 extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,
Index: libcpp/init.c
===
--- libcpp/init.c   (revision 192897)
+++ libcpp/init.c   (working copy)
@@ -182,6 +182,9 @@
   CPP_OPTION (pfile, track_macro_expansion) = 2;
   CPP_OPTION (pfile, warn_normalize) = normalized_C;
   CPP_OPTION (pfile, warn_literal_suffix) = 1;
+  CPP_OPTION (pfile, imaginary_literals) = 1;
+  CPP_OPTION (pfile, fixed_point_literals) = 1;
+  CPP_OPTION (pfile, machine_defined_literals) = 1;
 
   /* Default CPP arithmetic to something sensible for the host for the
  benefit of dumb users like fix-header.  */
Index: libcpp/expr.c
===
--- libcpp/expr.c   (revision 192897)
+++ libcpp/expr.c   (working copy)
@@ -61,8 +61,8 @@
 static cpp_num parse_defined (cpp_reader *);
 static cpp_num eval_token (cpp_reader *, const cpp_token *, source_location);
 static struct op *reduce (cpp_reader *, struct op *, enum cpp_ttype);
-static unsigned int interpret_float_suffix (const uchar *, size_t);
-static unsigned int interpret_int_suffix (const uchar *, size_t);
+static unsigned int interpret_float_suffix (cpp_reader *, const uchar *, 
size_t);
+static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
 static void check_promotion (cpp_reader *, const struct op *);
 
 /* Token type abuse to create unary plus and minus operators.  */
@@ -87,7 +87,7 @@
length LEN, possibly zero.  Returns 0 for an invalid suffix, or a
flag vector describing the suffix

<    1   2   3   4   >