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

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


Ed



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

2014-06-24 Thread Ed Smith-Rowland

I am still having problems doing a full build.

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


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

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



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

Ed



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

2014-06-24 Thread Ed Smith-Rowland

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

In i386.h

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

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



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

2014-06-24 Thread Ed Smith-Rowland
 
 

On 06/24/14, Andrew Sutton wrote:

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

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

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

Andrew Sutton


Andrew,

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

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

Ed


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

2014-06-26 Thread Ed Smith-Rowland

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

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

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

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

Thoughts?

Andrew


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

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


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


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


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


I'm CCing Jason.



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

2014-06-26 Thread Ed Smith-Rowland


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


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


Ed



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

2014-06-27 Thread Ed Smith-Rowland

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

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

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


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



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


Aren't trigraphs off by default already?

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

Jason






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

2014-06-28 Thread Ed Smith-Rowland

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

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

--- Comment #5 from Paolo Carlini 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

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 

[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


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



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

2014-07-11 Thread Ed Smith-Rowland

On 07/10/2014 06:16 AM, Paolo Carlini wrote:

.. I have another comment: are we sure the usual strategy:

  templatetypename _UniformRandomNumberGenerator
result_type
operator()(_UniformRandomNumberGenerator __urng)
{ return this-operator()(__urng, this-_M_param); }

doesn't make sense here too?

Paolo.


 Look OK to me too, but I would move both operator() out of line

 and definitely operator()(_UniformRandomNumberGenerator, const 
param_type) of von_mises_distribution.

Ouch - that on was huge huge!

So moved.  The logistic operator() bodies were small looking to me but 
they aren't one or two lines either.  And DRY.


Rebuilt and retested on x86_64-linux.
OK?


2014-07-11  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 212442)
+++ include/ext/random  (working copy)
@@ -2728,42 +2728,8 @@
   templatetypename _UniformRandomNumberGenerator
result_type
operator()(_UniformRandomNumberGenerator __urng,
-  const param_type __p)
-   {
- const result_type __pi
-   = __gnu_cxx::__math_constantsresult_type::__pi;
- std::__detail::_Adaptor_UniformRandomNumberGenerator, result_type
-   __aurng(__urng);
+  const param_type __p);
 
- result_type __f;
- while (1)
-   {
- result_type __rnd = std::cos(__pi * __aurng());
- __f = (result_type(1) + __p._M_r * __rnd) / (__p._M_r + __rnd);
- result_type __c = __p._M_kappa * (__p._M_r - __f);
-
- result_type __rnd2 = __aurng();
- if (__c * (result_type(2) - __c)  __rnd2)
-   break;
- if (std::log(__c / __rnd2) = __c - result_type(1))
-   break;
-   }
-
- result_type __res = std::acos(__f);
-#if _GLIBCXX_USE_C99_MATH_TR1
- __res = std::copysign(__res, __aurng() - result_type(0.5));
-#else
- if (__aurng()  result_type(0.5))
-   __res = -__res;
-#endif
- __res += __p._M_mu;
- if (__res  __pi)
-   __res -= result_type(2) * __pi;
- else if (__res  -__pi)
-   __res += result_type(2) * __pi;
- return __res;
-   }
-
   templatetypename _ForwardIterator,
   typename _UniformRandomNumberGenerator
void
@@ -3106,6 +3072,227 @@
   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;
+  };
+
+  

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

2014-07-11 Thread Ed Smith-Rowland

On 07/11/2014 11:42 AM, Paolo Carlini wrote:

Hi,

On 07/11/2014 05:38 PM, Ed Smith-Rowland wrote:

OK?
Ok, thanks, but please adjust the dates you have on the testcases to 
the date of the actual commit (I suppose today or tomorrow)


Thanks again!
Paolo.



As committed.
Thanks all for looking at this.
Ed

Index: include/ext/random
===
--- include/ext/random  (revision 212475)
+++ include/ext/random  (working copy)
@@ -2728,42 +2728,8 @@
   templatetypename _UniformRandomNumberGenerator
result_type
operator()(_UniformRandomNumberGenerator __urng,
-  const param_type __p)
-   {
- const result_type __pi
-   = __gnu_cxx::__math_constantsresult_type::__pi;
- std::__detail::_Adaptor_UniformRandomNumberGenerator, result_type
-   __aurng(__urng);
+  const param_type __p);
 
- result_type __f;
- while (1)
-   {
- result_type __rnd = std::cos(__pi * __aurng());
- __f = (result_type(1) + __p._M_r * __rnd) / (__p._M_r + __rnd);
- result_type __c = __p._M_kappa * (__p._M_r - __f);
-
- result_type __rnd2 = __aurng();
- if (__c * (result_type(2) - __c)  __rnd2)
-   break;
- if (std::log(__c / __rnd2) = __c - result_type(1))
-   break;
-   }
-
- result_type __res = std::acos(__f);
-#if _GLIBCXX_USE_C99_MATH_TR1
- __res = std::copysign(__res, __aurng() - result_type(0.5));
-#else
- if (__aurng()  result_type(0.5))
-   __res = -__res;
-#endif
- __res += __p._M_mu;
- if (__res  __pi)
-   __res -= result_type(2) * __pi;
- else if (__res  -__pi)
-   __res += result_type(2) * __pi;
- return __res;
-   }
-
   templatetypename _ForwardIterator,
   typename _UniformRandomNumberGenerator
void
@@ -3106,6 +3072,227 @@
   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

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

2014-07-12 Thread Ed Smith-Rowland

PING!

Support operator (...) per CWG 1473.
This brings full string parsing to literal operator declarations including 
string chunk concatenation and appropriate errors.

Bootstrapped and tested on x86_64-linux.

OK?

I'm less sure if this is appropriate for 4.9 even when it opens.

cp/

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

PR C++/60209 - Declaration of user-defined literal operator cause error
* cp/parser.c (cp_parser_operator()): Fold treatment of strings
and user-defined string literals.  Use the full string parser.
(cp_parser_string_literal()): Add flag to not look for literal operator.


testsuite/

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

PR C++/60209 - Declaration of user-defined literal operator cause error
* g++.dg/cpp0x/pr60209-neg.C: New.
* g++.dg/cpp0x/pr60209.C: New.
* g++.dg/cpp1y/udlit-empty-string-neg.C: Adjust messages.

Index: cp/parser.c
===
--- cp/parser.c (revision 212479)
+++ 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
@@ -12636,7 +12640,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);
@@ -12836,83 +12840,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)
  {
+  

[PATCH] PR preprocessor/23827 - standard C++ should not have hex float preprocessing tokens

2014-07-12 Thread Ed Smith-Rowland

Greetings,

This old bug involved C++98 accepting hex floats without complaint.
I also split the error messages between C and C++ like in the recent PR 
61389 patch.


Bootstrapped and tested clean on x86_64-linux.

OK?


libcpp/

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

PR preprocessor/23827
* init.c (lang_defaults[]): Set extended_identifiers to false for C++98.
* expr.c (cpp_classify_number()): Make hexfloat pedward trigger
for !extended_identifiers.  Split error message for C99 and C++11.


gcc/testsuite/

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

PR preprocessor/23827
* g++.dg/cpp/pr23827.C: New.

Index: libcpp/init.c
===
--- libcpp/init.c   (revision 212479)
+++ libcpp/init.c   (working copy)
@@ -102,7 +102,7 @@
   /* STDC99   */  { 1,  0,  1,   0,  0,  1,   1,   1,   0,   0,   0,0, 
 0 },
   /* STDC11   */  { 1,  0,  1,   0,  1,  1,   1,   1,   1,   0,   0,0, 
 0 },
   /* GNUCXX   */  { 0,  1,  1,   0,  0,  0,   1,   1,   0,   0,   0,0, 
 0 },
-  /* CXX98*/  { 0,  1,  1,   0,  0,  1,   1,   1,   0,   0,   0,0, 
 0 },
+  /* CXX98*/  { 0,  1,  0,   0,  0,  1,   1,   1,   0,   0,   0,0, 
 0 },
   /* GNUCXX11 */  { 1,  1,  1,   0,  1,  0,   1,   1,   1,   1,   1,0, 
 0 },
   /* CXX11*/  { 1,  1,  1,   0,  1,  1,   1,   1,   1,   1,   1,0, 
 0 },
   /* GNUCXX1Y */  { 1,  1,  1,   0,  1,  0,   1,   1,   1,   1,   1,1, 
 1 },
Index: libcpp/expr.c
===
--- libcpp/expr.c   (revision 212479)
+++ libcpp/expr.c   (working copy)
@@ -540,9 +540,16 @@
SYNTAX_ERROR_AT (virtual_location,
 no digits in hexadecimal floating constant);
 
-  if (radix == 16  CPP_PEDANTIC (pfile)  !CPP_OPTION (pfile, c99))
-   cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
-use of C99 hexadecimal floating constant);
+  if (radix == 16  CPP_PEDANTIC (pfile)
+  !CPP_OPTION (pfile, extended_numbers))
+   {
+ if (CPP_OPTION (pfile, cplusplus))
+   cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
+use of C++11 hexadecimal floating constant);
+ else
+   cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
+use of C99 hexadecimal floating constant);
+   }
 
   if (float_flag == AFTER_EXPON)
{
Index: gcc/testsuite/g++.dg/cpp/pr23827.C
===
--- gcc/testsuite/g++.dg/cpp/pr23827.C  (revision 0)
+++ gcc/testsuite/g++.dg/cpp/pr23827.C  (working copy)
@@ -0,0 +1,22 @@
+// { dg-do run }
+// { dg-options -std=c++98 -pedantic-errors }
+
+#define f (
+#define l )
+#define str(x) #x
+#define xstr(x) str(x)
+
+/* C90 and C++: 0x1p+( 0x1p+); C99: 0x1p+f 0x1p+l */
+const char *s = xstr(0x1p+f 0x1p+l);
+
+extern C void abort();
+extern C int strcmp(const char *, const char *);
+
+int
+main()
+{
+  if (strcmp (s, 0x1p+( 0x1p+)))
+abort();
+  else
+return 0;
+}


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

2014-07-13 Thread Ed Smith-Rowland

 are these dummy implementations intended?



Yes.  There is no state.  The only parameter is the dimensionality
which is a template parameter.


We do often serialize underlying helper distributions, in your case the 
normal distribution _M_n.
While the normal distribution mean and stddev are trivial for your case 
(not actually needing serialization)

the normal distribution has these _M_saved, etc. shat we should store.

So I would just serialize _M_n here.

This is a great distribution.
Thanks!

Are you looking at the normal distribution equivalent of these?



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

2014-07-13 Thread Ed Smith-Rowland

On 07/13/2014 10:11 AM, Ulrich Drepper wrote:

On Sun, Jul 13, 2014 at 9:55 AM, Ed Smith-Rowland 3dw...@verizon.net wrote:

So I would just serialize _M_n here.

It has fixed parameters. This would mean unnecessary work.  When you
try to use the parameter of the sphere distribution the normal
distribution will be reset.  So there really is no need here.

The only problem would be if code couldn't handle the operators not
writing/reading anything  But I haven't seen anything like that.


OK.  I see it. Thanks.



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

2014-07-16 Thread Ed Smith-Rowland

On 07/14/2014 04:14 AM, Paolo Carlini wrote:

Hi,

On 07/14/2014 09:58 AM, Andreas Schwab wrote:
FAIL: ext/random/arcsine_distribution/cons/default.cc (test for 
excess errors)

Excess errors:
/daten/aranym/gcc/gcc-20140714/libstdc++-v3/include/ext/random.tcc:1587:22: 
error: '_M_n' was not declared in this scope
/daten/aranym/gcc/gcc-20140714/libstdc++-v3/include/ext/random.tcc:1598:22: 
error: '_M_n' was not declared in this scope
Ulrich please fix those _M_n to __x._M_n and remove the obsolete 
comments. We could also add the usual minimal set of tests exercising 
serialization. Thanks.


Paolo.



All,

One thing we all forgot: the operator== is also non-trivial because it 
needs to compare _M_n.


Operators must be guaranteed to produce the same numbers in future when 
fed with identical urngs if they compare equal.


Ulrich, do you want to do this?  There are also old comments in the 
inserters and extractors.


Ed



Re: Patch for constexpr variable templates

2014-07-21 Thread Ed Smith-Rowland

Braden,

I've played with this and it seems to work nicely.
Only one comment:  Could you put the test cases in the C++14 subdirectory?

g++.dg/template/cpp1y/var-templ1.C

^
We should CC Jason on all this.

Also, do you have your FSF paperwork in place?

Thanks,

Ed



Re: Implement N4051 - Allow typename in a template template parameter

2014-07-22 Thread Ed Smith-Rowland

On 07/22/2014 01:56 AM, Ville Voutilainen wrote:

+/* Parse a type-parameter-key.
+
+   type-parameter-key:
+ class
+ typedef
+
+   Returns the kind of type-parameter-key specified, or none_type to indicate
+   error.  */
+

Typo above, should be typename, not typedef.


Thanks!

New patch..

OK?

cp/

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

Implement N4051 - Allow typename in a template template parameter
* parser.c (enum required_token): Add RT_TYPE_PARAMETER_KEY;
(cp_parser_type_parameter_key): New funtion;
(cp_parser_token_is_type_parameter_key): Ditto;
(cp_parser_type_parameter): Look for type-parameter-key for cxx1z or
or greater; (cp_parser_required_error): Error for RT_TYPE_PARAMETER_KEY.


testsuite/

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

Implement N4051 - Allow typename in a template template parameter
* g++.dg/cpp1z/typename-tmpl-tmpl-parm.C: New.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 178114d..dd5ddac 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -177,6 +177,7 @@ typedef enum required_token {
   RT_INTERATION, /* iteration-statement */
   RT_JUMP, /* jump-statement */
   RT_CLASS_KEY, /* class-key */
+  RT_TYPE_PARAMETER_KEY, /* type-parameter-key */
   RT_CLASS_TYPENAME_TEMPLATE, /* class, typename, or template */
   RT_TRANSACTION_ATOMIC, /* __transaction_atomic */
   RT_TRANSACTION_RELAXED, /* __transaction_relaxed */
@@ -2151,6 +2152,8 @@ static tree cp_parser_class_head
   (cp_parser *, bool *);
 static enum tag_types cp_parser_class_key
   (cp_parser *);
+static enum tag_types cp_parser_type_parameter_key
+  (cp_parser* parser);
 static void cp_parser_member_specification_opt
   (cp_parser *);
 static void cp_parser_member_declaration
@@ -2409,6 +2412,8 @@ static bool 
cp_parser_nth_token_starts_template_argument_list_p
   (cp_parser *, size_t);
 static enum tag_types cp_parser_token_is_class_key
   (cp_token *);
+static enum tag_types cp_parser_token_is_type_parameter_key
+  (cp_token *);
 static void cp_parser_check_class_key
   (enum tag_types, tree type);
 static void cp_parser_check_access_in_redeclaration
@@ -13375,8 +13380,18 @@ cp_parser_type_parameter (cp_parser* parser, bool 
*is_parameter_pack)
cp_parser_template_parameter_list (parser);
/* Look for the `'.  */
cp_parser_require (parser, CPP_GREATER, RT_GREATER);
-   /* Look for the `class' keyword.  */
-   cp_parser_require_keyword (parser, RID_CLASS, RT_CLASS);
+   if (cxx_dialect  cxx1z)
+ {
+   /* Look for the `class' keyword.  */
+   cp_parser_require_keyword (parser, RID_CLASS, RT_CLASS);
+ }
+   else
+ {
+   /* Look for the `class' or 'typename' keywords.  */
+   enum tag_types tag_type = cp_parser_type_parameter_key (parser);
+   if (tag_type == none_type)
+ return error_mark_node;
+ }
 /* If the next token is an ellipsis, we have a template
argument pack. */
 if (cp_lexer_next_token_is (parser-lexer, CPP_ELLIPSIS))
@@ -20258,6 +20273,33 @@ cp_parser_class_key (cp_parser* parser)
   return tag_type;
 }
 
+/* Parse a type-parameter-key.
+
+   type-parameter-key:
+ class
+ typename
+
+   Returns the kind of type-parameter-key specified, or none_type to indicate
+   error.  */
+
+static enum tag_types
+cp_parser_type_parameter_key (cp_parser* parser)
+{
+  cp_token *token;
+  enum tag_types tag_type;
+
+  /* Look for the type-parameter-key.  */
+  token = cp_parser_require (parser, CPP_KEYWORD, RT_TYPE_PARAMETER_KEY);
+  if (!token)
+return none_type;
+
+  /* Check to see if the TOKEN is a type-parameter-key.  */
+  tag_type = cp_parser_token_is_type_parameter_key (token);
+  if (!tag_type)
+cp_parser_error (parser, expected type-parameter-key);
+  return tag_type;
+}
+
 /* Parse an (optional) member-specification.
 
member-specification:
@@ -24543,6 +24585,9 @@ cp_parser_required_error (cp_parser *parser,
  case RT_CLASS_KEY:
cp_parser_error (parser, expected class-key);
return;
+ case RT_TYPE_PARAMETER_KEY:
+   cp_parser_error (parser, expected %class% or %typename%);
+   return;
  case RT_CLASS_TYPENAME_TEMPLATE:
cp_parser_error (parser,
 expected %class%, %typename%, or %template%);
@@ -24776,6 +24821,24 @@ cp_parser_token_is_class_key (cp_token* token)
 }
 }
 
+/* Returns the kind of tag indicated by TOKEN, if it is a type-parameter-key,
+   or none_type otherwise.  */
+
+static enum tag_types
+cp_parser_token_is_type_parameter_key (cp_token* token)
+{
+  switch (token-keyword)
+{
+case RID_CLASS:
+  return class_type;
+case RID_TYPENAME:
+  return typename_type;
+
+default:
+  return none_type;
+}
+}
+
 /* Issue an error message if the CLASS_KEY does not match the TYPE.  */
 
 static void
diff --git 

Re: Patch for constexpr variable templates

2014-07-23 Thread Ed Smith-Rowland

Braden,

Great work on this.  In addition to helping with constraints there is at 
least one new library feature that depends on constexpr variable templates.


For my two cents it would be good to get just the constexpr variable 
templates, aka n3651, in now as a first stage - it's quite usable.


But someday we'll want non-constexpr too. I have only seen a sentence 
somewhere stating that non-constexpr variable templates are allowed but 
have seen no paper or wording anywhere.  Does anyone know where such exists?


Ed



Re: Implement N4051 - Allow typename in a template template parameter

2014-07-23 Thread Ed Smith-Rowland

On 07/23/2014 06:05 AM, Jason Merrill wrote:

On 07/22/2014 01:53 PM, Ed Smith-Rowland wrote:

+if (cxx_dialect  cxx1z)
+  {
+/* Look for the `class' keyword.  */
+cp_parser_require_keyword (parser, RID_CLASS, RT_CLASS);
+  }
+else
+  {
+/* Look for the `class' or 'typename' keywords.  */
+enum tag_types tag_type = cp_parser_type_parameter_key 
(parser);

+if (tag_type == none_type)
+  return error_mark_node;
+  }


Let's encapsulate this in cp_parser_type_parameter_key.  And also 
accept 'typename' in lower dialects with a pedwarn.


Jason



OK,

Here is the latest.  I did the rearranging.
g++ now accepts templatetemplatetypename typename X from g++98 on 
with pedwarn.
I also upped the test support lib to support c++1z better (this for 
testing pedwarn for version  cxx1z).


Bootstraps and tests clean on x86_64-linux.

OK?

cp/

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

Implement N4051 - Allow typename in a template template parameter
* parser.c (enum required_token): Add RT_TYPE_PARAMETER_KEY;
(cp_parser_type_parameter_key): New funtion;
(cp_parser_token_is_type_parameter_key): Ditto;
(cp_parser_type_parameter): Look for type-parameter-key for cxx1z or
or greater; (cp_parser_required_error): Error for RT_TYPE_PARAMETER_KEY.


testsuite/

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

Implement N4051 - Allow typename in a template template parameter
* lib/target-supports.exp (check_effective_target_c++1y): Now
means C++1y and up.
(check_effective_target_c++1y_down): New.
(check_effective_target_c++1z_only): New.
(check_effective_target_c++1z): New.
* g++.dg/cpp1z/typename-tmpl-tmpl-parm.C: New.
* g++.dg/cpp1z/typename-tmpl-tmpl-parm-neg.C: New.
* g++.dg/cpp1z/typename-tmpl-tmpl-parm-.C: New.
Index: cp/parser.c
===
--- cp/parser.c (revision 212967)
+++ cp/parser.c (working copy)
@@ -177,6 +177,7 @@
   RT_INTERATION, /* iteration-statement */
   RT_JUMP, /* jump-statement */
   RT_CLASS_KEY, /* class-key */
+  RT_TYPE_PARAMETER_KEY, /* type-parameter-key */
   RT_CLASS_TYPENAME_TEMPLATE, /* class, typename, or template */
   RT_TRANSACTION_ATOMIC, /* __transaction_atomic */
   RT_TRANSACTION_RELAXED, /* __transaction_relaxed */
@@ -2151,6 +2152,8 @@
   (cp_parser *, bool *);
 static enum tag_types cp_parser_class_key
   (cp_parser *);
+static void cp_parser_type_parameter_key
+  (cp_parser* parser);
 static void cp_parser_member_specification_opt
   (cp_parser *);
 static void cp_parser_member_declaration
@@ -2409,6 +2412,8 @@
   (cp_parser *, size_t);
 static enum tag_types cp_parser_token_is_class_key
   (cp_token *);
+static enum tag_types cp_parser_token_is_type_parameter_key
+  (cp_token *);
 static void cp_parser_check_class_key
   (enum tag_types, tree type);
 static void cp_parser_check_access_in_redeclaration
@@ -13375,8 +13380,8 @@
cp_parser_template_parameter_list (parser);
/* Look for the `'.  */
cp_parser_require (parser, CPP_GREATER, RT_GREATER);
-   /* Look for the `class' keyword.  */
-   cp_parser_require_keyword (parser, RID_CLASS, RT_CLASS);
+   /* Look for the `class' or 'typename' keywords.  */
+   cp_parser_type_parameter_key (parser);
 /* If the next token is an ellipsis, we have a template
argument pack. */
 if (cp_lexer_next_token_is (parser-lexer, CPP_ELLIPSIS))
@@ -20258,6 +20263,35 @@
   return tag_type;
 }
 
+/* Parse a type-parameter-key.
+
+   type-parameter-key:
+ class
+ typename
+
+ */
+
+static void
+cp_parser_type_parameter_key (cp_parser* parser)
+{
+  /* Look for the type-parameter-key.  */
+  cp_token* token = cp_parser_require (parser, CPP_KEYWORD, 
RT_TYPE_PARAMETER_KEY);
+  if (!token)
+return;
+
+  /* Check to see if the TOKEN is a type-parameter-key.  */
+  enum tag_types tag_type = cp_parser_token_is_type_parameter_key (token);
+  if (tag_type == none_type)
+cp_parser_error (parser, expected type-parameter-key);
+  else if (pedantic  tag_type == typename_type  cxx_dialect  cxx1z)
+/* typename is not allowed in a template template parameter
+   by the standard until C++1Z.  */
+pedwarn (token-location, OPT_Wpedantic, 
+ISO C++ forbids typename key in template template parameter);
+
+  return;
+}
+
 /* Parse an (optional) member-specification.
 
member-specification:
@@ -24543,6 +24577,9 @@
  case RT_CLASS_KEY:
cp_parser_error (parser, expected class-key);
return;
+ case RT_TYPE_PARAMETER_KEY:
+   cp_parser_error (parser, expected %class% or %typename%);
+   return;
  case RT_CLASS_TYPENAME_TEMPLATE:
cp_parser_error (parser,
 expected %class%, %typename%, or %template%);
@@ -24776,6 +24813,24

Re: Implement N4051 - Allow typename in a template template parameter

2014-07-24 Thread Ed Smith-Rowland

On 07/24/2014 11:32 AM, Jason Merrill wrote:

On 07/23/2014 10:31 PM, Ed Smith-Rowland wrote:

+pedwarn (token-location, OPT_Wpedantic,
+ ISO C++ forbids typename key in template template 
parameter);


This should mention -std=c++1z.


+  if (tag_type == none_type)
+cp_parser_error (parser, expected type-parameter-key);

...

+  case RT_TYPE_PARAMETER_KEY:
+cp_parser_error (parser, expected %class% or %typename%);


It seems unfortunate to have this diagnostic in two places.  I think 
let's not use cp_parser_require here.


Jason



OK, here is another round..
Error handling collapsed.  Got rid of RT_TYPE_PARAMETER_KEY and uses 
altogether.


Built and tested clean on x86_64-linux.  OK?

Ed

cp/

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

Implement N4051 - Allow typename in a template template parameter
* parser.c (cp_parser_type_parameter_key): New funtion;
(cp_parser_token_is_type_parameter_key): Ditto;
(cp_parser_type_parameter): Look for type-parameter-key for all versions
but pedwarn for less than cxx1z.


testsuite/

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

Implement N4051 - Allow typename in a template template parameter
* lib/target-supports.exp (check_effective_target_c++1y): Now
means C++1y and up.
(check_effective_target_c++1y_down): New.
(check_effective_target_c++1z_only): New.
(check_effective_target_c++1z): New.
* g++.dg/cpp1z/typename-tmpl-tmpl-parm.C: New.
* g++.dg/cpp1z/typename-tmpl-tmpl-parm-neg.C: New.
* g++.dg/cpp1z/typename-tmpl-tmpl-parm-.C: New.
Index: cp/parser.c
===
--- cp/parser.c (revision 212967)
+++ cp/parser.c (working copy)
@@ -2151,6 +2151,8 @@
   (cp_parser *, bool *);
 static enum tag_types cp_parser_class_key
   (cp_parser *);
+static void cp_parser_type_parameter_key
+  (cp_parser* parser);
 static void cp_parser_member_specification_opt
   (cp_parser *);
 static void cp_parser_member_declaration
@@ -2409,6 +2411,8 @@
   (cp_parser *, size_t);
 static enum tag_types cp_parser_token_is_class_key
   (cp_token *);
+static enum tag_types cp_parser_token_is_type_parameter_key
+  (cp_token *);
 static void cp_parser_check_class_key
   (enum tag_types, tree type);
 static void cp_parser_check_access_in_redeclaration
@@ -13375,8 +13379,8 @@
cp_parser_template_parameter_list (parser);
/* Look for the `'.  */
cp_parser_require (parser, CPP_GREATER, RT_GREATER);
-   /* Look for the `class' keyword.  */
-   cp_parser_require_keyword (parser, RID_CLASS, RT_CLASS);
+   /* Look for the `class' or 'typename' keywords.  */
+   cp_parser_type_parameter_key (parser);
 /* If the next token is an ellipsis, we have a template
argument pack. */
 if (cp_lexer_next_token_is (parser-lexer, CPP_ELLIPSIS))
@@ -20258,6 +20262,35 @@
   return tag_type;
 }
 
+/* Parse a type-parameter-key.
+
+   type-parameter-key:
+ class
+ typename
+ */
+
+static void
+cp_parser_type_parameter_key (cp_parser* parser)
+{
+  /* Look for the type-parameter-key.  */
+  enum tag_types tag_type = none_type;
+  cp_token *token = cp_lexer_peek_token (parser-lexer);
+  if ((tag_type = cp_parser_token_is_type_parameter_key (token)) != none_type)
+{
+  cp_lexer_consume_token (parser-lexer);
+  if (pedantic  tag_type == typename_type  cxx_dialect  cxx1z)
+   /* typename is not allowed in a template template parameter
+  by the standard until C++1Z.  */
+   pedwarn (token-location, OPT_Wpedantic, 
+ISO C++ forbids typename key in template template parameter;
+ use -std=c++1z or -std=gnu++1z);
+}
+  else
+cp_parser_error (parser, expected %class% or %typename%);
+
+  return;
+}
+
 /* Parse an (optional) member-specification.
 
member-specification:
@@ -24776,6 +24809,27 @@
 }
 }
 
+/* Returns the kind of tag indicated by TOKEN, if it is a type-parameter-key,
+   or none_type otherwise or if the token is null.  */
+
+static enum tag_types
+cp_parser_token_is_type_parameter_key (cp_token* token)
+{
+  if (!token)
+return none_type;
+
+  switch (token-keyword)
+{
+case RID_CLASS:
+  return class_type;
+case RID_TYPENAME:
+  return typename_type;
+
+default:
+  return none_type;
+}
+}
+
 /* Issue an error message if the CLASS_KEY does not match the TYPE.  */
 
 static void
Index: testsuite/lib/target-supports.exp
===
--- testsuite/lib/target-supports.exp   (revision 212967)
+++ testsuite/lib/target-supports.exp   (working copy)
@@ -5707,8 +5707,17 @@
 return [check-flags { { } { } { -std=c++1y -std=gnu++1y -std=c++14 
-std=gnu++14 } }]
 }
 proc check_effective_target_c++1y { } {
-return [check_effective_target_c++1y_only

Re: Make the string_view literal operators constexpr like the ctors they call.

2014-07-24 Thread Ed Smith-Rowland

On 03/08/2014 01:33 PM, Jonathan Wakely wrote:

On 8 March 2014 16:29, Ed Smith-Rowland wrote:

On 03/08/2014 11:27 AM, Ed Smith-Rowland wrote:

The title says it all.  This was just an oversight in the original patch.

This could wait until stage 1 obviously.  I just wanted to post it.

There are a lot of post-Issaquah constexpr changes but these will have to
wait for front-end support for C++14 constexpr.

Builds and tests clean on x86_64-linux.

OK?

OK for stage 1, but not now.  (And please remember to CC gcc-patches)


I had completely forgotten about this until now.

Rebased, retested, committed.

Ed

2014-07-25  Ed Smith-Rowland  3dw...@verizon.net

* include/experimental/string_view: Make the literal operators
constexpr like the ctors they call.

Index: include/experimental/string_view
===
--- include/experimental/string_view(revision 212967)
+++ include/experimental/string_view(working copy)
@@ -664,22 +664,22 @@
   inline namespace string_view_literals
   {
 
-inline basic_string_viewchar
+inline constexpr basic_string_viewchar
 operatorsv(const char* __str, size_t __len)
 { return basic_string_viewchar{__str, __len}; }
 
 #ifdef _GLIBCXX_USE_WCHAR_T
-inline basic_string_viewwchar_t
+inline constexpr basic_string_viewwchar_t
 operatorsv(const wchar_t* __str, size_t __len)
 { return basic_string_viewwchar_t{__str, __len}; }
 #endif
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
-inline basic_string_viewchar16_t
+inline constexpr basic_string_viewchar16_t
 operatorsv(const char16_t* __str, size_t __len)
 { return basic_string_viewchar16_t{__str, __len}; }
 
-inline basic_string_viewchar32_t
+inline constexpr basic_string_viewchar32_t
 operatorsv(const char32_t* __str, size_t __len)
 { return basic_string_viewchar32_t{__str, __len}; }
 #endif


Re: Patch for constexpr variable templates

2014-07-25 Thread Ed Smith-Rowland

How difficult would it be to make partial specializations work:

// Write n*pi once for every possible type
templatetypename Tp, std::size_t N
  constexpr Tp npi = N * Tp(3.1415926535897932385L);

// Partial specialization for int type.
templatestd::size_t N
  constexpr double npiint, N = N * double(3.1415926535897932385L);



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

2014-07-26 Thread Ed Smith-Rowland

On 07/16/2014 12:18 PM, Mike Stump wrote:

On Jul 16, 2014, at 7:51 AM, Ed Smith-Rowland 3dw...@verizon.net wrote:

Deprecate c++1y. Chane language to reflect greater confidence in C++14

Chane - Change.  I looked at your patch, all seems fine.  I like the 
documentation edits you did, nice job.


Here is another round - basically the same except testcases tweaked.

built and tested on x86_64-linux.

OK?


libcpp/

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


gcc/

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

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


gcc/testsuite/

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

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

Re: Patch for constexpr variable templates

2014-07-26 Thread Ed Smith-Rowland

On 07/26/2014 03:04 AM, Braden Obrzut wrote:
Ed, I looked into partial specializations and it looks like, while not 
trivial, it would be easy enough for me to do them.  However, it is 
not required for concepts (which can not be specialized), so should I 
fix them for this patch or as a separate patch later?
I see no reason why we can't add features in stages.  I just wondered if 
you had already given it a look.  Certainly constexpr variable templates 
are useful on their own.

On 07/25/2014 05:24 PM, Jason Merrill wrote:


Fair enough, but in that case let's use 'sorry' rather then 'error' 
to be clear that it's a missing feature.


Tests like g++.dg/cpp1y/pr59638.C produce extra failures if this is 
changed.  Is there something I'm supposed to do to account for that?


- Braden Obrzut





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

2014-07-26 Thread Ed Smith-Rowland

On 07/16/2014 12:18 PM, Mike Stump wrote:

On Jul 16, 2014, at 7:51 AM, Ed Smith-Rowland 3dw...@verizon.net wrote:

Deprecate c++1y. Chane language to reflect greater confidence in C++14

Chane - Change.  I looked at your patch, all seems fine.  I like the 
documentation edits you did, nice job.

In the last patch I has missed a few testcases.  These are repaired and 
added to the patch.  Sorry for the noise.


built and tested on x86_64-linux.

OK?

libcpp/

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


gcc/

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

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


gcc/testsuite/

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

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

[PATCH ] PR libstdc++/60037 - SIGFPE in std::generate_canonicalunsigned int...

2014-07-29 Thread Ed Smith-Rowland
As discussed in the audit trail both _Adaptor and generate_canonical are 
both meant to use floating point values.  Both are here given 
static_asserts to that effect.

This would have prevented this error and might help future users.

The main issue is the use of value_type in _Adaptor and thus in 
generate_canonical in hypergeometric_distribution::operator().  This 
distribution is a discreet distribution and thus value_type is an 
unsigned integer which caused overflow in generate_canonical.  In 
keeping with practice in all other discreet distributions a double type 
will now be used in _Adaptor.


Someday, it might be beneficial to discuss an _IntegralAdaptor and a 
corresponding __generate_canonical for use in our discreet distributions 
but I want to close this bug with this patch.


Built and tested on x86_64-linux.

OK?


2014-07-29  Ed Smith-Rowland  3dw...@verizon.net

* include/bits/random.h (_Adaptor): static_assert for non floating-point
result type.
* include/bits/random.tcc (generate_canonical): Ditto.
* include/ext/random.tcc (hypergeometric_distribution::operator()):
Use double as a rng result type.
* testsuite/26_numerics/random/pr60037-neg.cc: New.
* testsuite/ext/random/hypergeometric_distribution/pr60037.cc: New.

Index: include/bits/random.h
===
--- include/bits/random.h   (revision 213145)
+++ include/bits/random.h   (working copy)
@@ -164,6 +164,8 @@
 templatetypename _Engine, typename _DInputType
   struct _Adaptor
   {
+   static_assert(std::is_floating_point_DInputType::value,
+ template argument not a floating point type);
 
   public:
_Adaptor(_Engine __g)
Index: include/bits/random.tcc
===
--- include/bits/random.tcc (revision 213145)
+++ include/bits/random.tcc (working copy)
@@ -3463,6 +3463,9 @@
 _RealType
 generate_canonical(_UniformRandomNumberGenerator __urng)
 {
+  static_assert(std::is_floating_point_RealType::value,
+   template argument not a floating point type);
+
   const size_t __b
= std::min(static_castsize_t(std::numeric_limits_RealType::digits),
__bits);
Index: include/ext/random.tcc
===
--- include/ext/random.tcc  (revision 213145)
+++ include/ext/random.tcc  (working copy)
@@ -1355,7 +1355,7 @@
   operator()(_UniformRandomNumberGenerator __urng,
 const param_type __param)
   {
-   std::__detail::_Adaptor_UniformRandomNumberGenerator, result_type
+   std::__detail::_Adaptor_UniformRandomNumberGenerator, double
  __aurng(__urng);
 
result_type __a = __param.successful_size();
Index: testsuite/26_numerics/random/pr60037-neg.cc
===
--- testsuite/26_numerics/random/pr60037-neg.cc (revision 0)
+++ testsuite/26_numerics/random/pr60037-neg.cc (working copy)
@@ -0,0 +1,9 @@
+
+#include random
+
+std::mt19937 urng;
+
+std::__detail::_Adaptorstd::mt19937, unsigned long aurng(urng); // { 
dg-error template argument not a floating point type }
+
+auto x = std::generate_canonicalstd::size_t,
+   std::numeric_limitsstd::size_t::digits(urng); // { 
dg-error template argument not a floating point type }
Index: testsuite/ext/random/hypergeometric_distribution/pr60037.cc
===
--- testsuite/ext/random/hypergeometric_distribution/pr60037.cc (revision 0)
+++ testsuite/ext/random/hypergeometric_distribution/pr60037.cc (working copy)
@@ -0,0 +1,24 @@
+// { dg-options -std=gnu++11 }
+// { dg-require-cstdint  }
+// { dg-require-cmath  }
+// { dg-options -O0 }
+
+#include ext/random
+#include functional
+
+void
+hyperplot(unsigned int N, unsigned int K, unsigned int n)
+{
+  std::mt19937 re; // the default engine
+  __gnu_cxx::hypergeometric_distribution hd(N, K, n);
+  auto gen = std::bind(hd, re);
+  gen();
+}
+
+int
+main()
+{
+  hyperplot(15, 3, 2);
+  hyperplot(500, 50, 30);
+  hyperplot(100, 20, 5);
+}


Re: [PATCH ] PR libstdc++/60037 - SIGFPE in std::generate_canonicalunsigned int...

2014-07-29 Thread Ed Smith-Rowland

On 07/29/2014 04:29 AM, Jonathan Wakely wrote:

On 29/07/14 04:11 -0400, Ed Smith-Rowland wrote:
As discussed in the audit trail both _Adaptor and generate_canonical 
are both meant to use floating point values.  Both are here given 
static_asserts to that effect.

This would have prevented this error and might help future users.

The main issue is the use of value_type in _Adaptor and thus in 
generate_canonical in hypergeometric_distribution::operator(). This 
distribution is a discreet distribution and thus value_type is an 
unsigned integer which caused overflow in generate_canonical.  In 
keeping with practice in all other discreet distributions a double 
type will now be used in _Adaptor.


Someday, it might be beneficial to discuss an _IntegralAdaptor and a 
corresponding __generate_canonical for use in our discreet 
distributions but I want to close this bug with this patch.


Makes sense, thanks for the fix.


Built and tested on x86_64-linux.

OK?


One question ...


Index: testsuite/ext/random/hypergeometric_distribution/pr60037.cc
===
--- testsuite/ext/random/hypergeometric_distribution/pr60037.cc 
(revision 0)
+++ testsuite/ext/random/hypergeometric_distribution/pr60037.cc 
(working copy)

@@ -0,0 +1,24 @@
+// { dg-options -std=gnu++11 }
+// { dg-require-cstdint  }
+// { dg-require-cmath  }
+// { dg-options -O0 }


Did you mean to have two separate dg-options directives here?

OK to commit, after either combining them into one or removing the
second one.


Committed (with small changes to test cases).
Attached new CLand patch.

2014-07-29  Ed Smith-Rowland  3dw...@verizon.net

PR libstdc++/60037 - SIGFPE in std::generate_canonicalunsigned int...
* include/bits/random.h (_Adaptor): static_assert for non floating-point
result type.
* include/bits/random.tcc (generate_canonical): Ditto.
* include/ext/random.tcc (hypergeometric_distribution::operator()):
Use double as a rng result type.
* testsuite/26_numerics/random/pr60037-neg.cc: New.
* testsuite/ext/random/hypergeometric_distribution/pr60037.cc: New.

Index: include/bits/random.h
===
--- include/bits/random.h   (revision 213145)
+++ include/bits/random.h   (working copy)
@@ -164,6 +164,8 @@
 templatetypename _Engine, typename _DInputType
   struct _Adaptor
   {
+   static_assert(std::is_floating_point_DInputType::value,
+ template argument not a floating point type);
 
   public:
_Adaptor(_Engine __g)
Index: include/bits/random.tcc
===
--- include/bits/random.tcc (revision 213145)
+++ include/bits/random.tcc (working copy)
@@ -3463,6 +3463,9 @@
 _RealType
 generate_canonical(_UniformRandomNumberGenerator __urng)
 {
+  static_assert(std::is_floating_point_RealType::value,
+   template argument not a floating point type);
+
   const size_t __b
= std::min(static_castsize_t(std::numeric_limits_RealType::digits),
__bits);
Index: include/ext/random.tcc
===
--- include/ext/random.tcc  (revision 213145)
+++ include/ext/random.tcc  (working copy)
@@ -1355,7 +1355,7 @@
   operator()(_UniformRandomNumberGenerator __urng,
 const param_type __param)
   {
-   std::__detail::_Adaptor_UniformRandomNumberGenerator, result_type
+   std::__detail::_Adaptor_UniformRandomNumberGenerator, double
  __aurng(__urng);
 
result_type __a = __param.successful_size();
Index: testsuite/26_numerics/random/pr60037-neg.cc
===
--- testsuite/26_numerics/random/pr60037-neg.cc (revision 0)
+++ testsuite/26_numerics/random/pr60037-neg.cc (working copy)
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options -std=gnu++11 }
+
+#include random
+
+std::mt19937 urng;
+
+std::__detail::_Adaptorstd::mt19937, unsigned long aurng(urng);
+
+auto x = std::generate_canonicalstd::size_t,
+   std::numeric_limitsstd::size_t::digits(urng);
+
+// { dg-error static assertion failed: template argument not a floating point 
type  { target *-*-* } 167 }
+
+// { dg-error static assertion failed: template argument not a floating point 
type  { target *-*-* } 3466 }
Index: testsuite/ext/random/hypergeometric_distribution/pr60037.cc
===
--- testsuite/ext/random/hypergeometric_distribution/pr60037.cc (revision 0)
+++ testsuite/ext/random/hypergeometric_distribution/pr60037.cc (working copy)
@@ -0,0 +1,23 @@
+// { dg-options -std=gnu++11 -O0 }
+// { dg-require-cstdint  }
+// { dg-require-cmath  }
+
+#include ext/random
+#include functional
+
+void
+hyperplot

Re: Add the latest C++ SD-6 additions.

2014-11-10 Thread Ed Smith-Rowland

On 11/10/2014 12:10 PM, Jason Merrill wrote:

On 11/10/2014 10:55 AM, Ed Smith-Rowland wrote:

Would a 4.9 version be accepted?


Sure.

What do you think about defining the macros for unsupported features 
to 0 rather than leaving them undefined?  The document doesn't seem to 
specify.


Jason



Jason,

1. Undefined macros evaluate to 0 so that's effectively what we have now 
- no change in behavior if we explicitly set them
2. The SD-6 document advertises direct use of macros with #if 
__cpp_foobar without #ifdef - However if people are using #ifdef rather 
than #if that might break things (I guess that's different behavior); 
OTOH those dates are there for a reason.
3. OTOH, the SD-6 document seems to suggest only adding a macro as a 
feature is implemented or allowed bycompiler flags - implying undefined 
macros for unimplemented features
4. __has_include and __has_cpp_attribute return 0 on 
non-existent/undefined so there's some precedent (though these are 
rather different structurally - function macros)


So I'm conflicted after being initially sympathetic to defining as 
zero.  Still slightly in favor.


I'll might put this to the SD-6 list because it would be nice to have 
clarity - even if it's implementation defined.


Ed



[PATCH PC preprocessor/63831] - [5 Regression] r217292 causes segfaults with -MM

2014-11-13 Thread Ed Smith-Rowland

There were segfaults on preprocess-only involving __has_attribute.
-MM and -E both bombed with __has_attribute.

Several codebases use __has_attribute this (because of clang).

This problem would have been found with the SD-6 macro 
__has_cpp_attribute as well so just taking out the extra macro is not 
the answer.


The answer is to provide the preprocessor pretty printer with a callback 
for has_attribute to match that of the lexer.


I don't know how pretty the output is but the thing doesn't crash and 
we can fix the output if needs be later on.


This patch builds and tests clean on x86_64-linux.

OK?

Ed


libcpp:

2014-11-13  Edward Smith-Rowland  3dw...@verizon.net

* expr.c (parse_has_attribute): Only call pfile-cb.has_attribute
if it is non-null.


gcc/c-family:

2014-11-13  Edward Smith-Rowland  3dw...@verizon.net

* c-lex.c (cb_has_attribute): Remove old comment.
* c-cppbuiltin.c (cb_has_attribute): New callback;
(init_pp_output): Set it.


gcc/testsuite:

2014-11-13  Edward Smith-Rowland  3dw...@verizon.net

* g++.dg/cpp1y/pr63831.C: New.
* g++.dg/cpp1y/pr63831.h: New.
Index: libcpp/expr.c
===
--- libcpp/expr.c   (revision 217482)
+++ libcpp/expr.c   (working copy)
@@ -2162,7 +2162,10 @@
   result.high = 0;
   result.overflow = false;
 
-  result.low = pfile-cb.has_attribute (pfile);
+  if (pfile-cb.has_attribute)
+result.low = pfile-cb.has_attribute (pfile);
+  else
+result.low = 0;
 
   pfile-state.in__has_attribute__--;
 
Index: gcc/c-family/c-lex.c
===
--- gcc/c-family/c-lex.c(revision 217482)
+++ gcc/c-family/c-lex.c(working copy)
@@ -306,7 +306,6 @@
 
   if (token-type == CPP_NAME)
 {
-  //node = token-val.node.node;
   const cpp_token *nxt_token = cpp_peek_token (pfile, 0);
   if (c_dialect_cxx()  nxt_token-type == CPP_SCOPE)
{
Index: gcc/c-family/c-ppoutput.c
===
--- gcc/c-family/c-ppoutput.c   (revision 217482)
+++ gcc/c-family/c-ppoutput.c   (working copy)
@@ -80,6 +80,7 @@
 static void cb_def_pragma (cpp_reader *, source_location);
 static void cb_read_pch (cpp_reader *pfile, const char *name,
 int fd, const char *orig_name);
+static int cb_has_attribute (cpp_reader *);
 
 /* Preprocess and output.  */
 void
@@ -129,6 +130,8 @@
}
 }
 
+  cb-has_attribute = cb_has_attribute;
+
   if (flag_dump_includes)
 cb-include  = cb_include;
 
@@ -510,6 +513,48 @@
 print.src_line++;
 }
 
+static int
+cb_has_attribute (cpp_reader * pfile)
+{
+  bool paren = false;
+  const cpp_token * token = cpp_get_token (pfile);
+
+  fputs (__has_attribute__ , print.outf);
+
+  if (token-type == CPP_OPEN_PAREN)
+{
+  paren = true;
+  token = cpp_get_token (pfile);
+  putc ('(', print.outf);
+}
+  if (token-type == CPP_NAME)
+{
+  const cpp_token *nxt_token = cpp_peek_token (pfile, 0);
+  if (c_dialect_cxx()  nxt_token-type == CPP_SCOPE)
+   {
+ nxt_token = cpp_get_token (pfile); // Eat scope.
+ nxt_token = cpp_get_token (pfile);
+ if (nxt_token-type == CPP_NAME)
+   {
+ fprintf (print.outf, %s::%s,
+  cpp_token_as_text (pfile, token),
+  cpp_token_as_text (pfile, nxt_token));
+   }
+   }
+  else
+   {
+ fprintf (print.outf, %s, cpp_token_as_text (pfile, token));
+   }
+}
+  if (paren)
+{
+  cpp_get_token (pfile);
+  putc (')', print.outf);
+}
+
+  return 0;
+}
+
 static void
 cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
  cpp_hashnode *node)
Index: gcc/testsuite/g++.dg/cpp1y/pr63831.C
===
--- gcc/testsuite/g++.dg/cpp1y/pr63831.C(revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/pr63831.C(working copy)
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-options -I${srcdir}/g++.dg/cpp1y -MM }
+
+#include pr63831.h
Index: gcc/testsuite/g++.dg/cpp1y/pr63831.h
===
--- gcc/testsuite/g++.dg/cpp1y/pr63831.h(revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/pr63831.h(working copy)
@@ -0,0 +1,7 @@
+#ifndef __has_attribute
+#define __has_attribute(x) 0
+#endif
+
+#if  __has_attribute(alloc_size)
+#   define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
+#endif


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

2014-09-26 Thread Ed Smith-Rowland

On 09/25/2014 01:40 PM, Jason Merrill wrote:

On 09/01/2014 09:41 PM, Ed Smith-Rowland wrote:

+  cpp_define (pfile, __cpp_attribute_deprecated=201309);


Don't we support attribute deprecated in C++11?

Jason



We support [[gnu::deprecated]] in C++11 bit not [[deprecated]] until C++14.
Ed



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

2014-09-28 Thread Ed Smith-Rowland

On 09/25/2014 12:57 PM, Jason Merrill wrote:

On 09/01/2014 09:34 PM, Ed Smith-Rowland wrote:

(open_file_failed()): Not an error to not find a header file for
__has_include__.


Hmm, looks like this means that __has_include__ will silently return 
false if a header exists but is unreadable; I would think that we want 
it to be true (and have an error when the user tries to include it).


Jason

I have changed __has_include__ to return true if a header exists but is 
unreadable.  Then I tried to see if an error would occur for a header of 
permission 000.
Just including it gives a permission error.  Putting it into an #if 
block does not.

---
ed@bad-horse:~/tr2$ ls -l hidden.h
-- 1 ed ed 0 Sep 26 10:27 hidden.h
---
//  Try header that exists but we can't read.
#if __has_include(hidden.h)
#  warning found hidden.h
#  include hidden.h // No error!
#else
#  error hidden.h
#endif

#if 1
#  include hidden.h // No error!
#endif
---

Is this a bug in cpp?

I'm going to submit new patches that answer all your questions.  As far 
as this one goes I do no worse than current behavior.

As for [[deprecated]] for C++11 I'll add another patch on top of the four.

Ed



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

2014-09-29 Thread Ed Smith-Rowland

On 09/25/2014 12:57 PM, Jason Merrill wrote:

On 09/01/2014 09:34 PM, Ed Smith-Rowland wrote:

(open_file_failed()): Not an error to not find a header file for
__has_include__.


Hmm, looks like this means that __has_include__ will silently return 
false if a header exists but is unreadable; I would think that we want 
it to be true (and have an error when the user tries to include it).


Jason


Here is the new patch series.

A patch addressing C++11 [[deprecated]] is coming later when these are 
in as is a library patch for std::is_final.


I flipped the logic on the libcpp functions because there was a double 
negative of sorts - the logic was confusing to me on second look.
Also, a file that a user can't read for permissions still returns true 
with __has_include.


Built and tested on x86_64-linux.

OK?

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

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

Index: internal.h
===
--- internal.h  (revision 215628)
+++ 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 215628)
+++ directives.c(working copy)
@@ -566,6 +566,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;
 }
@@ -2623,3 +2628,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 215628)
+++ expr.c  (working copy)
@@ -64,6 +64,8 @@
 static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
 static void check_promotion (cpp_reader *, const struct op *);
 
+static cpp_num parse_has_include (cpp_reader *, enum include_type);
+
 /* Token type abuse to create unary plus and minus operators.  */
 #define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1))
 #define CPP_UMINUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 2))
@@ -1048,6 +1050,10 @@
 case CPP_NAME:
   if (token-val.node.node == pfile-spec_nodes.n_defined)
return parse_defined (pfile);
+  else if (token-val.node.node == pfile-spec_nodes.n__has_include__)
+   return

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

2014-10-01 Thread Ed Smith-Rowland
 
 

On 10/01/14, Jonathan Wakely wrote:

On 02/09/14 10:24 +0100, Jonathan Wakely wrote:
On 01/09/14 21:46 -0400, Ed Smith-Rowland wrote:
Index: include/bits/stl_function.h
===
--- include/bits/stl_function.h (revision 214680)
+++ include/bits/stl_function.h (working copy)
@@ -217,6 +217,10 @@
 };

#if __cplusplus  201103L
+
+#define __cpp_lib_transparent_operators 201210
+#define __cpp_lib_generic_associative_lookup 201304

The generic associative lookup feature is not supported.

Index: testsuite/experimental/feat-lib-fund.cc
===
--- testsuite/experimental/feat-lib-fund.cc (revision 0)
+++ testsuite/experimental/feat-lib-fund.cc (working copy)
@@ -0,0 +1,25 @@
+// { dg-options -std=gnu++14 }
+// { dg-do compile }
+
+#include experimental/optional
+#include experimental/string_view
+
+#if !__has_include(experimental/optional)
+# error experimental/optional
+#endif
+
+//#if !__has_include(experimental/net)
+//# error experimental/net
+//#endif
+
+//#if !__has_include(experimental/any)
+//# error experimental/any
+//#endif

This can be uncommented, experimental/any is available.

OK with those changes.

Ed, the commit at http://gcc.gnu.org/r215752 doesn't have the
corrections I asked for above and causes a number of test failures,
could you look into it please?

I swore I put these changes in.
I'll fix these ASAP.
Ed



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

2014-10-02 Thread Ed Smith-Rowland

On 10/01/2014 11:28 AM, Jonathan Wakely wrote:

On 02/09/14 10:24 +0100, Jonathan Wakely wrote:

On 01/09/14 21:46 -0400, Ed Smith-Rowland wrote:

Index: include/bits/stl_function.h
===
--- include/bits/stl_function.h(revision 214680)
+++ include/bits/stl_function.h(working copy)
@@ -217,6 +217,10 @@
   };

#if __cplusplus  201103L
+
+#define __cpp_lib_transparent_operators 201210
+#define __cpp_lib_generic_associative_lookup 201304


The generic associative lookup feature is not supported.


Index: testsuite/experimental/feat-lib-fund.cc
===
--- testsuite/experimental/feat-lib-fund.cc(revision 0)
+++ testsuite/experimental/feat-lib-fund.cc(working copy)
@@ -0,0 +1,25 @@
+// { dg-options -std=gnu++14 }
+// { dg-do compile }
+
+#include experimental/optional
+#include experimental/string_view
+
+#if !__has_include(experimental/optional)
+#  error experimental/optional
+#endif
+
+//#if !__has_include(experimental/net)
+//#  error experimental/net
+//#endif
+
+//#if !__has_include(experimental/any)
+//#  error experimental/any
+//#endif


This can be uncommented, experimental/any is available.

OK with those changes.


Ed, the commit at http://gcc.gnu.org/r215752 doesn't have the
corrections I asked for above and causes a number of test failures,
could you look into it please?



OK,

Here is the patch.

Built and tested on x86_64-linux.

OK?

Ed

FWIW, I remember a svn tree corruption while getting this patch ready.
I should have retested everything in the new tree.
Sorry everyone!

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

* include/bits/stl_function.h: generic associative lookup feature
is not supported.
* testsuite/experimental/feat-lib-fund.cc:experimental/any is
actually available.
* testsuite/experimental/feat-cxx14.cc: Add test for __cpp_lib_is_final.
* 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/stl_function.h
===
--- include/bits/stl_function.h (revision 215788)
+++ include/bits/stl_function.h (working copy)
@@ -219,7 +219,7 @@
 #if __cplusplus  201103L
 
 #define __cpp_lib_transparent_operators 201210
-#define __cpp_lib_generic_associative_lookup 201304
+//#define __cpp_lib_generic_associative_lookup 201304
 
   template
 struct plusvoid
Index: testsuite/experimental/feat-lib-fund.cc
===
--- testsuite/experimental/feat-lib-fund.cc (revision 215788)
+++ testsuite/experimental/feat-lib-fund.cc (working copy)
@@ -12,9 +12,9 @@
 //#  error experimental/net
 //#endif
 
-//#if !__has_include(experimental/any)
-//#  error experimental/any
-//#endif
+#if !__has_include(experimental/any)
+#  error experimental/any
+#endif
 
 //#if !__has_include(experimental/memory_resource)
 //#  error experimental/memory_resource
Index: testsuite/experimental/feat-cxx14.cc
===
--- testsuite/experimental/feat-cxx14.cc(revision 215788)
+++ testsuite/experimental/feat-cxx14.cc(working copy)
@@ -78,11 +78,11 @@
 #  error __cpp_lib_complex_udls != 201309
 #endif
 
-#ifndef  __cpp_lib_generic_associative_lookup
-#  error __cpp_lib_generic_associative_lookup
-#elif  __cpp_lib_generic_associative_lookup != 201304
-#  error __cpp_lib_generic_associative_lookup != 201304
-#endif
+//#ifndef  __cpp_lib_generic_associative_lookup
+//#  error __cpp_lib_generic_associative_lookup
+//#elif  __cpp_lib_generic_associative_lookup != 201304
+//#  error __cpp_lib_generic_associative_lookup != 201304
+//#endif
 
 //#ifndef  __cpp_lib_null_iterators
 //#  error __cpp_lib_null_iterators
@@ -111,3 +111,9 @@
 #elif  __cpp_lib_shared_timed_mutex != 201402
 #  error __cpp_lib_shared_timed_mutex != 201402
 #endif
+
+#ifndef  __cpp_lib_is_final
+#  error __cpp_lib_is_final
+#elif  __cpp_lib_is_final != 201402
+#  error __cpp_lib_is_final != 201402
+#endif
Index: testsuite/20_util/declval/requirements/1_neg.cc
===
--- testsuite/20_util/declval/requirements/1_neg.cc (revision 215788)
+++ testsuite/20_util/declval/requirements

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

2014-10-02 Thread Ed Smith-Rowland

On 10/02/2014 02:51 AM, Ed Smith-Rowland wrote:

On 10/01/2014 11:28 AM, Jonathan Wakely wrote:

On 02/09/14 10:24 +0100, Jonathan Wakely wrote:

On 01/09/14 21:46 -0400, Ed Smith-Rowland wrote:

Index: include/bits/stl_function.h
===
--- include/bits/stl_function.h(revision 214680)
+++ include/bits/stl_function.h(working copy)
@@ -217,6 +217,10 @@
   };

#if __cplusplus  201103L
+
+#define __cpp_lib_transparent_operators 201210
+#define __cpp_lib_generic_associative_lookup 201304


The generic associative lookup feature is not supported.


Index: testsuite/experimental/feat-lib-fund.cc
===
--- testsuite/experimental/feat-lib-fund.cc(revision 0)
+++ testsuite/experimental/feat-lib-fund.cc(working copy)
@@ -0,0 +1,25 @@
+// { dg-options -std=gnu++14 }
+// { dg-do compile }
+
+#include experimental/optional
+#include experimental/string_view
+
+#if !__has_include(experimental/optional)
+#  error experimental/optional
+#endif
+
+//#if !__has_include(experimental/net)
+//#  error experimental/net
+//#endif
+
+//#if !__has_include(experimental/any)
+//#  error experimental/any
+//#endif


This can be uncommented, experimental/any is available.

OK with those changes.


Ed, the commit at http://gcc.gnu.org/r215752 doesn't have the
corrections I asked for above and causes a number of test failures,
could you look into it please?



OK,

Here is the patch.

Built and tested on x86_64-linux.

OK?

Ed

FWIW, I remember a svn tree corruption while getting this patch ready.
I should have retested everything in the new tree.
Sorry everyone!


Here is a front-end test patch.
Built and tested on x86_64-linux.
OK?
Ed

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

* g++.dg/cpp1y/feat-cxx98-neg.C: Fix double negative thinko and
add many more tests.

Index: g++.dg/cpp1y/feat-cxx98-neg.C
===
--- g++.dg/cpp1y/feat-cxx98-neg.C   (revision 215793)
+++ g++.dg/cpp1y/feat-cxx98-neg.C   (working copy)
@@ -1,6 +1,99 @@
 // { dg-do compile { target c++98_only } }
 // { dg-options -ansi }
 
-#ifdef __cpp_runtime_arrays
+#ifndef __cpp_runtime_arrays
 #  error __cpp_runtime_arrays // { dg-error error }
 #endif
+
+#ifndef __cpp_unicode_characters
+#  error __cpp_unicode_characters // { dg-error error }
+#endif
+
+#ifndef __cpp_raw_strings
+#  error __cpp_raw_strings // { dg-error error }
+#endif
+
+#ifndef __cpp_unicode_literals
+#  error __cpp_unicode_literals // { dg-error error }
+#endif
+
+#ifndef __cpp_user_defined_literals
+#  error __cpp_user_defined_literals // { dg-error error }
+#endif
+
+#ifndef __cpp_lambdas
+#  error __cpp_lambdas // { dg-error error }
+#endif
+
+#ifndef __cpp_constexpr
+#  error __cpp_constexpr // { dg-error error }
+#endif
+
+#ifndef __cpp_static_assert
+#  error __cpp_static_assert // { dg-error error }
+#endif
+
+#ifndef __cpp_decltype
+#  error __cpp_decltype // { dg-error error }
+#endif
+
+#ifndef __cpp_attributes
+#  error __cpp_attributes // { dg-error error }
+#endif
+
+#ifndef __cpp_rvalue_reference
+#  error __cpp_rvalue_reference // { dg-error error }
+#endif
+
+#ifndef __cpp_variadic_templates
+#  error __cpp_variadic_templates // { dg-error error }
+#endif
+
+#ifndef __cpp_alias_templates
+#  error __cpp_alias_templates // { dg-error error }
+#endif
+
+// C++14
+
+// C++98 gets binary literals.
+//#ifndef __cpp_binary_literals
+//#  error __cpp_binary_literals
+//#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
+
+//  Aggregate initializers not in yet.
+//#ifdef __cpp_aggregate_nsdmi
+//#  error __cpp_aggregate_nsdmi
+//#endif
+
+#ifndef __cpp_variable_templates
+#  error __cpp_variable_templates // { 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
+
+//  Sized deallocation not in yet.
+//#ifdef __cpp_sized_deallocation
+//#  error __cpp_sized_deallocation
+//#endif


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

2014-10-02 Thread Ed Smith-Rowland

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

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

Note Ed's recent changes. Committed to CVS.


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


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


Thanks,

Ed



std::is_final for gcc-4.9 branch.

2014-10-02 Thread Ed Smith-Rowland

Built and tested clean on x86_64-linux.

OK?

Ed

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

* include/std/type_traits: Add is_final type trait for C++14.
* testsuite/util/testsuite_tr1.h: Add 
* testsuite/20_util/is_final/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_final/requirements/typedefs.cc: New.
* testsuite/20_util/is_final/value.cc: New.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust.

Index: include/std/type_traits
===
--- include/std/type_traits (revision 215826)
+++ include/std/type_traits (working copy)
@@ -634,6 +634,14 @@
 : public integral_constantbool, __is_polymorphic(_Tp)
 { };
 
+#if __cplusplus  201103L
+  /// is_final
+  templatetypename _Tp
+struct is_final
+: public integral_constantbool, __is_final(_Tp)
+{ };
+#endif
+
   /// is_abstract
   templatetypename _Tp
 struct is_abstract
Index: testsuite/20_util/declval/requirements/1_neg.cc
===
--- testsuite/20_util/declval/requirements/1_neg.cc (revision 215826)
+++ testsuite/20_util/declval/requirements/1_neg.cc (working copy)
@@ -19,7 +19,7 @@
 // with this library; see the file COPYING3.  If not see
 // http://www.gnu.org/licenses/.
 
-// { dg-error static assertion failed  { target *-*-* } 2036 }
+// { dg-error static assertion failed  { target *-*-* } 2044 }
 
 #include utility
 
Index: testsuite/20_util/is_final/requirements/explicit_instantiation.cc
===
--- testsuite/20_util/is_final/requirements/explicit_instantiation.cc   
(revision 0)
+++ testsuite/20_util/is_final/requirements/explicit_instantiation.cc   
(working copy)
@@ -0,0 +1,29 @@
+// { dg-options -std=gnu++14 }
+// { dg-do compile }
+
+// 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/.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include type_traits
+
+namespace std
+{
+  typedef short test_type;
+  template struct is_finaltest_type;
+}
Index: testsuite/20_util/is_final/requirements/typedefs.cc
===
--- testsuite/20_util/is_final/requirements/typedefs.cc (revision 0)
+++ testsuite/20_util/is_final/requirements/typedefs.cc (working copy)
@@ -0,0 +1,34 @@
+// { dg-options -std=gnu++14 }
+// { dg-do compile }
+
+// 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/.
+
+// 
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include type_traits
+
+void test01()
+{
+  // Check for required typedefs
+  typedef std::is_finalint test_type;
+  typedef test_type::value_type   value_type;
+  typedef test_type::type type;
+  typedef test_type::type::value_type type_value_type;
+  typedef test_type::type::type   type_type;
+}
Index: testsuite/20_util/is_final/value.cc
===
--- testsuite/20_util/is_final/value.cc (revision 0)
+++ testsuite/20_util/is_final/value.cc (working copy)
@@ -0,0 +1,35 @@
+// { dg-options -std=gnu++14 }
+// { dg-do compile }
+
+// Copyright (C) 2011-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. 

SD-6 C++ feature-testing macros for 4.9

2014-10-04 Thread Ed Smith-Rowland

On 10/02/2014 11:42 AM, Jonathan Wakely wrote:

The library macros are safe and can't cause any issues, so I'm happy for them 
to go on the branch.

I can think of at least two that aren't implemented on the branch: 
experimental/any and the std::is_final trait (although I'd be OK with the 
trait going on the branch too).



- Original Message -
From: Jason Merrill ja...@redhat.com
To: Ed Smith-Rowland 3dw...@verizon.net, Jonathan Wakely 
jwak...@redhat.com
Cc: gcc-patches@gcc.gnu.org, thiago macieira thiago.macie...@intel.com
Sent: Thursday, 2 October, 2014 4:40:03 PM
Subject: Re: feature-testing macros for 4.9

On 10/02/2014 10:58 AM, Ed Smith-Rowland wrote:

We've had a request from someone that we include SD-6 feature testing
for gcc-4.9.
It seems rather heavy for a backport but it might make maintainers of
large C++ libraries happy ;-) and it might make sense as people migrate
from 4.9 to 5.0 to see what we've added.

I'm open to that.

Jason




OK,

This really does build clean and test clean on x86_64-linux.
It's basically the same as for 5.0 except experimental/any isn't in and 
variable templates aren't in.


I put std::is_final into 4.9 earlier - this patch adds the macro for 
that too.


I made this into a single grand unified patch this time.  i didn't think 
splitting it lat time bought me much.


Ed


libcpp/

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

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


gcc/c-family/

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

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


libstdc++-v3/

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

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


gcc/testsuite/

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

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

Index: libcpp/internal.h
===
--- libcpp/internal.h   (revision 215826)
+++ libcpp/internal.h   (working copy)
@@ -258,6 +258,9 @@
   /* Nonzero when parsing arguments to a function-like macro.  */
   unsigned char parsing_args;
 
+  /* Nonzero if in a __has_include__ or __has_include_next__ statement.  */
+  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

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

2014-10-05 Thread Ed Smith-Rowland

Greetings,

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


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

Ed


gcc/c-family:

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

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


gcc/cp:

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

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


gcc/testsuite:

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

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

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

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

2014-10-07 Thread Ed Smith-Rowland

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

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

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

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

Note Ed's recent changes. Committed to CVS.


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


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

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


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


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

Are these too wordy?

Ed

Index: htdocs/gcc-5/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-5/changes.html,v
retrieving revision 1.14
diff -r1.14 changes.html
56a57,81
 liNew preprocessor constructs, code__has_include_next/code
 and code__has_include_next/code, to test the availability of 
 headers
 have been added.br/
 This demonstrates a way to include the header 
 codelt;optionalgt;/code
 only if it is available:br/
 blockquotepre
 #ifdef __has_include
 #  if __has_include(lt;optionalgt;)
 #include lt;optionalgt;
 #define have_optional 1
 #  elif __has_include(lt;experimental/optionalgt;)
 #include lt;experimental/optionalgt;
 #define have_optional 1
 #define experimental_optional
 #  else
 #define have_optional 0
 #  endif
 #endif
 /pre/blockquote
 The header search paths for code__has_include_next/code
 and code__has_include_next/code are equivalent to those
 of the standard directive code#include/code
 and the extension code#include_next/code respectively.
 /li
 
88a114,117
   liG++ now allows codetypename/code in a template template parameter.
 blockquotepre
   templatelt;templatelt;typenamegt; btypename/b Xgt; struct D; // 
 OK
 /pre/blockquote/li


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

2014-10-09 Thread Ed Smith-Rowland

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

On Oct 9, 2014, at 11:56 AM, Uros Bizjak ubiz...@gmail.com wrote:

2014-10-09  Uros Bizjak  ubiz...@gmail.com

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

Tested on x86_64. OK for branch?

So, I need Ed or Jason to review it…


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

The patch is good.

Thank you all!
Ed



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




[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: [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, 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, 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? ;-)




[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: [C++11, C++14 PATCH 2/3] Support for SD-6: SG10 Feature Test Recommendations - c-family and testsuite

2014-06-02 Thread Ed Smith-Rowland

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

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

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


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



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


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

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

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


Jason






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

2014-06-05 Thread Ed Smith-Rowland

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

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

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


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


Jason



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

After rebuilding and testing committed as obvious.

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

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

[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

[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

[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

[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;
+};


PATCH to add -std=c++14

2014-03-11 Thread Ed Smith-Rowland

Why not also -std=gnu++14?



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

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.



[PATCH, C++, SD-6] Add __cpp_aggregate_nsdmi macro now that we nave them.

2014-11-01 Thread Ed Smith-Rowland

Subject says it all really.

Build and tested clean on x86_64-linux.

OK?

Ed


testsuite/

2014-11-02  Edward Smith-Rowland  3dw...@verizon.net

* g++.dg/cpp1y/feat-cxx11.C: Commentary and rearrangement of tests.
* g++.dg/cpp1y/feat-cxx11-neg.C: Add aggregate NSDMI test.
Commentary and rearrangement of tests.
* g++.dg/cpp1y/feat-cxx14.C: Enable aggregate NSDMI test.
Commentary and rearrangement of tests.
* g++.dg/cpp1y/feat-cxx98-neg.C: Ditto
* g++.dg/cpp1y/feat-cxx98.C: Commentary.

c-family/

2014-11-02  Edward Smith-Rowland  3dw...@verizon.net

* c-cppbuiltin.c: Define __cpp_aggregate_nsdmi.
Index: testsuite/g++.dg/cpp1y/feat-cxx11-neg.C
===
--- testsuite/g++.dg/cpp1y/feat-cxx11-neg.C (revision 217006)
+++ testsuite/g++.dg/cpp1y/feat-cxx11-neg.C (working copy)
@@ -1,7 +1,7 @@
 // { dg-do compile { target c++11_only } }
 // { dg-options -pedantic-errors }
 
-// These *are* defined in C++14 onwards.
+// C++14 features:
 
 #ifndef __cpp_binary_literals
 #  error __cpp_binary_literals // { dg-error error }
@@ -31,11 +31,19 @@
 #  error __cpp_digit_separators // { dg-error error }
 #endif
 
+#ifndef __cpp_aggregate_nsdmi
+#  error __cpp_aggregate_nsdmi // { dg-error error }
+#endif
+
+//  Array TS features:
+
+#ifndef __cpp_runtime_arrays
+#  error __cpp_runtime_arrays // { dg-error error }
+#endif
+
+//  Attribute checks:
+
 //  Attribute [[deprecated]] is allowed in C++11 as an extension (with 
pedwarn).
 //#ifndef __cpp_attribute_deprecated
 //#  error __cpp_attribute_deprecated
 //#endif
-
-#ifndef __cpp_runtime_arrays
-#  error __cpp_runtime_arrays // { dg-error error }
-#endif
Index: testsuite/g++.dg/cpp1y/feat-cxx11.C
===
--- testsuite/g++.dg/cpp1y/feat-cxx11.C (revision 217006)
+++ testsuite/g++.dg/cpp1y/feat-cxx11.C (working copy)
@@ -1,6 +1,8 @@
 // { dg-do compile }
 // { dg-options -std=gnu++11 }
 
+//  C++11 features:
+
 #ifndef __cpp_unicode_characters
 #  error __cpp_unicode_characters
 #elif __cpp_unicode_characters != 200704
@@ -73,7 +75,8 @@
 #  error __cpp_alias_templates != 200704
 #endif
 
-//  These C++14 features are allowed in C++11 in non-ANSI modes.
+//  C++14 features allowed in C++11 in non-ANSI modes:
+
 #ifndef __cpp_binary_literals
 #  error __cpp_binary_literals
 #elif __cpp_binary_literals != 201304
@@ -80,6 +83,9 @@
 #  error __cpp_binary_literals != 201304
 #endif
 
+//  Attribute checks:
+
+//  Attribute [[deprecated]] is allowed in C++11 as an extension (with 
pedwarn).
 #ifndef __cpp_attribute_deprecated
 #  error __cpp_attribute_deprecated
 #elif __cpp_attribute_deprecated != 201309
Index: testsuite/g++.dg/cpp1y/feat-cxx14.C
===
--- testsuite/g++.dg/cpp1y/feat-cxx14.C (revision 217006)
+++ testsuite/g++.dg/cpp1y/feat-cxx14.C (working copy)
@@ -1,7 +1,7 @@
 // { dg-do compile { target c++14 } }
 // { dg-options -I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc }
 
-// Begin C++11 tests.
+//  C++11 features:
 
 #ifndef __cpp_unicode_characters
 #  error __cpp_unicode_characters
@@ -75,7 +75,7 @@
 #  error __cpp_alias_templates != 200704
 #endif
 
-// Begin C++14 tests.
+//  C++14 features:
 
 #ifndef __cpp_binary_literals
 #  error __cpp_binary_literals
@@ -114,15 +114,10 @@
 #  error __cpp_return_type_deduction != 201304
 #endif
 
-#ifndef __cpp_runtime_arrays
-#  error __cpp_runtime_arrays
-#elif __cpp_runtime_arrays != 201304
-#  error __cpp_runtime_arrays != 201304
-#endif
-
-//  Aggregate initializers not in yet.
-#ifdef __cpp_aggregate_nsdmi
+#ifndef __cpp_aggregate_nsdmi
 #  error __cpp_aggregate_nsdmi
+#elif __cpp_aggregate_nsdmi != 201304
+#  error __cpp_aggregate_nsdmi != 201304
 #endif
 
 #ifndef __cpp_variable_templates
@@ -137,6 +132,21 @@
 #  error __cpp_digit_separators != 201309
 #endif
 
+//  Sized deallocation not in yet.
+#ifdef __cpp_sized_deallocation
+#  error __cpp_sized_deallocation
+#endif
+
+//  Array TS features:
+
+#ifndef __cpp_runtime_arrays
+#  error __cpp_runtime_arrays
+#elif __cpp_runtime_arrays != 201304
+#  error __cpp_runtime_arrays != 201304
+#endif
+
+//  Attribute checks:
+
 #ifndef __cpp_attribute_deprecated
 #  error __cpp_attribute_deprecated
 #elif __cpp_attribute_deprecated != 201309
@@ -143,13 +153,8 @@
 #  error __cpp_attribute_deprecated != 201309
 #endif
 
-//  Sized deallocation not in yet.
-#ifdef __cpp_sized_deallocation
-#  error __cpp_sized_deallocation
-#endif
+//  Include checks:
 
-// Begin include checks.
-
 //  Check for __has_include macro.
 #ifndef __has_include
 #  error __has_include
Index: testsuite/g++.dg/cpp1y/feat-cxx98-neg.C
===
--- testsuite/g++.dg/cpp1y/feat-cxx98-neg.C (revision 217006)
+++ testsuite/g++.dg/cpp1y/feat-cxx98-neg.C (working copy)
@@ -1,6 +1,8 @@
 

Add uniform_inside_sphere_distribution

2014-11-05 Thread Ed Smith-Rowland

This distribution has come in handy for me.

It relies on uniform_on_sphere_distribution and like it, min and max 
have no real meaning.
Unlike uniform_on_sphere_distribution which really is a random 
multidimensional unit vector users often want to pick the radius of the 
distribution.
Unit radius is a good default and is provided but the user can specify 
radius.


Like the uniform_on_sphere_distribution which is used inside, the 
2-dimensional case uses rejection and higher dimensions use a transform.


Built and tested clean on x86_64-linux.

OK?

Ed

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

* include/ext/random: Add uniform_inside_sphere_distribution.
* include/ext/random.tcc: Out-of-line implementation of
uniform_inside_sphere_distribution.
* testsuite/ext/random/uniform_inside_sphere_distribution/cons/
default.cc: New.
* testsuite/ext/random/uniform_inside_sphere_distribution/cons/
parms.cc: New.
* testsuite/ext/random/uniform_inside_sphere_distribution/operators/
equal.cc: New.
* testsuite/ext/random/uniform_inside_sphere_distribution/operators/
generate.cc: New.
* testsuite/ext/random/uniform_inside_sphere_distribution/operators/
inequal.cc: New.
* testsuite/ext/random/uniform_inside_sphere_distribution/operators/
serialize.cc: New.
Index: include/ext/random
===
--- include/ext/random  (revision 216942)
+++ include/ext/random  (working copy)
@@ -3487,6 +3487,218 @@
   _RealType __d2)
 { return !(__d1 == __d2); }
 
+
+  /**
+   * @brief A distribution for random coordinates inside a unit sphere.
+   */
+  templatestd::size_t _Dimen, typename _RealType = double
+class uniform_inside_sphere_distribution
+{
+  static_assert(std::is_floating_point_RealType::value,
+   template argument not a floating point type);
+  static_assert(_Dimen != 0, dimension is zero);
+
+public:
+  /** The type of the range of the distribution. */
+  using result_type = std::array_RealType, _Dimen;
+
+  /** Parameter type. */
+  struct param_type
+  {
+   using distribution_type
+ = uniform_inside_sphere_distribution_Dimen, _RealType;
+   friend class uniform_inside_sphere_distribution_Dimen, _RealType;
+
+   explicit
+   param_type(_RealType __radius = _RealType(1))
+   : _M_radius(__radius)
+   {
+ _GLIBCXX_DEBUG_ASSERT(_M_radius  _RealType(0));
+   }
+
+   _RealType
+   radius() const
+   { return _M_radius; }
+
+   friend bool
+   operator==(const param_type __p1, const param_type __p2)
+   { return __p1._M_radius == __p2._M_radius; }
+
+  private:
+   _RealType _M_radius;
+  };
+
+  /**
+   * @brief Constructors.
+   */
+  explicit
+  uniform_inside_sphere_distribution(_RealType __radius = _RealType(1))
+  : _M_param(__radius), _M_uosd()
+  { }
+
+  explicit
+  uniform_inside_sphere_distribution(const param_type __p)
+  : _M_param(__p), _M_uosd()
+  { }
+
+  /**
+   * @brief Resets the distribution state.
+   */
+  void
+  reset()
+  { _M_uosd.reset(); }
+
+  /**
+   * @brief Returns the @f$radius@f$ of the distribution.
+   */
+  _RealType
+  radius() const
+  { return _M_param.radius(); }
+
+  /**
+   * @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.
+   * This function makes no sense for this distribution.
+   */
+  result_type
+  min() const
+  {
+   result_type __res;
+   __res.fill(0);
+   return __res;
+  }
+
+  /**
+   * @brief Returns the least upper bound value of the distribution.
+   * This function makes no sense for this distribution.
+   */
+  result_type
+  max() const
+  {
+   result_type __res;
+   __res.fill(0);
+   return __res;
+  }
+
+  /**
+   * @brief Generating functions.
+   */
+  templatetypename _UniformRandomNumberGenerator
+   result_type
+   operator()(_UniformRandomNumberGenerator __urng)
+   { return this-operator()(__urng, _M_param); }
+
+  templatetypename _UniformRandomNumberGenerator
+   result_type
+   operator()(_UniformRandomNumberGenerator __urng,
+  const param_type __p);
+
+  templatetypename _ForwardIterator,
+  typename _UniformRandomNumberGenerator
+   void
+   

Re: Add uniform_inside_sphere_distribution

2014-11-05 Thread Ed Smith-Rowland

On 11/05/2014 04:25 PM, Marc Glisse wrote:

On Wed, 5 Nov 2014, Ed Smith-Rowland wrote:

Like the uniform_on_sphere_distribution which is used inside, the 
2-dimensional case uses rejection


Could you point out where in the code you are special-casing dimension 
2? Somehow I can't see it in the patch.



My miscommunication.  Sorry.

The special casing - and all the hard work - is done by the contained 
uniform_on_sphere_distribution.

The uniform_inside_sphere_distribution only has one template.

Ed



Re: Add uniform_inside_sphere_distribution

2014-11-06 Thread Ed Smith-Rowland

On 11/06/2014 02:23 AM, Marc Glisse wrote:

On Wed, 5 Nov 2014, Ed Smith-Rowland wrote:


On 11/05/2014 04:25 PM, Marc Glisse wrote:

On Wed, 5 Nov 2014, Ed Smith-Rowland wrote:

Like the uniform_on_sphere_distribution which is used inside, the 
2-dimensional case uses rejection


Could you point out where in the code you are special-casing 
dimension 2? Somehow I can't see it in the patch.



My miscommunication.  Sorry.

The special casing - and all the hard work - is done by the contained 
uniform_on_sphere_distribution.


In dimension 2, uniform_on_sphere_distribution generates a uniform 
random point in the unit disk and projects it to the circle. Using 
that + one more random number to regenerate a uniform random point in 
the disk seems wasteful to me.


Good point.  I'll check out a direct rejection and see what that gets me 
time-wise.  The ratio is pi/4 which is pretty good.




Add the latest C++ SD-6 additions.

2014-11-09 Thread Ed Smith-Rowland
I would like to put this patch out before Stage 1 ends even if there is 
bikeshed renaming of macros in the next couple weeks as the C++ 
committee wraps up after their meeting.


The main part of this patch is a __has_cpp_attribute macro.
#if __has_cpp_attribute(foobar)
#else
#endif

In C++ we can use namespaces as well:
#if __has_cpp_attribute(gnu::foobar)
#else
#endif

I also added __has_attribute with the same sematics as an extension 
since clang has it.

I made these available to C as well as C++.

There are also two C++98 flags in SD-6 added since most compilers allow 
one to switch these features off:
__cpp_rtti, __cpp_exceptions.  These are not defined if -fno-rtti 
-fno-exceptions respectively.


Also, the macro __cpp_attribute_deprecated has been removed in favor of 
__has_cpp_attribute(deprecated).
Since __cpp_attribute_deprecated is out in the wild in the latest 
gcc-4.9 release perhaps I need to support this
even if, in an ironic twist, __cpp_attribute_deprecated is deprecated.  
Let me know.


This builds clean on x86_64-linux.

Is this OK once it passes testing?

Ed

libcpp:

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

* include/cpplib.h (cpp_callbacks): Add has_attribute.
* internal.h (lexer_state): Add in__has_attribute__.
* directives.c (lex_macro_node): Prevent use of __has_attribute__
as a macro.
* expr.c (parse_has_attribute): New function; (eval_token): Look for
__has_attribute__ and route to parse_has_attribute.
* identifiers.c (_cpp_init_hashtable): Initialize n__has_attribute__.
* pch.c (cpp_read_state): Initialize n__has_attribute__.
* traditional.c (enum ls): Add ls_has_attribute, ls_has_attribute_close;
(_cpp_scan_out_logical_line): Attend to __has_attribute__.


gcc/c-family:

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

* c-cppbuiltin.c (__has_attribute, __has_cpp_attribute): New macros;
(__cpp_rtti, __cpp_exceptions): New macros for C++98;
(__cpp_range_based_for, __cpp_initializer_lists,
__cpp_delegating_constructors, __cpp_nsdmi,
__cpp_inheriting_constructors, __cpp_ref_qualifiers): New macros
for C++11; (__cpp_attribute_deprecated): Remove in favor of
__has_cpp_attribute.
* c-lex.c (cb_has_attribute): New callback CPP function;
(init_c_lex): Set has_attribute callback.


gcc/testsuite:

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

* g++.dg/cpp1y/feat-cxx11.C: Test new feature macros for C++98
and C++11; Test existence of __has_cpp_attribute;  Test C++11
attributes.
* g++.dg/cpp1y/feat-cxx11-neg.C: Ditto.
* g++.dg/cpp1y/feat-cxx14.C: Ditto and test for C++14 attributes.
* g++.dg/cpp1y/feat-cxx98.C: Test new feature macros for C++98.
* g++.dg/cpp1y/feat-cxx98-neg.C: Ditto.
* g++.dg/cpp1y/feat-neg.C: Test that __cpp_rtti, _cpp_exceptions
will be undefined for -fno-rtti -fno-exceptions.
Index: libcpp/include/cpplib.h
===
--- libcpp/include/cpplib.h (revision 217269)
+++ libcpp/include/cpplib.h (working copy)
@@ -580,6 +580,9 @@
  Second argument is the location of the start of the current expansion.  */
   void (*used) (cpp_reader *, source_location, cpp_hashnode *);
 
+  /* Callback to identify whether an attribute exists.  */
+  int (*has_attribute) (cpp_reader *);
+
   /* Callback that can change a user builtin into normal macro.  */
   bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *);
 };
Index: libcpp/internal.h
===
--- libcpp/internal.h   (revision 217269)
+++ libcpp/internal.h   (working copy)
@@ -261,6 +261,9 @@
   /* Nonzero if in a __has_include__ or __has_include_next__ statement.  */
   unsigned char in__has_include__;
 
+  /* Nonzero if in a __has_attribute__ statement.  */
+  unsigned char in__has_attribute__;
+
   /* Nonzero if prevent_expansion is true only because output is
  being discarded.  */
   unsigned char discarding_output;
@@ -284,6 +287,7 @@
   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 */
+  cpp_hashnode *n__has_attribute__;/* __has_attribute__ operator */
 };
 
 typedef struct _cpp_line_note _cpp_line_note;
Index: libcpp/directives.c
===
--- libcpp/directives.c (revision 217269)
+++ libcpp/directives.c (working copy)
@@ -571,6 +571,10 @@
 || 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 (is_def_or_undef
+node == pfile-spec_nodes.n__has_attribute__)
+   cpp_error (pfile, 

Re: Add the latest C++ SD-6 additions.

2014-11-10 Thread Ed Smith-Rowland

On 11/09/2014 11:45 PM, Jason Merrill wrote:

On 11/09/2014 08:33 PM, Ed Smith-Rowland wrote:

+  //cpp_hashnode *node = 0;
+  //node = token-val.node.node;
+  //if (node)
+  //  pfile-mi_ind_cmacro = node;


Remove this commented-out code?

The patch is OK.

Jason


Here is the committed patch.  It has those comments removed and has some 
test case cleanup.


Would a 4.9 version be accepted?

Thanks,

Ed

Index: libcpp/include/cpplib.h
===
--- libcpp/include/cpplib.h (revision 217269)
+++ libcpp/include/cpplib.h (working copy)
@@ -580,6 +580,9 @@
  Second argument is the location of the start of the current expansion.  */
   void (*used) (cpp_reader *, source_location, cpp_hashnode *);
 
+  /* Callback to identify whether an attribute exists.  */
+  int (*has_attribute) (cpp_reader *);
+
   /* Callback that can change a user builtin into normal macro.  */
   bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *);
 };
Index: libcpp/internal.h
===
--- libcpp/internal.h   (revision 217269)
+++ libcpp/internal.h   (working copy)
@@ -261,6 +261,9 @@
   /* Nonzero if in a __has_include__ or __has_include_next__ statement.  */
   unsigned char in__has_include__;
 
+  /* Nonzero if in a __has_attribute__ statement.  */
+  unsigned char in__has_attribute__;
+
   /* Nonzero if prevent_expansion is true only because output is
  being discarded.  */
   unsigned char discarding_output;
@@ -284,6 +287,7 @@
   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 */
+  cpp_hashnode *n__has_attribute__;/* __has_attribute__ operator */
 };
 
 typedef struct _cpp_line_note _cpp_line_note;
Index: libcpp/directives.c
===
--- libcpp/directives.c (revision 217269)
+++ libcpp/directives.c (working copy)
@@ -571,6 +571,10 @@
 || 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 (is_def_or_undef
+node == pfile-spec_nodes.n__has_attribute__)
+   cpp_error (pfile, CPP_DL_ERROR,
+  \__has_attribute__\ cannot be used as a macro name);
   else if (! (node-flags  NODE_POISONED))
return node;
 }
Index: libcpp/expr.c
===
--- libcpp/expr.c   (revision 217269)
+++ libcpp/expr.c   (working copy)
@@ -65,6 +65,7 @@
 static void check_promotion (cpp_reader *, const struct op *);
 
 static cpp_num parse_has_include (cpp_reader *, enum include_type);
+static cpp_num parse_has_attribute (cpp_reader *);
 
 /* Token type abuse to create unary plus and minus operators.  */
 #define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1))
@@ -1054,6 +1055,8 @@
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 (token-val.node.node == pfile-spec_nodes.n__has_attribute__)
+   return parse_has_attribute (pfile);
   else if (CPP_OPTION (pfile, cplusplus)
(token-val.node.node == pfile-spec_nodes.n_true
   || token-val.node.node == pfile-spec_nodes.n_false))
@@ -2147,3 +2150,21 @@
 
   return result;
 }
+
+/* Handle meeting __has_attribute__ in a preprocessor expression.  */
+static cpp_num
+parse_has_attribute (cpp_reader *pfile)
+{
+  pfile-state.in__has_attribute__++;
+
+  cpp_num result;
+  result.unsignedp = false;
+  result.high = 0;
+  result.overflow = false;
+
+  result.low = pfile-cb.has_attribute (pfile);
+
+  pfile-state.in__has_attribute__--;
+
+  return result;
+}
Index: libcpp/identifiers.c
===
--- libcpp/identifiers.c(revision 217269)
+++ libcpp/identifiers.c(working copy)
@@ -72,6 +72,7 @@
   s-n__VA_ARGS__-flags |= NODE_DIAGNOSTIC;
   s-n__has_include__   = cpp_lookup (pfile, DSC(__has_include__));
   s-n__has_include_next__ = cpp_lookup (pfile, DSC(__has_include_next__));
+  s-n__has_attribute__   = cpp_lookup (pfile, DSC(__has_attribute__));
 }
 
 /* Tear down the identifier hash table.  */
Index: libcpp/pch.c
===
--- libcpp/pch.c(revision 217269)
+++ libcpp/pch.c(working copy)
@@ -835,6 +835,7 @@
 s-n__VA_ARGS__ = cpp_lookup (r, DSC(__VA_ARGS__));
 s-n__has_include__ = cpp_lookup (r, DSC(__has_include__));
 s-n__has_include_next__ = cpp_lookup (r, DSC(__has_include_next__));
+s-n__has_attribute__ = cpp_lookup (r, DSC(__has_attribute__));
   }
 
   old_state

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

2014-08-26 Thread Ed Smith-Rowland

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

Hi,

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

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

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

Paolo.


I should have mentioned this thought.

Maybe we could do something more scary like

   __GLIBCXX_CPLUSPLUS_98
   __GLIBCXX_CPLUSPLUS_11
   __GLIBCXX_CPLUSPLUS_14

so people won't use them.

The __cplusplus_11 etc. look almost standard ;-)

Ed



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

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


Built and tested on x86_64-linux.

OK?


libcpp/

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

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


gcc/testsuite/

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

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

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

2014-08-28 Thread Ed Smith-Rowland

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

OK.

Jason


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

Attached slightly modified patch.

Ed


libcpp/

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

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


gcc/testsuite/

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

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

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

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

2014-08-28 Thread Ed Smith-Rowland

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

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

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


Agreed.

Jason





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

Ed



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

2014-09-01 Thread Ed Smith-Rowland

Greetings,

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


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


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


Bootstrapped and tested under x86_64-linux.

OK?

Ed

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

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

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

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

2014-09-01 Thread Ed Smith-Rowland

Greetings,

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

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

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

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

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

Bootstrapped and tested under x86_64-linux.

OK?

Ed

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

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

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


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

2014-09-01 Thread Ed Smith-Rowland

Greetings,

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

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

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

Bootstrapped and tested under x86_64-linux.

OK?

Ed

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

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

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

[PATCH C++] - SD-6 Implementation

2014-09-01 Thread Ed Smith-Rowland

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

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

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

The __has_cpp_attribute will just be for C++.

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


Sincerely,

Ed



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

2014-09-06 Thread Ed Smith-Rowland

Greetings,

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

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

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

Bootstrapped and tested under x86_64-linux.

OK?

Ed

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

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

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

[C++14] Add is_final type trait.

2014-09-13 Thread Ed Smith-Rowland

We've had __has_final built-in for a good while.
the std library component is_final was added to C++14 - which is now good.
I noticed while looking at the latest SD-6 draft.

So here is a simple patch that builds and passes clean on x86_64-linux.

OK?

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

* include/std/type_traits: Add is_final type trait for C++14.
* testsuite/util/testsuite_tr1.h: Add 
* testsuite/20_util/is_final/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_final/requirements/typedefs.cc: New.
* testsuite/20_util/is_final/value.cc: New.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust.

Index: include/std/type_traits
===
--- include/std/type_traits (revision 215247)
+++ include/std/type_traits (working copy)
@@ -634,6 +634,15 @@
 : public integral_constantbool, __is_polymorphic(_Tp)
 { };
 
+#if __cplusplus = 201402L
+#define __cpp_lib_is_final 201402L
+  /// is_final
+  templatetypename _Tp
+struct is_final
+: public integral_constantbool, __is_final(_Tp)
+{ };
+#endif
+
   /// is_abstract
   templatetypename _Tp
 struct is_abstract
Index: testsuite/20_util/declval/requirements/1_neg.cc
===
--- testsuite/20_util/declval/requirements/1_neg.cc (revision 215247)
+++ testsuite/20_util/declval/requirements/1_neg.cc (working copy)
@@ -19,7 +19,7 @@
 // with this library; see the file COPYING3.  If not see
 // http://www.gnu.org/licenses/.
 
-// { dg-error static assertion failed  { target *-*-* } 2082 }
+// { dg-error static assertion failed  { target *-*-* } 2091 }
 
 #include utility
 
Index: testsuite/20_util/is_final/requirements/explicit_instantiation.cc
===
--- testsuite/20_util/is_final/requirements/explicit_instantiation.cc   
(revision 0)
+++ testsuite/20_util/is_final/requirements/explicit_instantiation.cc   
(working copy)
@@ -0,0 +1,29 @@
+// { dg-options -std=gnu++14 }
+// { dg-do compile }
+
+// 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/.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include type_traits
+
+namespace std
+{
+  typedef short test_type;
+  template struct is_finaltest_type;
+}
Index: testsuite/20_util/is_final/requirements/typedefs.cc
===
--- testsuite/20_util/is_final/requirements/typedefs.cc (revision 0)
+++ testsuite/20_util/is_final/requirements/typedefs.cc (working copy)
@@ -0,0 +1,34 @@
+// { dg-options -std=gnu++14 }
+// { dg-do compile }
+
+// 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/.
+
+// 
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include type_traits
+
+void test01()
+{
+  // Check for required typedefs
+  typedef std::is_finalint test_type;
+  typedef test_type::value_type   value_type;
+  typedef test_type::type type;
+  typedef test_type::type::value_type type_value_type;
+  typedef test_type::type::type   type_type;
+}
Index: testsuite/20_util/is_final/value.cc
===
--- testsuite/20_util/is_final/value.cc (revision 0)

[PATCH C++, PING] - SD-6 Implementation Part N/4.

2014-09-14 Thread Ed Smith-Rowland

I would like review of my SD-6 implementation.

Part 1 - __has_include__ built-in in libcpp.
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00083.html

Part 2 - __has_include macro and C++ language feature macros.
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00084.html

Part 3 - libstdc++ library macros was already approved by Jonathan. 
Thank you.

https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00085.html
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00110.html

Part 4 - C++ front end tests.
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00553.html

These build and test cleanly on x86_64-linux.

Part 5 - __has_cpp_attribute and supporting machinery is proving more 
interesting than I thought.

But the rest should be put in.

Thank you,
Ed Smith-Rowland



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

2014-09-15 Thread Ed Smith-Rowland

On 09/15/2014 05:17 AM, Paolo Carlini wrote:

Hi again,

On 08/26/2014 10:54 AM, Paolo Carlini wrote:

Hi,

On 08/26/2014 10:52 AM, Jonathan Wakely wrote:

That seems like a good idea, but I'm not convinced there's any benefit
in Ed's changes to do:

-#if __cplusplus  201103L
+#if __cplusplus = 201402L

It seems like unnecessary churn to me,

about this, I had the same thought ;)
By the way, in case isn't already clear, it occurs to me that the kind 
of change proposed by Ed, thus standardize on __cplusplus = required 
version, will make more sense when the C++17 Standard will be closer. 
So far, since we can simply do everything with only 201103L, my idea 
too of adding _GLIBCXX_CXX11  co seems quite pointless.


Paolo.

I understand.  I guess I was looking far ahead through the eyes of some 
new maintainer where we have CXX11, CXX14, CXX17, CXX20, ... and after 
the experimental names Cxx0x, Cxx1y had long lost their meaning and 
thinking that these dates and names would be a jumble. As new library 
components come into std:: proper we should look at straightening that 
out and standardizing on something.  For now, one date works well.


The new libraries are safely tucked away in experimental behind
#if __cplusplus = 201103L
# include bits/c++14_warning.h
#else

*** Jonathan: filesystem uses:

#if __cplusplus  201103L
# include bits/c++0x_warning.h
#else
and should probably eventually be like the others.

Ed




[PING 2, PATCH C++] - SD-6 Implementation Part N/4.

2014-09-25 Thread Ed Smith-Rowland

*PING*

I would like review of my SD-6 implementation.

Part 1 - __has_include__ built-in in libcpp.
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00083.html

Part 2 - __has_include macro and C++ language feature macros.
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00084.html

Part 3 - libstdc++ library macros was already approved by Jonathan. 
Thank you.

https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00085.html
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00110.html

Part 4 - C++ front end tests.
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00553.html

These build and test cleanly on x86_64-linux.

Part 5 - __has_cpp_attribute and supporting machinery is proving more 
interesting than I thought.

But the rest should be put in.

Thank you,
Ed Smith-Rowland



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


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 }


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][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: [C++-11] User defined literals

2011-10-09 Thread Ed Smith-Rowland

On 10/08/2011 07:15 PM, Jason Merrill wrote:

On 10/08/2011 07:25 PM, Ed Smith-Rowland wrote:

Also, In spite of the documentation cp_parser_template_parameter_list
returns a TREE_VEC not a TREE_LIST. This happens inside
end_template_parm_list called inside the former. So parameter_list is a
TREE_VEC, parm_list is a TREE_LIST, parm is a PARM_DECL, etc.


Ah, I was thinking of template arguments rather than parameters.  
You're right, except that INNERMOST_TEMPLATE_PARMS should be just 
TREE_VALUE; you are already starting from the innermost parm list if 
you use what end_template_parm_list returns.


Though it occurs to me that push_template_decl_real might be a better 
place for this check.



I'm still looking for a fix for duplicate errors/warnings coming from
cp_parser_operator. I tried cp_parser_error and lost the errors. I'll
look for different code paths for the two invocations and see if I can
either move something up or see if something is set differently between
the two that would be useful for a flag.


One approach would be changing the token stream after the first error 
to something that won't produce another error, e.g. changing 
token-u.value to be an empty string after you complain about it being 
non-empty.

Interesting.  That one error is the one of the three that does *not* repeat.
One idea.  the fist error about non-empty string is followed by a 
consume_token (for the string).
Does cp_parser_identifier (parser) *not* consume the identifier token?  
Is that token left on the stream for  second pass?

I'll try it and get back.


Jason





Re: [C++-11] User defined literals

2011-10-11 Thread Ed Smith-Rowland

On 10/11/2011 12:57 PM, Jason Merrill wrote:

On 10/11/2011 12:55 PM, Jason Merrill wrote:

On 10/09/2011 07:19 PM, Ed Smith-Rowland wrote:

Does cp_parser_identifier (parser) *not* consume the identifier token?


I'm pretty sure it does.

It does.


Does it work to only complain if !cp_parser_parsing_tentatively?


I suppose not, if you got no complaints with cp_parser_error.

Jason


cp_parser_operator(function_id) is simply run twice in 
cp_parser_unqualified_id.

Once inside cp_parser_template_id called at parser.c:4515.
Once directly inside cp_parser_unqualified_id at parser.c:4525.

cp_parser_template_id never succeeds with literal operator templates.  I 
find that curious.  But I haven't looked real hard and the things do get 
parsed somehow.




Re: [v3] tr2: bool_set, dynamic_bitset, ratio

2011-10-19 Thread Ed Smith-Rowland

On 10/19/2011 06:48 PM, Benjamin Kosnik wrote:

Hi Edward!

I have reviewed and selectively merged your development
branch, libstdcxx-tr2-ideas-branch, into trunk. As ISO C++ is now
looking at new library efforts for TR2 (and N2965 has already been
checked in to trunk) I thought it well-timed.

Please check my work, patch attached.

On  libstdcxx-tr2-ideas-branch, I found:

1) N1718 + extensions for polynomial.
2) N2136 bool_set
3) N2050 dynamic_bitset
4) ratio extensions for binary
5) cmath extensions
6) C++0x rope

Of these, I selected 2, 3, and 4 for merging.

It is sad to leave N1718 unmerged, I think there is a lot of good work
here and frankly see N1744 (marked with open status for LWG) as a weaker
candidate. But it's hard for me to justify putting this in given that it
was explicitly rejected by LWG. Perhaps you have current status or
thoughts?

For the rope extensions, I would suggest just adding C++0x bits to
ext/rope, instead of making tr2/rope.

Thecmath  additions look interesting but I just saw declarations and
no actual implementation so I punted.

I would encourage you to continue working on TR2 projects! This
future work can now proceed on mainline, without a special branch.

tested x86_64/linux

-benjamin








Wow!  Thank you for putting these in!  I was going to take a look at 
these during 4.8 but this is a nice surprise!


The ones I'd most like to look at are real and integer.  Stroustrup and 
others have often expressed a wish for multiprecision maths in the 
library wish list.  I don't know if there is a paper yet.  I also did 
rational using the gmp library.  I'm wondering if rational should be a 
template class that could take any integral type - of which integer 
could be one - like boost rational.  I think I like that solution 
better.  I was also debating if we should make these multiprecision 
classes allocator aware.  I tend to think so.


Anyway, I'll take a look at the tr2 stuff that you checked in.  I hadn't 
considered constexpr, nullptr, noexcept because they weren't in place in 
g++ when I did all this.


Also, with ratio and typelist we might be able to get units pretty 
easily (although I haven't looked at it).  That would be really cool.


Thanks,
Ed



Re: [C++-11] User defined literals

2011-10-23 Thread Ed Smith-Rowland

On 10/21/2011 05:20 PM, Jason Merrill wrote:

I think we're down to minor cosmetic issues:

On 10/21/2011 03:55 PM, Tom Tromey wrote:

There are a few spots like this that are missing a space before an open
paren.



+  if (DECL_LANGUAGE(decl) == lang_c)


Another one.


-  if (warn_cxx0x_compat
-  C_RID_CODE (token-u.value) = RID_FIRST_CXX0X
-  C_RID_CODE (token-u.value) = RID_LAST_CXX0X)



This code doesn't seem to have actually changed, so let's not adjust 
its whitespace.



+  /* Fill in PARMVEC with all of the parameters.  */
+  parmvec = make_tree_vec (len);


Let's call it 'charvec'; the characters are template arguments, not 
parameters.


+/* Parse a user-defined numeric constant.  returns a call to a 
user-defined

+   literal operator.  */
+static tree
+cp_parser_userdef_numeric_literal (cp_parser *parser)


Add a blank line between comment and function.

While looking at the embedded string issue I found that if you apply 
the suffix of a raw literal to a string it errors as it should but 
the error complained that there were too many arguments for the 
function.  This was not helpful so I made a nicer error message.



+  if (result == error_mark_node)
+error (invalid string literal prefix %\%s\% for user-defined
+   raw literal operator %qD, TREE_STRING_POINTER (value), 
name);


I think that we want a combination of the two errors; the new error 
doesn't help the user to fix their code as much.  It should remind 
them that for a string literal the function is called with a length 
argument as well.


Concerning this error, the only way to get here is to mis-use a raw 
literal operator by giving it a quoted string.  The prefix must be 
interpretable as a number of some kind.  I think I'll tell the user to 
drop the quotes.
The length of a string literal is supplied implicitly by the compiler to 
a string literal operator when a string user defined literal is 
encountered.  The user doesn't explicitly call the operator (not here 
anyway).


+   error (literal operator template %qD has invalid parameter 
list,

+  decl);


Similarly, this message should say that the parameter list needs to be 
char...




+
+/* Return true if a user-defined literal operator is a raw 
operator.  */

+


We don't need the extra newline before the comment.

Should be ready to go with these tweaks.

Jason


I've made these corrections.  They'll be in the next patch.

Unfortunately, as I was testing raw operators on very long strings I 
observed two things:
1. A bad error - the argument to a raw literal operator must be a 
null-terminated string.
2. If a very long number is given as the prefix to a numeric literal, a 
warning is issued (integer constant is too large for its type)
If the receiving operator is either the raw operator or the operator 
template then this should not be given.  I anticipate people might like 
to have multi-precision numbers someday, for example.


Before I release another patch I have to fix 1.  The warning might be 
fixed in-tree if that's OK.


Ed



  1   2   3   4   >