[Patch, fortran] PR77703 - [7/8/9 Regression] ICE on assignment to pointer function

2018-12-23 Thread Paul Richard Thomas
I will apply this as 'obvious' this evening, unless there are
objections. The patch is entirely self-explanatory.

Paul

2018-12-23  Paul Thomas  

PR fortran/77703
* resolve.c (get_temp_from_expr): Use the string length of
constant character expressions.

2018-12-23  Paul Thomas  

PR fortran/77703
* gfortran.dg/ptr_func_assign_5.f08 : New test.
Index: gcc/fortran/resolve.c
===
*** gcc/fortran/resolve.c	(revision 267336)
--- gcc/fortran/resolve.c	(working copy)
*** get_temp_from_expr (gfc_expr *e, gfc_nam
*** 10637,10642 
--- 10637,10647 
gfc_get_sym_tree (name, ns, &tmp, false);
gfc_add_type (tmp->n.sym, &e->ts, NULL);
  
+   if (e->expr_type == EXPR_CONSTANT && e->ts.type == BT_CHARACTER)
+ tmp->n.sym->ts.u.cl->length = gfc_get_int_expr (gfc_charlen_int_kind,
+ 		NULL,
+ 		e->value.character.length);
+ 
as = NULL;
ref = NULL;
aref = NULL;
Index: gcc/testsuite/gfortran.dg/ptr_func_assign_5.f08
===
*** gcc/testsuite/gfortran.dg/ptr_func_assign_5.f08	(nonexistent)
--- gcc/testsuite/gfortran.dg/ptr_func_assign_5.f08	(working copy)
***
*** 0 
--- 1,45 
+ ! { dg-do run }
+ !
+ ! Test the fix for PR77703, in which calls of the pointer function
+ ! caused an ICE in 'gfc_trans_auto_character_variable'.
+ !
+ ! Contributed by Gerhard Steinmetz  
+ !
+ module m
+implicit none
+private
+integer, parameter, public :: n = 2
+integer, parameter :: ell = 6
+ 
+character(len=n*ell), target, public :: s
+ 
+public :: t
+ contains
+function t( idx ) result( substr )
+   integer, intent(in) :: idx
+   character(len=ell), pointer  :: substr
+ 
+   if ( (idx < 0).or.(idx > n) ) then
+  error stop
+   end if
+   substr => s((idx-1)*ell+1:idx*ell)
+end function t
+ end module m
+ 
+ program p
+use m, only : s, t, n
+integer :: i
+ 
+! Define 's'
+s = "123456789012"
+ 
+! Then perform operations involving 't'
+if (t(1) .ne. "123456") stop 1
+if (t(2) .ne. "789012") stop 2
+ 
+! Do the pointer function assignments
+t(1) = "Hello "
+if (s .ne. "Hello 789012") Stop 3
+t(2) = "World!"
+if (s .ne. "Hello World!") Stop 4
+ end program p


[PATCH, committed] Enable ident for X86 Darwin.

2018-12-23 Thread Iain Sandoe
Hi,

The c-c++-common tests fail (or XPASS depending on which) on Darwin
because it doesn't currently emit .ident marker.  For X86 Darwin, this
is a trivial oversight; the assembler supports the directive.  We can
therefore use the default target hook there.

I applied the following as obvious,

Iain

2018-12-23  Iain Sandoe  

gcc/

* config/i386/darwin.h (TARGET_ASM_OUTPUT_IDENT): New.

diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index 53789e7c23..f760218bda 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -219,6 +219,11 @@ extern int darwin_emit_branch_islands;
 }  \
 } while (0)
 
+/* Darwin x86 assemblers support the .ident directive.  */
+
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
+
 /* Darwin profiling -- call mcount.  */
 #undef FUNCTION_PROFILER
 #define FUNCTION_PROFILER(FILE, LABELNO)   \
-- 
2.17.1




Re: [ping] Change static chain to r11 on aarch64

2018-12-23 Thread Olivier Hainque
Hi Wilco,


> On 21 Dec 2018, at 19:02, Wilco Dijkstra  wrote:
> 
> Remember these are just temporaries for use in the prolog and epilog -
> there is no need to save/restore the static base. Setting static chain
> to x9 and the temporaries to x10/x11 is the simplest solution. We
> can separately look at why the prolog uses more than a single
> temporary.

Ok, I'm happy to test that :-)

With local adjustments to libffi for starters.

Thanks for your feedback!




[PATCH] Don't run ident tests on powerpc-darwin

2018-12-23 Thread Iain Sandoe
Hi

The c-c++-common tests fail (or XPASS depending on which) on Darwin
because it doesn't currently emit .ident marker. 

For powerpc darwin (and, I think, AIX - hence copying David), there’s no
.ident support in the assembler, and we need to skip the tests.

In this case, I suggest that it’s not worth having a target-supports entry.
This is because what a target chooses to emit for -fident is controlled by
a target hook and therefore there’s no guarantee that a target-supports
that triggers off “ .ident” in the asm would be generically useful.

OTOH, if the testsuite maintainers prefer a support .. it can be done ;-)

OK for trunk?
Iain

gcc/testsuite/

* c-c++-common/ident-0a.c: Skip for powerpc-darwin.
* c-c++-common/ident-0b.c: Likewise.
* c-c++-common/ident-1a.c: Likewise.
* c-c++-common/ident-1b.c: Likewise.
* c-c++-common/ident-2a.c: Likewise.
* c-c++-common/ident-2b.c: Likewise.

diff --git a/gcc/testsuite/c-c++-common/ident-0a.c 
b/gcc/testsuite/c-c++-common/ident-0a.c
index 900d206bad..13bc6284de 100644
--- a/gcc/testsuite/c-c++-common/ident-0a.c
+++ b/gcc/testsuite/c-c++-common/ident-0a.c
@@ -1,6 +1,7 @@
 /* PR testsuite/52665
  * Make sure scan-assembler-not turns off .ident  */
 /* { dg-do compile } */
+/* { dg-skip-if "no assembler .ident support" { powerpc*-*-darwin* } } */
 int i;
 
 /* { dg-final { scan-assembler-not "GCC: " } } */
diff --git a/gcc/testsuite/c-c++-common/ident-0b.c 
b/gcc/testsuite/c-c++-common/ident-0b.c
index e08126d2d2..1184f8ff1c 100644
--- a/gcc/testsuite/c-c++-common/ident-0b.c
+++ b/gcc/testsuite/c-c++-common/ident-0b.c
@@ -2,6 +2,7 @@
  * Make sure scan-assembler-not turns off .ident unless -fident in testcase */
 /* { dg-do compile } */
 /* { dg-options "-fident" } */
+/* { dg-skip-if "no assembler .ident support" { powerpc*-*-darwin* } } */
 int i;
 
 /* { dg-final { scan-assembler-not "GCC: " { xfail *-*-* } } } */
diff --git a/gcc/testsuite/c-c++-common/ident-1a.c 
b/gcc/testsuite/c-c++-common/ident-1a.c
index 867ee43fb2..b6003735ce 100644
--- a/gcc/testsuite/c-c++-common/ident-1a.c
+++ b/gcc/testsuite/c-c++-common/ident-1a.c
@@ -1,6 +1,7 @@
 /* PR testsuite/52665
  * Make sure scan-assembler turns off .ident  */
 /* { dg-do compile } */
+/* { dg-skip-if "no assembler .ident support" { powerpc*-*-darwin* } } */
 int i;
 
 /* { dg-final { scan-assembler "GCC: " { xfail *-*-* } } } */
diff --git a/gcc/testsuite/c-c++-common/ident-1b.c 
b/gcc/testsuite/c-c++-common/ident-1b.c
index 2431086d24..b0d88983f3 100644
--- a/gcc/testsuite/c-c++-common/ident-1b.c
+++ b/gcc/testsuite/c-c++-common/ident-1b.c
@@ -2,6 +2,7 @@
  * Make sure scan-assembler turns off .ident unless -fident in testcase */
 /* { dg-do compile } */
 /* { dg-options "-fident" } */
+/* { dg-skip-if "no assembler .ident support" { powerpc*-*-darwin* } } */
 int i;
 
 /* { dg-final { scan-assembler "GCC: " } } */
diff --git a/gcc/testsuite/c-c++-common/ident-2a.c 
b/gcc/testsuite/c-c++-common/ident-2a.c
index 131b867628..e9321c7292 100644
--- a/gcc/testsuite/c-c++-common/ident-2a.c
+++ b/gcc/testsuite/c-c++-common/ident-2a.c
@@ -1,6 +1,7 @@
 /* PR testsuite/52665
  * Make sure scan-assembler-times turns off .ident  */
 /* { dg-do compile } */
+/* { dg-skip-if "no assembler .ident support" { powerpc*-*-darwin* } } */
 int i;
 
 /* { dg-final { scan-assembler-times "GCC: " 0 } } */ /* internal test, keep 
-times 0 ! */
diff --git a/gcc/testsuite/c-c++-common/ident-2b.c 
b/gcc/testsuite/c-c++-common/ident-2b.c
index a21e25fcce..e057fac747 100644
--- a/gcc/testsuite/c-c++-common/ident-2b.c
+++ b/gcc/testsuite/c-c++-common/ident-2b.c
@@ -2,6 +2,7 @@
  * Make sure scan-assembler-times turns off .ident unless -fident in testcase 
*/
 /* { dg-do compile } */
 /* { dg-options "-fident" } */
+/* { dg-skip-if "no assembler .ident support" { powerpc*-*-darwin* } } */
 int ident;
 
 /* { dg-final { scan-assembler-times "GCC: " 1 } } */
-- 
2.17.1




[PATCH] Fix Ada bootstrap for Darwin9 and earlier.

2018-12-23 Thread Iain Sandoe
Hi,

This is a bootstrap regression on 7,8 and trunk for Ada on [X86 and PowerPC] 
Darwin9 (and earlier, although I don’t test much there).

Changes were made to __gnat_lwp_self to use a facility that’s only available 
from Darwin10 onwards.

The patch makes this conditional on the target Darwin version.

OK for trunk?
Open branches?

Iain

gcc/ada/

* adaint.c (__gnat_lwp_self): Ensure that the system interface used
is available on the target.

 gcc/ada/adaint.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 54a1d6e..0af8ca4 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -3174,9 +3174,13 @@ __gnat_lwp_self (void)
 #endif
 
 #if defined (__APPLE__)
-#include 
-#include 
-#include 
+# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
+#  include 
+#  include 
+#  include 
+# else
+#  include 
+# endif
 
 /* System-wide thread identifier.  Note it could be truncated on 32 bit
hosts.
@@ -3184,6 +3188,7 @@ __gnat_lwp_self (void)
 void *
 __gnat_lwp_self (void)
 {
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
   thread_identifier_info_data_t data;
   mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
   kern_return_t kret;
@@ -3194,6 +3199,9 @@ __gnat_lwp_self (void)
 return (void *)(uintptr_t)data.thread_id;
   else
 return 0;
+#else
+return (void *)pthread_mach_thread_np (pthread_self ());
+#endif
 }
 #endif
 
-- 
2.8.1




[PATCH, lto-wrapper] Don't pre-link the early-debug objects.

2018-12-23 Thread Iain Sandoe
Hi,

As there was some discussion of this on IRC - I believe that Honza might want 
this patch sooner, rather than later

I constructed it as part of the series to support LTO debug [PR 82005] on 
Darwin (it’s still needed there).

The patch has been reg-strapped on x86_64-darwin, x86_64-linux, powerpc-linux 
and AIX-7.2.

There are some small tidy-ups in this too, which can be split out (but posting 
what I tested, anyway).

OK for trunk?
thoughts?

Iain

* I don’t think to mention the PR for this patch alone - the simple object 
stuff needs to be included too.

gcc/

* lto-wrapper.c (tool_cleanup): Don’t report ficticious temp files.
(debug_objcopy): Improve temp filenames.  Append the early
debug objects to the outfiles.  Remove the phase prelinking the
early debug. Emit the early debug filenames for ld.

 gcc/lto-wrapper.c | 135 +-
 1 file changed, 50 insertions(+), 85 deletions(-)

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 90d8c1c7fb..15cf6edb5b 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -71,7 +71,8 @@ static char **output_names;
 static char **offload_names;
 static char *offload_objects_file_name;
 static char *makefile;
-static char *debug_obj;
+static unsigned int num_deb_objs;
+static const char **early_debug_object_names;
 
 const char tool_name[] = "lto-wrapper";
 
@@ -90,8 +91,10 @@ tool_cleanup (bool)
 maybe_unlink (offload_objects_file_name);
   if (makefile)
 maybe_unlink (makefile);
-  if (debug_obj)
-maybe_unlink (debug_obj);
+  if (early_debug_object_names)
+for (i = 0; i < num_deb_objs; ++i)
+  if (early_debug_object_names[i])
+   maybe_unlink (early_debug_object_names[i]);
   for (i = 0; i < nr; ++i)
 {
   maybe_unlink (input_names[i]);
@@ -1036,7 +1039,7 @@ find_and_merge_options (int fd, off_t file_offset, const 
char *prefix,
 const char *
 debug_objcopy (const char *infile, bool rename)
 {
-  const char *outfile;
+  char *outfile;
   const char *errmsg;
   int err;
 
@@ -1075,7 +1078,15 @@ debug_objcopy (const char *infile, bool rename)
   return NULL;
 }
 
-  outfile = make_temp_file ("debugobjtem");
+  if (save_temps)
+{
+  outfile = (char *) xmalloc (strlen (infile)
+ + sizeof (".debug.temp.o") + 1);
+  strcpy (outfile, infile);
+  strcat (outfile, ".debug.temp.o");
+}
+  else
+outfile = make_temp_file (".debug.temp.o");
   errmsg = simple_object_copy_lto_debug_sections (inobj, outfile, &err, 
rename);
   if (errmsg)
 {
@@ -1412,9 +1423,16 @@ cont1:
 
   if (lto_mode == LTO_MODE_LTO)
 {
-  flto_out = make_temp_file (".lto.o");
   if (linker_output)
-   obstack_ptr_grow (&argv_obstack, linker_output);
+   {
+ obstack_ptr_grow (&argv_obstack, linker_output);
+ flto_out = (char *) xmalloc (strlen (linker_output)
+  + sizeof (".lto.o") + 1);
+ strcpy (flto_out, linker_output);
+ strcat (flto_out, ".lto.o");
+   }
+  else
+   flto_out = make_temp_file (".lto.o");
   obstack_ptr_grow (&argv_obstack, "-o");
   obstack_ptr_grow (&argv_obstack, flto_out);
 }
@@ -1487,95 +1505,39 @@ cont1:
   argv_ptr = &new_argv[new_head_argc];
   fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true);
 
-  /* Handle early generated debug information.  At compile-time
- we output early DWARF debug info into .gnu.debuglto_ prefixed
- sections.  LTRANS object DWARF debug info refers to that.
- So we need to transfer the .gnu.debuglto_ sections to the final
- link.  Ideally the linker plugin interface would allow us to
- not claim those sections and instruct the linker to keep
- them, renaming them in the process.  For now we extract and
- rename those sections via a simple-object interface to produce
- regular objects containing only the early debug info.  We
- then partially link those to a single early debug info object
- and pass that as additional output back to the linker plugin.  */
-
-  /* Prepare the partial link to gather the compile-time generated
- debug-info into a single input for the final link.  */
-  debug_obj = make_temp_file ("debugobj");
-  obstack_ptr_grow (&argv_obstack, collect_gcc);
-  for (i = 1; i < decoded_options_count; ++i)
-{
-  /* Retain linker choice and -B.  */
-  if (decoded_options[i].opt_index == OPT_B
- || decoded_options[i].opt_index == OPT_fuse_ld_bfd
- || decoded_options[i].opt_index == OPT_fuse_ld_gold)
-   append_linker_options (&argv_obstack, &decoded_options[i-1], 2);
-  /* Retain all target options, this preserves -m32 for example.  */
-  if (cl_options[decoded_options[i].opt_index].flags & CL_TARGET)
-   append_linker_options (&argv_obstack, &decoded_options[i-1], 2);
-  /* Recognize -g0.  */
-  if (decoded_options[i].opt_index == OPT_g
-

[PATCH, Darwin, config] Check for DWARF debug line support with otool.

2018-12-23 Thread Iain Sandoe
Hi,

This corrects a long-standing misconfiguration for Darwin.
The assembler supports the “.file” and “.loc” directives, but
the GCC configury was not detecting this because it was 
using objdump, which does not exist on most Darwin installations.

We added support for “otool” to GCC and now we can use that to
make the check that’s done with objdump on ELF targets.

OK for trunk?
Iain

gcc/

* configure.ac (dwarf2_debug_line): Check for the debug_line
section using otool when there’s no objdump available.
* configure: Regenerate.

diff --git a/gcc/configure.ac b/gcc/configure.ac
index 7fce52a319..a101232589 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4926,6 +4926,10 @@ if test x"$insn" != x; then
&& $gcc_cv_objdump -h conftest.o 2> /dev/null \
   | grep debug_line > /dev/null 2>&1; then
  gcc_cv_as_dwarf2_debug_line=yes
+   elif test x$gcc_cv_otool != x \
+   && $gcc_cv_otool -l conftest.o 2> /dev/null \
+  | grep debug_line > /dev/null 2>&1; then
+ gcc_cv_as_dwarf2_debug_line=yes
fi])
 
 # The .debug_line file table must be in the exact order that
-- 
2.17.1




Re: [PATCH, lto-wrapper] Don't pre-link the early-debug objects.

2018-12-23 Thread Richard Biener
On December 23, 2018 12:41:04 PM GMT+01:00, Iain Sandoe  
wrote:
>Hi,
>
>As there was some discussion of this on IRC - I believe that Honza
>might want this patch sooner, rather than later
>
>I constructed it as part of the series to support LTO debug [PR 82005]
>on Darwin (it’s still needed there).
>
>The patch has been reg-strapped on x86_64-darwin, x86_64-linux,
>powerpc-linux and AIX-7.2.
>
>There are some small tidy-ups in this too, which can be split out (but
>posting what I tested, anyway).
>
>OK for trunk?

OK. 

Richard. 

>thoughts?
>
>Iain
>
>* I don’t think to mention the PR for this patch alone - the simple
>object stuff needs to be included too.
>
>gcc/
>
>   * lto-wrapper.c (tool_cleanup): Don’t report ficticious temp files.
>   (debug_objcopy): Improve temp filenames.  Append the early
>   debug objects to the outfiles.  Remove the phase prelinking the
>   early debug. Emit the early debug filenames for ld.
>
> gcc/lto-wrapper.c | 135 +-
> 1 file changed, 50 insertions(+), 85 deletions(-)
>
>diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
>index 90d8c1c7fb..15cf6edb5b 100644
>--- a/gcc/lto-wrapper.c
>+++ b/gcc/lto-wrapper.c
>@@ -71,7 +71,8 @@ static char **output_names;
> static char **offload_names;
> static char *offload_objects_file_name;
> static char *makefile;
>-static char *debug_obj;
>+static unsigned int num_deb_objs;
>+static const char **early_debug_object_names;
> 
> const char tool_name[] = "lto-wrapper";
> 
>@@ -90,8 +91,10 @@ tool_cleanup (bool)
> maybe_unlink (offload_objects_file_name);
>   if (makefile)
> maybe_unlink (makefile);
>-  if (debug_obj)
>-maybe_unlink (debug_obj);
>+  if (early_debug_object_names)
>+for (i = 0; i < num_deb_objs; ++i)
>+  if (early_debug_object_names[i])
>+  maybe_unlink (early_debug_object_names[i]);
>   for (i = 0; i < nr; ++i)
> {
>   maybe_unlink (input_names[i]);
>@@ -1036,7 +1039,7 @@ find_and_merge_options (int fd, off_t
>file_offset, const char *prefix,
> const char *
> debug_objcopy (const char *infile, bool rename)
> {
>-  const char *outfile;
>+  char *outfile;
>   const char *errmsg;
>   int err;
> 
>@@ -1075,7 +1078,15 @@ debug_objcopy (const char *infile, bool rename)
>   return NULL;
> }
> 
>-  outfile = make_temp_file ("debugobjtem");
>+  if (save_temps)
>+{
>+  outfile = (char *) xmalloc (strlen (infile)
>++ sizeof (".debug.temp.o") + 1);
>+  strcpy (outfile, infile);
>+  strcat (outfile, ".debug.temp.o");
>+}
>+  else
>+outfile = make_temp_file (".debug.temp.o");
>errmsg = simple_object_copy_lto_debug_sections (inobj, outfile, &err,
>rename);
>   if (errmsg)
> {
>@@ -1412,9 +1423,16 @@ cont1:
> 
>   if (lto_mode == LTO_MODE_LTO)
> {
>-  flto_out = make_temp_file (".lto.o");
>   if (linker_output)
>-  obstack_ptr_grow (&argv_obstack, linker_output);
>+  {
>+obstack_ptr_grow (&argv_obstack, linker_output);
>+flto_out = (char *) xmalloc (strlen (linker_output)
>+ + sizeof (".lto.o") + 1);
>+strcpy (flto_out, linker_output);
>+strcat (flto_out, ".lto.o");
>+  }
>+  else
>+  flto_out = make_temp_file (".lto.o");
>   obstack_ptr_grow (&argv_obstack, "-o");
>   obstack_ptr_grow (&argv_obstack, flto_out);
> }
>@@ -1487,95 +1505,39 @@ cont1:
>   argv_ptr = &new_argv[new_head_argc];
>   fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true);
> 
>-  /* Handle early generated debug information.  At compile-time
>- we output early DWARF debug info into .gnu.debuglto_ prefixed
>- sections.  LTRANS object DWARF debug info refers to that.
>- So we need to transfer the .gnu.debuglto_ sections to the final
>- link.  Ideally the linker plugin interface would allow us to
>- not claim those sections and instruct the linker to keep
>- them, renaming them in the process.  For now we extract and
>- rename those sections via a simple-object interface to produce
>- regular objects containing only the early debug info.  We
>- then partially link those to a single early debug info object
>- and pass that as additional output back to the linker plugin.  */
>-
>-  /* Prepare the partial link to gather the compile-time generated
>- debug-info into a single input for the final link.  */
>-  debug_obj = make_temp_file ("debugobj");
>-  obstack_ptr_grow (&argv_obstack, collect_gcc);
>-  for (i = 1; i < decoded_options_count; ++i)
>-{
>-  /* Retain linker choice and -B.  */
>-  if (decoded_options[i].opt_index == OPT_B
>-|| decoded_options[i].opt_index == OPT_fuse_ld_bfd
>-|| decoded_options[i].opt_index == OPT_fuse_ld_gold)
>-  append_linker_options (&argv_obstack, &decoded_options[i-1], 2);
>-  /* Retain all target options, this preserves -m32 for example. 
>*/
>-  if (cl_options[decoded_options[i]

Re: [PATCH] Fix Ada bootstrap for Darwin9 and earlier.

2018-12-23 Thread Eric Botcazou
>   * adaint.c (__gnat_lwp_self): Ensure that the system interface used
>   is available on the target.

OK for all active branches, modulo the couple of following nits:

The ChangeLog must make it clear that this is for Darwin only:

* adaint.c [__APPLE__] (__gnat_lwp_self): Ensure that the system
interface used is available on the target.

> +#else
> +return (void *)pthread_mach_thread_np (pthread_self ());
> +#endif

Wrong indentation.

-- 
Eric Botcazou


[PATCH, Darwin] Fix PR67974.

2018-12-23 Thread Iain Sandoe
Hi,

The PR is about a set of tests that were not executed because of
missing asm support.  

However, the assembler can handle the insns now, so the tests are
attempted (but with a missing asm shim they fail).

This adds the shim.

In principle (bugs notwithstanding) Darwin’s x86_64 ABI is supposed
to follow the sysv psABI so we can have essentially a copy of the
Linux one.

This is needed on all open branches.

OK for trunk?
branches?

thanks
Iain

gcc/testsuite/

PR testsuite/67974
* gcc.target/x86_64/abi/avx/asm-support-darwin.s: New.


 .../x86_64/abi/avx/asm-support-darwin.s   | 77 +++
 1 file changed, 77 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/x86_64/abi/avx/asm-support-darwin.s

diff --git a/gcc/testsuite/gcc.target/x86_64/abi/avx/asm-support-darwin.s 
b/gcc/testsuite/gcc.target/x86_64/abi/avx/asm-support-darwin.s
new file mode 100644
index 00..c070d65034
--- /dev/null
+++ b/gcc/testsuite/gcc.target/x86_64/abi/avx/asm-support-darwin.s
@@ -0,0 +1,77 @@
+   .file   "asm-support-darwin.s"
+   .text
+   .p2align 4,,15
+   .globl _snapshot
+_snapshot:
+LFB3:
+   movq%rax, _rax(%rip)
+   movq%rbx, _rbx(%rip)
+   movq%rcx, _rcx(%rip)
+   movq%rdx, _rdx(%rip)
+   movq%rdi, _rdi(%rip)
+   movq%rsi, _rsi(%rip)
+   movq%rbp, _rbp(%rip)
+   movq%rsp, _rsp(%rip)
+   movq%r8, _r8(%rip)
+   movq%r9, _r9(%rip)
+   movq%r10, _r10(%rip)
+   movq%r11, _r11(%rip)
+   movq%r12, _r12(%rip)
+   movq%r13, _r13(%rip)
+   movq%r14, _r14(%rip)
+   movq%r15, _r15(%rip)
+   vmovdqu %ymm0, _ymm_regs+0(%rip)
+   vmovdqu %ymm1, _ymm_regs+32(%rip)
+   vmovdqu %ymm2, _ymm_regs+64(%rip)
+   vmovdqu %ymm3, _ymm_regs+96(%rip)
+   vmovdqu %ymm4, _ymm_regs+128(%rip)
+   vmovdqu %ymm5, _ymm_regs+160(%rip)
+   vmovdqu %ymm6, _ymm_regs+192(%rip)
+   vmovdqu %ymm7, _ymm_regs+224(%rip)
+   vmovdqu %ymm8, _ymm_regs+256(%rip)
+   vmovdqu %ymm9, _ymm_regs+288(%rip)
+   vmovdqu %ymm10, _ymm_regs+320(%rip)
+   vmovdqu %ymm11, _ymm_regs+352(%rip)
+   vmovdqu %ymm12, _ymm_regs+384(%rip)
+   vmovdqu %ymm13, _ymm_regs+416(%rip)
+   vmovdqu %ymm14, _ymm_regs+448(%rip)
+   vmovdqu %ymm15, _ymm_regs+480(%rip)
+   jmp *_callthis(%rip)
+LFE3:
+   .p2align 4,,15
+   .globl _snapshot_ret
+_snapshot_ret:
+   movq%rdi, _rdi(%rip)
+   subq$8, %rsp
+   call*_callthis(%rip)
+   addq$8, %rsp
+   movq%rax, _rax(%rip)
+   movq%rdx, _rdx(%rip)
+   vmovdqu %ymm0, _ymm_regs+0(%rip)
+   vmovdqu %ymm1, _ymm_regs+32(%rip)
+   fstpt   _x87_regs(%rip)
+   fstpt   _x87_regs+16(%rip)
+   fldt_x87_regs+16(%rip)
+   fldt_x87_regs(%rip)
+   ret
+
+   .comm   _callthis,8,3
+   .comm   _rax,8,3
+   .comm   _rbx,8,3
+   .comm   _rcx,8,3
+   .comm   _rdx,8,3
+   .comm   _rsi,8,3
+   .comm   _rdi,8,3
+   .comm   _rsp,8,3
+   .comm   _rbp,8,3
+   .comm   _r8,8,3
+   .comm   _r9,8,3
+   .comm   _r10,8,3
+   .comm   _r11,8,3
+   .comm   _r12,8,3
+   .comm   _r13,8,3
+   .comm   _r14,8,3
+   .comm   _r15,8,3
+   .comm   _ymm_regs,512,5
+   .comm   _x87_regs,128,5
+   .comm   _volatile_var,8,3
-- 
2.17.1





[committed] Cleanup structure initialization in preparation for fixing string length range computations

2018-12-23 Thread Jeff Law

So I'm working to break down and resubmit Martin's work to fix the
over-aggressive string length range computations.  There's a fair amount
of cleanup and other non-behavorial changes in that work.

There's two paths we could take.  One would be to drop all the
non-behavorial changes and reduce the patch down to just the fixes.
Sometimes this is my preferred route, but not this time.

With Martin out, I want the end result to look at much like his work as
possible to avoid introducing errors.  So culling out the non-behavorial
stuff will make comparing the end result to Martin's patch from Nov
essentially impossible.  Additionally, the non-behaviorial changes are
generally things we want to fix anyway.

So instead I'm going to break out the non-behavorial stuff, get it
installed, give the testers a day to build them (beyond my own standard
bootstrap/regression testing).  Then I'll work my way into the meat of
Martin's fixes.

Sooo..

This is the first of the non-behaviorial changes from Martin.  When I
introduced c_strlen_data to make our API more easily extendable, I used
memset for the structure initialization.  Using empty brace
initialization just seems cleaner.  I originally considered it, but got
it in my head that it wasn't supported in some case.  Maybe I was stuck
in a C mentality rather than C++.. :-)

This patch extracts Martin's work to convert the existing memset calls
in this space to instead use empty brace initialization.

None of these changes should affect the behavior of the resultant
compiler.  Bootstrapped and regression tested on x86_64.  Installing on
the trunk.  My tester will pick this up over the next 24hrs.

Committed to the trunk.


Jeff

commit 6f2fa95d8a2b62ffccddd23c6b04cef26b612d2a
Author: Jeff Law 
Date:   Fri Dec 21 16:55:19 2018 -0700

2018-12-23  Martin Sebor  
Jeff Law  

* builtins.c (unterminated_array): Use empty brace initialization
for c_strlen_data.
(c_strlen, expand_builtin_strnlen): Likewise.
(expand_builtin_stpcpy_1, fold_builtin_strlen): Likewise.
* gimple-fold.c (get_range_strlen): Likewise.
(gimple_fold_builtin_stpcpy): Likewise.
* gimple-ssa-sprintf.c (get_string_length): Likewise.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c15a1a43e6c..a63e7745536 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2018-12-23  Martin Sebor  
+   Jeff Law  
+
+   * builtins.c (unterminated_array): Use empty brace initialization
+   for c_strlen_data.
+   (c_strlen, expand_builtin_strnlen): Likewise.
+   (expand_builtin_stpcpy_1, fold_builtin_strlen): Likewise.
+   * gimple-fold.c (get_range_strlen): Likewise.
+   (gimple_fold_builtin_stpcpy): Likewise.
+   * gimple-ssa-sprintf.c (get_string_length): Likewise.
+
 2018-12-23  Alan Modra  
 
PR 88346
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 669e548706f..4a82f58d5f4 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -575,8 +575,7 @@ unterminated_array (tree exp, tree *size /* = NULL */, bool 
*exact /* = NULL */)
 {
   /* C_STRLEN will return NULL and set DECL in the info
  structure if EXP references a unterminated array.  */
-  c_strlen_data data;
-  memset (&data, 0, sizeof (c_strlen_data));
+  c_strlen_data data = { };
   tree len = c_strlen (exp, 1, &data);
   if (len == NULL_TREE && data.len && data.decl)
  {
@@ -647,8 +646,7 @@ c_strlen (tree src, int only_value, c_strlen_data *data, 
unsigned eltsize)
   /* If we were not passed a DATA pointer, then get one to a local
  structure.  That avoids having to check DATA for NULL before
  each time we want to use it.  */
-  c_strlen_data local_strlen_data;
-  memset (&local_strlen_data, 0, sizeof (c_strlen_data));
+  c_strlen_data local_strlen_data = { };
   if (!data)
 data = &local_strlen_data;
 
@@ -3085,8 +3083,7 @@ expand_builtin_strnlen (tree exp, rtx target, 
machine_mode target_mode)
 
   /* FIXME: Change c_strlen() to return sizetype instead of ssizetype
  so these conversions aren't necessary.  */
-  c_strlen_data data;
-  memset (&data, 0, sizeof (c_strlen_data));
+  c_strlen_data data { };
   tree len = c_strlen (src, 0, &data, 1);
   if (len)
 len = fold_convert_loc (loc, TREE_TYPE (bound), len);
@@ -4086,8 +4083,7 @@ expand_builtin_stpcpy_1 (tree exp, rtx target, 
machine_mode mode)
 compile-time, not an expression containing a string.  This is
 because the latter will potentially produce pessimized code
 when used to produce the return value.  */
-  c_strlen_data data;
-  memset (&data, 0, sizeof (c_strlen_data));
+  c_strlen_data data = { };
   if (!c_getstr (src, NULL)
  || !(len = c_strlen (src, 0, &data, 1)))
return expand_movstr (dst, src, target,
@@ -8571,8 +8567,7 @@ fold_builtin_strlen (location_t loc, tree type, tree arg)
 return NULL_TREE;
   else
 {
-  c_strlen_data data;
-   

[committed] Cleanup variable names and comments in preparation for fixing string length computations

2018-12-23 Thread Jeff Law

In a variety of instances Martin changed some variable names to be more
descriptive or avoid shadowing problems.  I've pulled those changes into
a distinct patch to cut down on the noise in the meat of the patch.

Bootstrapped and regression tested on x86_64-linux-gnu.  My tester will
spin this on the other targets overnight.

Installing on the trunk.

jeff
commit 10098590534b40db6929c59f195559b5417f1e06
Author: Jeff Law 
Date:   Fri Dec 21 10:30:57 2018 -0500

* builtins.c (unterminated_array): Rename "data" to "lendata".  Fix
a few comments.
(expand_builtin_strnlen, expand_builtin_stpcpy_1): Likewise.
(fold_builtin_strlen): Likewise.
* gimple-fold.c (get_range_strlen): Likewise.  Also rename a couple
instances of "type" to "optype" and "arg" to "fld".

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a63e7745536..f1f9d70f25b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,13 @@
 2018-12-23  Martin Sebor  
Jeff Law  
 
+   * builtins.c (unterminated_array): Rename "data" to "lendata".  Fix
+   a few comments.
+   (expand_builtin_strnlen, expand_builtin_stpcpy_1): Likewise.
+   (fold_builtin_strlen): Likewise.
+   * gimple-fold.c (get_range_strlen): Likewise.  Also rename a couple
+   instances of "type" to "optype" and "arg" to "fld".
+
* builtins.c (unterminated_array): Use empty brace initialization
for c_strlen_data.
(c_strlen, expand_builtin_strnlen): Likewise.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 4a82f58d5f4..0eb3df9ccc1 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -575,25 +575,25 @@ unterminated_array (tree exp, tree *size /* = NULL */, 
bool *exact /* = NULL */)
 {
   /* C_STRLEN will return NULL and set DECL in the info
  structure if EXP references a unterminated array.  */
-  c_strlen_data data = { };
-  tree len = c_strlen (exp, 1, &data);
-  if (len == NULL_TREE && data.len && data.decl)
+  c_strlen_data lendata = { };
+  tree len = c_strlen (exp, 1, &lendata);
+  if (len == NULL_TREE && lendata.len && lendata.decl)
  {
if (size)
{
- len = data.len;
- if (data.off)
+ len = lendata.len;
+ if (lendata.off)
{
- /* Constant offsets are already accounted for in data.len, but
-not in a SSA_NAME + CST expression.  */
- if (TREE_CODE (data.off) == INTEGER_CST)
+ /* Constant offsets are already accounted for in LENDATA.MINLEN,
+but not in a SSA_NAME + CST expression.  */
+ if (TREE_CODE (lendata.off) == INTEGER_CST)
*exact = true;
- else if (TREE_CODE (data.off) == PLUS_EXPR
-  && TREE_CODE (TREE_OPERAND (data.off, 1)) == INTEGER_CST)
+ else if (TREE_CODE (lendata.off) == PLUS_EXPR
+  && TREE_CODE (TREE_OPERAND (lendata.off, 1)) == 
INTEGER_CST)
{
  /* Subtract the offset from the size of the array.  */
  *exact = false;
- tree temp = TREE_OPERAND (data.off, 1);
+ tree temp = TREE_OPERAND (lendata.off, 1);
  temp = fold_convert (ssizetype, temp);
  len = fold_build2 (MINUS_EXPR, ssizetype, len, temp);
}
@@ -605,7 +605,7 @@ unterminated_array (tree exp, tree *size /* = NULL */, bool 
*exact /* = NULL */)
 
  *size = len;
}
-   return data.decl;
+   return lendata.decl;
  }
 
   return NULL_TREE;
@@ -3083,8 +3083,8 @@ expand_builtin_strnlen (tree exp, rtx target, 
machine_mode target_mode)
 
   /* FIXME: Change c_strlen() to return sizetype instead of ssizetype
  so these conversions aren't necessary.  */
-  c_strlen_data data { };
-  tree len = c_strlen (src, 0, &data, 1);
+  c_strlen_data lendata = { };
+  tree len = c_strlen (src, 0, &lendata, 1);
   if (len)
 len = fold_convert_loc (loc, TREE_TYPE (bound), len);
 
@@ -3106,12 +3106,12 @@ expand_builtin_strnlen (tree exp, rtx target, 
machine_mode target_mode)
   strnlen (&a[i], sizeof a)
 where the value of i is unknown.  Unless i's value is
 zero, the call is unsafe because the bound is greater. */
- data.decl = unterminated_array (src, &len, &exact);
- if (!data.decl)
+ lendata.decl = unterminated_array (src, &len, &exact);
+ if (!lendata.decl)
return NULL_RTX;
}
 
-  if (data.decl
+  if (lendata.decl
  && !TREE_NO_WARNING (exp)
  && ((tree_int_cst_lt (len, bound))
  || !exact))
@@ -3127,7 +3127,7 @@ expand_builtin_strnlen (tree exp, rtx target, 
machine_mode target_mode)
   "of at most %E of unterminated array"),
  exp, func, bound, len))
{
- inform (DECL_SOURCE_LOCATION (data.decl),
+ inform (

[committed] Add new fields to c_strlen_data structure, rename field access

2018-12-23 Thread Jeff Law

This is probably a good place to stop for today and let the testers
catch up.

This patch introduces new fields into the c_strlen_data structure.
They're mostly unused at this point.  The data structure shouldn't
change in subsequent patches.  The old "len" field accesses are changed
to "minlen" which allows the existing code to work with the new data
structure.

Bootstrapped and regression tested.  Installing on the trunk.

Jeff
commit 6f7fa01feb7087acd4e11d22efb3b1a4d966652d
Author: law 
Date:   Sun Dec 23 16:00:45 2018 +

* builtins.h (c_strlen_data): Add new fields and comments.
* builtins.c (unterminated_array): Change field reference from
"len" to "minlen" in c_strlen_data instance.
* gimple-fold.c (get_range_strlen): Likewise.
* gimple-ssa-sprintf.c (get_string_length): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267378 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f1f9d70f25b..cd2a294c583 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,12 @@
 2018-12-23  Martin Sebor  
Jeff Law  
 
+   * builtins.h (c_strlen_data): Add new fields and comments.
+   * builtins.c (unterminated_array): Change field reference from
+   "len" to "minlen" in c_strlen_data instance.
+   * gimple-fold.c (get_range_strlen): Likewise.
+   * gimple-ssa-sprintf.c (get_string_length): Likewise.
+
* builtins.c (unterminated_array): Rename "data" to "lendata".  Fix
a few comments.
(expand_builtin_strnlen, expand_builtin_stpcpy_1): Likewise.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 0eb3df9ccc1..b56577e450c 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -577,11 +577,11 @@ unterminated_array (tree exp, tree *size /* = NULL */, 
bool *exact /* = NULL */)
  structure if EXP references a unterminated array.  */
   c_strlen_data lendata = { };
   tree len = c_strlen (exp, 1, &lendata);
-  if (len == NULL_TREE && lendata.len && lendata.decl)
+  if (len == NULL_TREE && lendata.minlen && lendata.decl)
  {
if (size)
{
- len = lendata.len;
+ len = lendata.minlen;
  if (lendata.off)
{
  /* Constant offsets are already accounted for in LENDATA.MINLEN,
@@ -720,7 +720,7 @@ c_strlen (tree src, int only_value, c_strlen_data *data, 
unsigned eltsize)
{
  data->decl = decl;
  data->off = byteoff;
- data->len = ssize_int (len);
+ data->minlen = ssize_int (len);
  return NULL_TREE;
}
 
@@ -794,7 +794,7 @@ c_strlen (tree src, int only_value, c_strlen_data *data, 
unsigned eltsize)
 {
   data->decl = decl;
   data->off = byteoff;
-  data->len = ssize_int (len);
+  data->minlen = ssize_int (len);
   return NULL_TREE;
 }
 
diff --git a/gcc/builtins.h b/gcc/builtins.h
index cf4f9b1b264..472a86d9ad0 100644
--- a/gcc/builtins.h
+++ b/gcc/builtins.h
@@ -57,10 +57,48 @@ extern bool get_pointer_alignment_1 (tree, unsigned int *,
 unsigned HOST_WIDE_INT *);
 extern unsigned int get_pointer_alignment (tree);
 extern unsigned string_length (const void*, unsigned, unsigned);
+
 struct c_strlen_data
 {
+  /* [MINLEN, MAXBOUND, MAXLEN] is a range describing the length of
+ one or more strings of possibly unknown length.  For a single
+ string of known length the range is a constant where
+ MINLEN == MAXBOUND == MAXLEN holds.
+ For other strings, MINLEN is the length of the shortest known
+ string.  MAXBOUND is the length of a string that could be stored
+ in the largest array referenced by the expression.  MAXLEN is
+ the length of the longest sequence of non-zero bytes
+ in an object referenced by the expression.  For such strings,
+ MINLEN <= MAXBOUND <= MAXLEN holds.  For example, given:
+   struct A { char a[7], b[]; };
+   extern struct A *p;
+   n = strlen (p->a);
+ the computed range will be [0, 6, ALL_ONES].
+ However, for a conditional expression involving a string
+ of known length and an array of unknown bound such as
+   n = strlen (i ? p->b : "123");
+ the range will be [3, 3, ALL_ONES].
+ MINLEN != 0 && MAXLEN == ALL_ONES indicates that MINLEN is
+ the length of the shortest known string and implies that
+ the shortest possible string referenced by the expression may
+ actually be the empty string.  This distinction is useful for
+ diagnostics.  get_range_strlen() return value distinguishes
+ between these two cases.
+ As the tighter (and more optimistic) bound, MAXBOUND is suitable
+ for diagnostics but not for optimization.
+ As the more conservative bound, MAXLEN is intended to be used
+ for optimization.  */
+  tree minlen;
+  tree maxlen;
+  tree maxbound;
+  /* When non-null, NONSTR refers to the declaration known to store
+ an unterminated con

Re: [PATCH, Darwin] Fix PR67974.

2018-12-23 Thread Jeff Law
On 12/23/18 8:05 AM, Iain Sandoe wrote:
> Hi,
> 
> The PR is about a set of tests that were not executed because of
> missing asm support.  
> 
> However, the assembler can handle the insns now, so the tests are
> attempted (but with a missing asm shim they fail).
> 
> This adds the shim.
> 
> In principle (bugs notwithstanding) Darwin’s x86_64 ABI is supposed
> to follow the sysv psABI so we can have essentially a copy of the
> Linux one.
> 
> This is needed on all open branches.
> 
> OK for trunk?
> branches?
> 
> thanks
> Iain
> 
> gcc/testsuite/
> 
>   PR testsuite/67974
>   * gcc.target/x86_64/abi/avx/asm-support-darwin.s: New.
OK anywhere you want to install.

jeff


Re: [PATCH, Darwin, config] Check for DWARF debug line support with otool.

2018-12-23 Thread Jeff Law
On 12/23/18 4:53 AM, Iain Sandoe wrote:
> Hi,
> 
> This corrects a long-standing misconfiguration for Darwin.
> The assembler supports the “.file” and “.loc” directives, but
> the GCC configury was not detecting this because it was 
> using objdump, which does not exist on most Darwin installations.
> 
> We added support for “otool” to GCC and now we can use that to
> make the check that’s done with objdump on ELF targets.
> 
> OK for trunk?
> Iain
> 
> gcc/
> 
>   * configure.ac (dwarf2_debug_line): Check for the debug_line
>   section using otool when there’s no objdump available.
>   * configure: Regenerate.
OK
jeff


Re: [PATCH] Don't run ident tests on powerpc-darwin

2018-12-23 Thread Jeff Law
On 12/23/18 4:16 AM, Iain Sandoe wrote:
> Hi
> 
> The c-c++-common tests fail (or XPASS depending on which) on Darwin
> because it doesn't currently emit .ident marker. 
> 
> For powerpc darwin (and, I think, AIX - hence copying David), there’s no
> .ident support in the assembler, and we need to skip the tests.
> 
> In this case, I suggest that it’s not worth having a target-supports entry.
> This is because what a target chooses to emit for -fident is controlled by
> a target hook and therefore there’s no guarantee that a target-supports
> that triggers off “ .ident” in the asm would be generically useful.
> 
> OTOH, if the testsuite maintainers prefer a support .. it can be done ;-)
> 
> OK for trunk?
> Iain
> 
> gcc/testsuite/
> 
>   * c-c++-common/ident-0a.c: Skip for powerpc-darwin.
>   * c-c++-common/ident-0b.c: Likewise.
>   * c-c++-common/ident-1a.c: Likewise.
>   * c-c++-common/ident-1b.c: Likewise.
>   * c-c++-common/ident-2a.c: Likewise.
>   * c-c++-common/ident-2b.c: Likewise.
OK
jeff


Re: Fix hashtable node deallocation

2018-12-23 Thread François Dumont

On 12/21/18 9:29 PM, Jonathan Wakely wrote:

On 16/12/18 14:16 +0100, François Dumont wrote:

Gentle reminder, we still have this issue pending.

    * include/bits/hashtable_policy.h
(_Hashtable_alloc<>::_M_deallocate_node_ptr(__node_type*)): New.
(_Hashtable_alloc<>::_M_deallocate_node(__node_type*)): Use latter.
(_ReuseOrAllocNode<>::operator<_Arg>()(_Arg&&)): Likewise.


Please add more detail to the commit message explaining the problem.
Either as a paragraph of text in the commit message before the
changelog (e.g. see https://gcc.gnu.org/r267236 or
https://gcc.gnu.org/r267276 for commits with additional text in the
commit message), or in the changelog itself, e.g.

(_ReuseOrAllocNode<>::operator<_Arg>()(_Arg&&)): Likewise, so
   that the argument to __node_alloc_traits::deallocate is the
   correct pointer type.


    * libstdc++-v3/testsuite/util/testsuite_allocator.h
    (CustomPointerAlloc<>::allocate(size_t, pointer)): Replace by...
    (CustomPointerAlloc<>::allocate(size_t, const_void_pointer)): 
...this.


This should have been a separate commit really.

OK for trunk with a better commit message that explains what the
change does.



Committed in 2 different commits.

I hope you will appreciate my additional message, I didn't notice yours 
before writting mine.


François




[PATCH] PR fortran/81509 and fortran/45513

2018-12-23 Thread Steve Kargl
This is a re-submission of a patch I submitted 15 months ago.
See https://gcc.gnu.org/ml/fortran/2017-09/msg00124.html

At that time one reviewer OK'd the patch for committing,
and one reviewer raised objections to the patch as I
chose to remove dubious extensions to the Fortran standard.
I withdrew that patch with the expection that Someone
would fix the bug.  Well, Someone has not materialized.

The patch has been retested on i586-*-freebsd and x86_64-*-freebsd.

OK to commit as-is?

Here's the text from the above URL. 

In short, F2008 now allows boz-literal-constants in IAND, IOR, IEOR,
DSHIFTL, DSHIFTR, and MERGE_BITS.  gfortran currently allows a BOZ
argument, but she was not enforcing restrictions in F2008.  The
attach patch causes gfortran to conform to F2008.

As a side effect, the patch removes a questionable GNU Fortran
extension that allowed arguments to IAND, IOR, and IEOR to have
different kind type parameters.  The behavior of this extension
was not documented.

2017-09-27  Steven G. Kargl  

PR fortran/45513
PR fortran/81509
* check.c: Rename function gfc_check_iand to gfc_check_iand_ieor_ior.
* check.c (boz_args_check): New function.  Check I and J not both BOZ.
(gfc_check_dshift,gfc_check_iand_ieor_ior, gfc_check_ishft,
 gfc_check_and, gfc_check_merge_bits): Use it.
* check.c (gfc_check_iand_ieor_ior): Force conversion of BOZ to kind
type of other agrument.  Remove silly GNU extension.
(gfc_check_ieor, gfc_check_ior): Delete now unused functions.
* intrinsic.c (add_functions): Use gfc_check_iand_ieor_ior. Wrap long
line.
* intrinsic.h: Rename gfc_check_iand to gfc_check_iand_ieor_ior.
Delete prototype for bool gfc_check_ieor and gfc_check_ior
* intrinsic.texi: Update documentation for boz-literal-constant.

2017-09-27  Steven G. Kargl  

PR fortran/45513
PR fortran/81509
* gfortran.dg/graphite/id-26.f03: Fix non-conforming use of IAND.
* gfortran.dg/pr81509_1.f90: New test.
* gfortran.dg/pr81509_2.f90: New test.

-- 
Steve
Index: gcc/fortran/check.c
===
--- gcc/fortran/check.c	(revision 267379)
+++ gcc/fortran/check.c	(working copy)
@@ -2168,6 +2168,21 @@ gfc_check_dprod (gfc_expr *x, gfc_expr *y)
 }
 
 
+static bool
+boz_args_check(gfc_expr *i, gfc_expr *j)
+{
+  if (i->is_boz && j->is_boz)
+{
+  gfc_error ("Arguments of %qs at %L and %L cannot both be BOZ "
+		 "literal constants", gfc_current_intrinsic, &i->where,
+		 &j->where);
+  return false;
+
+}
+  return true;
+}
+
+
 bool
 gfc_check_dshift (gfc_expr *i, gfc_expr *j, gfc_expr *shift)
 {
@@ -2177,12 +2192,8 @@ gfc_check_dshift (gfc_expr *i, gfc_expr *j, gfc_expr *
   if (!type_check (j, 1, BT_INTEGER))
 return false;
 
-  if (i->is_boz && j->is_boz)
-{
-  gfc_error ("% at %L and %' at %L cannot both be BOZ literal "
-		   "constants", &i->where, &j->where);
-  return false;
-}
+  if (!boz_args_check (i, j))
+return false;
 
   if (!i->is_boz && !j->is_boz && !same_type_check (i, 0, j, 1))
 return false;
@@ -2482,7 +2493,7 @@ gfc_check_i (gfc_expr *i)
 
 
 bool
-gfc_check_iand (gfc_expr *i, gfc_expr *j)
+gfc_check_iand_ieor_ior (gfc_expr *i, gfc_expr *j)
 {
   if (!type_check (i, 0, BT_INTEGER))
 return false;
@@ -2490,10 +2501,16 @@ gfc_check_iand (gfc_expr *i, gfc_expr *j)
   if (!type_check (j, 1, BT_INTEGER))
 return false;
 
+  if (!boz_args_check (i, j))
+return false;
+
+  if (i->is_boz) i->ts.kind = j->ts.kind;
+  if (j->is_boz) j->ts.kind = i->ts.kind;
+
   if (i->ts.kind != j->ts.kind)
 {
-  if (!gfc_notify_std (GFC_STD_GNU, "Different type kinds at %L",
-			   &i->where))
+  gfc_error ("Arguments of %qs have different kind type parameters "
+		 "at %L", gfc_current_intrinsic, &i->where);
 	return false;
 }
 
@@ -2608,26 +2625,6 @@ gfc_check_idnint (gfc_expr *a)
 
 
 bool
-gfc_check_ieor (gfc_expr *i, gfc_expr *j)
-{
-  if (!type_check (i, 0, BT_INTEGER))
-return false;
-
-  if (!type_check (j, 1, BT_INTEGER))
-return false;
-
-  if (i->ts.kind != j->ts.kind)
-{
-  if (!gfc_notify_std (GFC_STD_GNU, "Different type kinds at %L",
-			   &i->where))
-	return false;
-}
-
-  return true;
-}
-
-
-bool
 gfc_check_index (gfc_expr *string, gfc_expr *substring, gfc_expr *back,
 		 gfc_expr *kind)
 {
@@ -2680,28 +2677,7 @@ gfc_check_intconv (gfc_expr *x)
   return true;
 }
 
-
 bool
-gfc_check_ior (gfc_expr *i, gfc_expr *j)
-{
-  if (!type_check (i, 0, BT_INTEGER))
-return false;
-
-  if (!type_check (j, 1, BT_INTEGER))
-return false;
-
-  if (i->ts.kind != j->ts.kind)
-{
-  if (!gfc_notify_std (GFC_STD_GNU, "Different type kinds at %L",
-			   &i->where))
-	return false;
-}
-
-  return true;
-}
-
-
-bool
 gfc_check_ishft (gfc_expr *i, gfc_expr *shift)
 {
   if (!type_check (i, 0, BT_INTEGER)
@@ -3584,6 +3560,

Re: libbacktrace integration for _GLIBCXX_DEBUG mode

2018-12-23 Thread François Dumont

On 12/21/18 10:03 PM, Jonathan Wakely wrote:

On 21/12/18 22:47 +0200, Ville Voutilainen wrote:
On Fri, 21 Dec 2018 at 22:35, Jonathan Wakely  
wrote:

>    I also explcitely define BACKTRACE_SUPPORTED to 0 to make sure
>libstdc++ has no libbacktrace dependency after usual build.



I'm concerned about the requirement to link to libbacktrace
explicitly (which will break existing makefiles and build systems that
currently use debug mode in testing).


But see what Francois wrote, "I also explcitely define
BACKTRACE_SUPPORTED to 0 to make sure
libstdc++ has no libbacktrace dependency after usual build."


Yes, but if you happen to install libbacktrace headers, the behaviour
for users building their own code changes. I agree that if you install
those headers, it's probably for a reason, but it might be a different
reason to "so that libstdc++ prints better backtraces".


Also, some of the glibc team pointed out to me that running *any*
extra code after undefined behaviour has been detected is a potential
risk. The less that you do between detecting UB and calling abort(),
the better. Giving the users more information is helpful, but comes
with some additional risk.


Ditto. Having said those things, I think we need to figure out a good
way to provide this sensibly
as an opt-in. The backtrace support is bloody useful, and dovetails
into a possible Contracts-aware
implementation of our library, but I think we need to do some more
thought-work on this, thus I agree
that it's not stage3 material. I do think it's something that we need
to keep in mind, thanks
for working on it, Francois!


Yes, I agree that making it available via a more explicit opt-in would
be good. Maybe require users to define _GLIBCXX_DEBUG_BACKTRACE as well
as _GLIBCXX_DEBUG, or something like that.


Yes, I considered that if you had install libbacktrace you wanted to use 
it. But I agree that an explicit activation might be better.


I'll prepare that.

François



Re: [PATCH] PR fortran/81509 and fortran/45513

2018-12-23 Thread Dominique d'Humières
Hi Steve,

The 'call abort’ in the test gfortran.dg/pr81509_1.f90 should be replaced with 
‘stop n’.

Thanks for the patch.

Dominique



Fix summary update after profile merging

2018-12-23 Thread Jan Hubicka
Hi,
while looking into Firefox inline dumps I noticed that my previous patch
was not quite enough to get inline summaries right. The problem is that
we may have speculative edges from profile feedback and also it does
happen that profiles mismatch and we should handle it better.  This
patch fixes the problem in more robust way.

Bootstrapped/regtested x86_64-linux and also tested with firefox,
will commit it shortly.

Honza

* ipa-utils.c (ipa_merge_profiles): Fix updating of fnsummary;
also handle rescaling of mismatched profiles.
* ipa-fnsummary.c (analyze_function): Handle speculative edges.
Index: ipa-utils.c
===
--- ipa-utils.c (revision 267377)
+++ ipa-utils.c (working copy)
@@ -392,6 +392,7 @@
   if (!src->definition
   || !dst->definition)
 return;
+
   if (src->frequency < dst->frequency)
 src->frequency = dst->frequency;
 
@@ -416,6 +417,8 @@
   fprintf (symtab->dump_file, "Merging profiles of %s to %s\n",
   src->dump_name (), dst->dump_name ());
 }
+  profile_count orig_count = dst->count;
+
   if (dst->count.initialized_p () && dst->count.ipa () == dst->count)
 dst->count += src->count.ipa ();
   else 
@@ -644,10 +647,21 @@
   if (!preserve_body)
 src->release_body ();
   /* Update summary.  */
-  symtab->call_cgraph_removal_hooks (dst);
-  symtab->call_cgraph_insertion_hooks (dst);
+  compute_fn_summary (dst, 0);
 }
-  /* TODO: if there is no match, we can scale up.  */
+  /* We can't update CFG profile, but we can scale IPA profile. CFG
+ will be scaled according to dst->count after IPA passes.  */
+  else
+{
+  profile_count to = dst->count;
+  profile_count::adjust_for_ipa_scaling (&to, &orig_count);
+  struct cgraph_edge *e;
+  
+  for (e = dst->callees; e; e = e->next_callee)
+   e->count = e->count.apply_scale (to, orig_count);
+  for (e = dst->indirect_calls; e; e = e->next_callee)
+   e->count = e->count.apply_scale (to, orig_count);
+}
   src->decl = oldsrcdecl;
 }
 
Index: ipa-fnsummary.c
===
--- ipa-fnsummary.c (revision 267377)
+++ ipa-fnsummary.c (working copy)
@@ -2180,6 +2180,17 @@
  es->call_stmt_time = this_time;
  es->loop_depth = bb_loop_depth (bb);
  edge_set_predicate (edge, &bb_predicate);
+ if (edge->speculative)
+   {
+ cgraph_edge *direct, *indirect;
+ ipa_ref *ref;
+ edge->speculative_call_info (direct, indirect, ref);
+ gcc_assert (direct == edge);
+ ipa_call_summary *es2
+= ipa_call_summaries->get_create (indirect);
+ ipa_call_summaries->duplicate (edge, indirect,
+es, es2);
+   }
}
 
  /* TODO: When conditional jump or swithc is known to be constant, but
@@ -2491,7 +2502,8 @@
  ipa_update_overall_fn_summary but because computation happens in
  different order the roundoff errors result in slight changes.  */
   ipa_update_overall_fn_summary (node);
-  gcc_assert (info->size == info->self_size);
+  /* In LTO mode we may have speculative edges set.  */
+  gcc_assert (in_lto_p || info->size == info->self_size);
 }
 
 


Re: [REVISED PATCH 1/9]: C++ P0482R5 char8_t: Documentation updates

2018-12-23 Thread Tom Honermann
Attached is a revised patch that addresses feedback provided by Jason 
and Sandra.  Changes from the prior patch include:

- Updates to the -fchar8_t option documentation as requested by Jason.
- Corrections for indentation, spacing, hyphenation, and wrapping as
  requested by Sandra.

Tested on x86_64-linux.

gcc/ChangeLog:

2018-11-04  Tom Honermann  
 * doc/invoke.texi (-fchar8_t): Document new option.

Tom.

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 57491f1033c..95374951d98 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -206,7 +206,7 @@ in the following sections.
 @item C++ Language Options
 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
 @gccoptlist{-fabi-version=@var{n}  -fno-access-control @gol
--faligned-new=@var{n}  -fargs-in-order=@var{n}  -fcheck-new @gol
+-faligned-new=@var{n}  -fargs-in-order=@var{n}  -fchar8_t  -fcheck-new @gol
 -fconstexpr-depth=@var{n}  -fconstexpr-loop-limit=@var{n} @gol
 -fno-elide-constructors @gol
 -fno-enforce-eh-specs @gol
@@ -2432,6 +2432,60 @@ but few users will need to override the default of
 
 This flag is enabled by default for @option{-std=c++17}.
 
+@item -fchar8_t
+@itemx -fno-char8_t
+@opindex fchar8_t
+@opindex fno-char8_t
+Enable support for @code{char8_t} as adopted for C++2a.  This includes
+the addition of a new @code{char8_t} fundamental type, changes to the
+types of UTF-8 string and character literals, new signatures for
+user-defined literals, associated standard library updates, and new
+@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
+
+This option enables functions to be overloaded for ordinary and UTF-8
+strings:
+
+@smallexample
+int f(const char *);// #1
+int f(const char8_t *); // #2
+int v1 = f("text"); // Calls #1
+int v2 = f(u8"text");   // Calls #2
+@end smallexample
+
+@noindent
+and introduces new signatures for user-defined literals:
+
+@smallexample
+int operator""_udl1(char8_t);
+int v3 = u8'x'_udl1;
+int operator""_udl2(const char8_t*, std::size_t);
+int v4 = u8"text"_udl2;
+template int operator""_udl3();
+int v5 = u8"text"_udl3;
+@end smallexample
+
+@noindent
+The change to the types of UTF-8 string and character literals introduces
+incompatibilities with ISO C++11 and later standards.  For example, the
+following code is well-formed under ISO C++11, but is ill-formed when
+@option{-fchar8_t} is specified.
+
+@smallexample
+char ca[] = u8"xx"; // error: char-array initialized from wide
+//string
+const char *cp = u8"xx";// error: invalid conversion from
+//`const char8_t*' to `const char*'
+int f(const char*);
+auto v = f(u8"xx"); // error: invalid conversion from
+//`const char8_t*' to `const char*'
+std::string s@{u8"xx"@};  // error: no matching function for call to
+//`std::basic_string::basic_string()'
+using namespace std::literals;
+s = u8"xx"s;// error: conversion from
+//`basic_string' to non-scalar
+//type `basic_string' requested
+@end smallexample
+
 @item -fcheck-new
 @opindex fcheck-new
 Check that the pointer returned by @code{operator new} is non-null


Re: [REVISED PATCH 2/9]: C++ P0482R5 char8_t: Core language support

2018-12-23 Thread Tom Honermann
Attached is a revised patch that addresses changes in P0482R6 as well as 
feedback provided by Jason.  Changes from the prior patch include:

- Updated the value of the __cpp_char8_t feature test macro to 201811
  per P0482R6.
- Enable char8_t support with -std=c++2a per adoption of P0482R6 in
  San Diego.
- Reverted the unnecessary changes to gcc/gcc/c/c-typeck.c as requested
  by Jason.
- Removed unnecessary checks of 'flag_char8_t' within the C++ front
  end as requested by Jason.
- Corrected the regression spotted by Jason regarding initialization of
  signed char and unsigned char arrays with string literals.
- Made minor changes to the error message emitted for ill-formed
  initialization of char arrays with UTF-8 string literals.  These
  changes do not yet implement Jason's suggestion; I'll follow up with a
  separate patch for that due to additional test impact.

Tested on x86_64-linux.

gcc/ChangeLog:

2018-11-04  Tom Honermann  

 * defaults.h: Define CHAR8_TYPE.

gcc/c-family/ChangeLog:

2018-11-04  Tom Honermann  
 * c-family/c-common.c (c_common_reswords): Add char8_t.
 (fix_string_type): Use char8_t for the type of u8 string literals.
 (c_common_get_alias_set): char8_t doesn't alias.
 (c_common_nodes_and_builtins): Define char8_t as a builtin type in
 C++.
 (c_stddef_cpp_builtins): Add __CHAR8_TYPE__.
 (keyword_begins_type_specifier): Add RID_CHAR8.
 * c-family/c-common.h (rid): Add RID_CHAR8.
 (c_tree_index): Add CTI_CHAR8_TYPE and CTI_CHAR8_ARRAY_TYPE.
 Define D_CXX_CHAR8_T and D_CXX_CHAR8_T_FLAGS.
 Define char8_type_node and char8_array_type_node.
 * c-family/c-cppbuiltin.c (cpp_atomic_builtins): Predefine
 __GCC_ATOMIC_CHAR8_T_LOCK_FREE.
 (c_cpp_builtins): Predefine __cpp_char8_t.
 * c-family/c-lex.c (lex_string): Use char8_array_type_node as the
 type of CPP_UTF8STRING.
 (lex_charconst): Use char8_type_node as the type of CPP_UTF8CHAR.
 * c-family/c-opts.c: If not otherwise specified, enable -fchar8_t
 when targeting C++2a.
 * c-family/c.opt: Add the -fchar8_t command line option.

gcc/cp/ChangeLog:

2018-11-04  Tom Honermann  

 * cp/cvt.c (type_promotes_to): Handle char8_t promotion.
 * cp/decl.c (grokdeclarator): Handle invalid type specifier
 combinations involving char8_t.
 * cp/lex.c (init_reswords): Add char8_t as a reserved word.
 * cp/mangle.c (write_builtin_type): Add name mangling for char8_t
 (Du).
 * cp/parser.c (cp_keyword_starts_decl_specifier_p,
 cp_parser_simple_type_specifier): Recognize char8_t as a simple
 type specifier.
 (cp_parser_string_literal): Use char8_array_type_node for the type
 of CPP_UTF8STRING.
 (cp_parser_set_decl_spec_type): Tolerate char8_t typedefs in system
 headers.
 * cp/rtti.c (emit_support_tinfos): type_info support for char8_t.
 * cp/tree.c (char_type_p): Recognize char8_t as a character type.
 * cp/typeck.c (string_conv_p): Handle conversions of u8 string
 literals of char8_t type.
 (check_literal_operator_args): Handle UDLs with u8 string literals
 of char8_t type.
 * cp/typeck2.c (digest_init_r): Disallow initializing a char array
 with a u8 string literal.

libiberty/ChangeLog:

2018-10-31  Tom Honermann  
 * cp-demangle.c (cplus_demangle_builtin_types,
 cplus_demangle_type): Add name demangling for char8_t (Du).
 * cp-demangle.h: Increase D_BUILTIN_TYPE_COUNT to accommodate the
 new char8_t type.

Tom.


diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index f10cf89c3a7..b387daca137 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -79,6 +79,7 @@ machine_mode c_default_pointer_mode = VOIDmode;
 	tree signed_char_type_node;
 	tree wchar_type_node;
 
+	tree char8_type_node;
 	tree char16_type_node;
 	tree char32_type_node;
 
@@ -128,6 +129,11 @@ machine_mode c_default_pointer_mode = VOIDmode;
 
 	tree wchar_array_type_node;
 
+   Type `char8_t[SOMENUMBER]' or something like it.
+   Used when a UTF-8 string literal is created.
+
+	tree char8_array_type_node;
+
Type `char16_t[SOMENUMBER]' or something like it.
Used when a UTF-16 string literal is created.
 
@@ -450,6 +456,7 @@ const struct c_common_resword c_common_reswords[] =
   { "case",		RID_CASE,	0 },
   { "catch",		RID_CATCH,	D_CXX_OBJC | D_CXXWARN },
   { "char",		RID_CHAR,	0 },
+  { "char8_t",		RID_CHAR8,	D_CXX_CHAR8_T_FLAGS | D_CXXWARN },
   { "char16_t",		RID_CHAR16,	D_CXXONLY | D_CXX11 | D_CXXWARN },
   { "char32_t",		RID_CHAR32,	D_CXXONLY | D_CXX11 | D_CXXWARN },
   { "class",		RID_CLASS,	D_CXX_OBJC | D_CXXWARN },
@@ -746,6 +753,11 @@ fix_string_type (tree value)
   nchars = length;
   e_type = char_type_node;
 }
+  else if (flag_char8_t && TREE_TYPE (value) == char8_array_type_node)
+{
+  nchars = length / (TYPE_PRECISION (char8_type_node) / BITS_PER_UNIT);
+  e_type = char8_type_node;
+}
   else if (TREE_TYPE (value) == char16_ar

Re: [REVISED PATCH 3/9]: C++ P0482R5 char8_t: New core language tests

2018-12-23 Thread Tom Honermann
Attached is a revised patch that addresses changes in P0482R6 as well as 
feedback provided by Jason for patch 2/9.  Changes from the prior patch 
include:

- New tests to ensure -fchar8_t is implicitly enabled when targeting
  C++2a per adoption of P0482R6 in San Diego.
  - gcc/testsuite/g++.dg/cpp2a/char8_t1.C
  - gcc/testsuite/g++.dg/cpp2a/char8_t2.C
- Updated the value of the __cpp_char8_t feature test macro to 201811
  per P0482R6.
- Updated tests to exercise initialization of signed char and unsigned
  char arrays with ordinary and UTF-8 string literals.
  - gcc/testsuite/g++.dg/ext/char8_t-init-1.C
  - gcc/testsuite/g++.dg/ext/char8_t-init-2.C

Tested on x86_64-linux.

gcc/testsuite/ChangeLog:

2018-11-04  Tom Honermann  
 * g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C: New test cloned
 from udlit-implicit-conv-neg.C.  Validates handling of ill-formed
 uses of char8_t based user defined literals.
 * g++.dg/cpp0x/udlit-resolve-char8_t.C: New test cloned from
 udlit-resolve.C.  Validates handling of well-formed uses of char8_t
 based user defined literals.
 * g++.dg/cpp2a/char8_t1.C: New test; validates char8_t support is
 implicitly enabled when targeting C++2a.
 * g++.dg/cpp2a/char8_t2.C: New test; validates char8_t support is
 disabled when -fno-char8_t is specified when targeting C++2a.
 * g++.dg/ext/char8_t-aliasing-1.C: New test; validates warnings
 for type punning with char8_t types.  Illustrates that char8_t does
 not alias.
 * g++.dg/ext/char8_t-char-literal-1.C: New test; validates u8
 character literals have type char if char8_t support is not
 enabled.
 * g++.dg/ext/char8_t-char-literal-2.C: New test; validates u8
 character literals have type char8_t if char8_t support is
 enabled.
 * g++.dg/ext/char8_t-deduction-1.C: New test; validates char is
 deduced for u8 character and string literals if char8_t support is
 not enabled.
 * g++.dg/ext/char8_t-deduction-2.C: New test; validates char8_t is
 deduced for u8 character and string literals if char8_t support is
 enabled.
 * g++.dg/ext/char8_t-feature-test-macro-1.C: New test; validates
 that the __cpp_char8_t feature test macro is not defined if char8_t
 support is not enabled.
 * g++.dg/ext/char8_t-feature-test-macro-2.C: New test; validates
 that the __cpp_char8_t feature test macro is defined with the
 correct value if char8_t support is enabled.
 * g++.dg/ext/char8_t-init-1.C: New test; validates initialization
 by u8 character and string literals when support for char8_t is not
 enabled.
 * g++.dg/ext/char8_t-init-2.C: New test; validates initialization
 by u8 character and string literals when support for char8_t is
 enabled.
 * g++.dg/ext/char8_t-keyword-1.C: New test; validates that char8_t
 is not a keyword if support for char8_t is not enabled.
 * g++.dg/ext/char8_t-keyword-2.C: New test; validates that char8_t
 is a keyword if support for char8_t is enabled.
 * g++.dg/ext/char8_t-limits-1.C: New test; validates that char8_t
 is unsigned and sufficiently large to store the required range of
 char8_t values.
 * g++.dg/ext/char8_t-overload-1.C: New test; validates overload
 resolution for u8 character and string literal arguments when
 support for char8_t is not enabled.
 * g++.dg/ext/char8_t-overload-2.C: New test; validates overload
 resolution for u8 character and string literal arguments when
 support for char8_t is enabled.
 * g++.dg/ext/char8_t-predefined-macros-1.C: New test; validates
 that the __CHAR8_TYPE__ and __GCC_ATOMIC_CHAR8_T_LOCK_FREE
 predefined macros are not defined when support for char8_t is not
 enabled.
 * g++.dg/ext/char8_t-predefined-macros-2.C: New test; validates
 that the __CHAR8_TYPE__ and __GCC_ATOMIC_CHAR8_T_LOCK_FREE
 predefined macros are defined when support for char8_t is enabled.
 * g++.dg/ext/char8_t-sizeof-1.C: New test; validates that the size
 of char8_t and u8 character literals is 1.
 * g++.dg/ext/char8_t-specialization-1.C: New test; validate
 template specialization for u8 character literal template
 arguments when support for char8_t is not enabled.
 * g++.dg/ext/char8_t-specialization-2.C: New test; validate
 template specialization for char8_t and u8 character literal
 template arguments when support for char8_t is enabled.
 * g++.dg/ext/char8_t-string-literal-1.C: New test; validate the
 type of u8 string literals when support for char8_t is not enabled.
 * g++.dg/ext/char8_t-string-literal-2.C: New test; validate the
 type of u8 string literals when support for char8_t is enabled.
 * g++.dg/ext/char8_t-type-specifier-1.C: New test; validate that
 char8_t is not recognized as a type specifier when support for
 char8_t is not enabled.
 * g++.dg/ext/char8_t-type-specifier-2.C: New test; validate t

Re: [REVISED PATCH 4/9]: C++ P0482R5 char8_t: Updates to existing core language tests

2018-12-23 Thread Tom Honermann
Attached is a revised patch that addresses changes in P0482R6 and 
adoption of P0482R6 for C++20 in San Diego.  Changes from the prior 
patch include:

- Updated a test to validate the value of the __cpp_char8_t feature test
  macro when targeting C++2a.

Tested on x86_64-linux.

gcc/testsuite/ChangeLog:

2018-11-04  Tom Honermann  

 * c-c++-common/raw-string-13.c: Added test cases for u8 raw string
 literals.
 * c-c++-common/raw-string-15.c: Likewise.
 * g++.dg/cpp0x/constexpr-wstring2.C: Added test cases for u8
 literals.
 * g++.dg/cpp2a/feat-cxx2a.C: Added test cases for the __cpp_char8_t
 feature test macro.
 * g++.dg/ext/utf-array-short-wchar.C: Likewise.
 * g++.dg/ext/utf-array.C: Likewise.
 * g++.dg/ext/utf-cxx98.C: Likewise.
 * g++.dg/ext/utf-dflt.C: Likewise.
 * g++.dg/ext/utf-gnuxx98.C: Likewise.
 * gcc.dg/utf-array-short-wchar.c: Likewise.
 * gcc.dg/utf-array.c: Likewise.

Tom.


diff --git a/gcc/testsuite/c-c++-common/raw-string-13.c b/gcc/testsuite/c-c++-common/raw-string-13.c
index 1b37405cee9..fa11edaa7aa 100644
--- a/gcc/testsuite/c-c++-common/raw-string-13.c
+++ b/gcc/testsuite/c-c++-common/raw-string-13.c
@@ -62,6 +62,47 @@ const char s16[] = R"??(??)??";
 const char s17[] = R"?(?)??)?";
 const char s18[] = R"??(??)??)??)??";
 
+const char u800[] = u8R"??=??()??'??!??-\
+(a)#[{}]^|~";
+)??=??";
+const char u801[] = u8R"a(
+)\
+a"
+)a";
+const char u802[] = u8R"a(
+)a\
+"
+)a";
+const char u803[] = u8R"ab(
+)a\
+b"
+)ab";
+const char u804[] = u8R"a??/(x)a??/";
+const char u805[] = u8R"abcdefghijklmn??(abc)abcdefghijklmn??";
+const char u806[] = u8R"abcdefghijklm??/(abc)abcdefghijklm??/";
+const char u807[] = u8R"abc(??)\
+abc";)abc";
+const char u808[] = u8R"def(de)\
+def";)def";
+const char u809[] = u8R"a(??)\
+a"
+)a";
+const char u810[] = u8R"a(??)a\
+"
+)a";
+const char u811[] = u8R"ab(??)a\
+b"
+)ab";
+const char u812[] = u8R"a#(a#)a??=)a#";
+const char u813[] = u8R"a#(??)a??=??)a#";
+const char u814[] = u8R"??/(x)??/
+";)??/";
+const char u815[] = u8R"??/(??)??/
+";)??/";
+const char u816[] = u8R"??(??)??";
+const char u817[] = u8R"?(?)??)?";
+const char u818[] = u8R"??(??)??)??)??";
+
 const char16_t u00[] = uR"??=??()??'??!??-\
 (a)#[{}]^|~";
 )??=??";
@@ -211,6 +252,25 @@ main (void)
   TEST (s16, "??");
   TEST (s17, "?)??");
   TEST (s18, "??"")??"")??");
+  TEST (u800, u8"??""??"")??""'??""!??""-\\\n(a)#[{}]^|~\";\n");
+  TEST (u801, u8"\n)\\\na\"\n");
+  TEST (u802, u8"\n)a\\\n\"\n");
+  TEST (u803, u8"\n)a\\\nb\"\n");
+  TEST (u804, u8"x");
+  TEST (u805, u8"abc");
+  TEST (u806, u8"abc");
+  TEST (u807, u8"??"")\\\nabc\";");
+  TEST (u808, u8"de)\\\ndef\";");
+  TEST (u809, u8"??"")\\\na\"\n");
+  TEST (u810, u8"??"")a\\\n\"\n");
+  TEST (u811, u8"??"")a\\\nb\"\n");
+  TEST (u812, u8"a#)a??""=");
+  TEST (u813, u8"??"")a??""=??");
+  TEST (u814, u8"x)??""/\n\";");
+  TEST (u815, u8"??"")??""/\n\";");
+  TEST (u816, u8"??");
+  TEST (u817, u8"?)??");
+  TEST (u818, u8"??"")??"")??");
   TEST (u00, u"??""??"")??""'??""!??""-\\\n(a)#[{}]^|~\";\n");
   TEST (u01, u"\n)\\\na\"\n");
   TEST (u02, u"\n)a\\\n\"\n");
diff --git a/gcc/testsuite/c-c++-common/raw-string-15.c b/gcc/testsuite/c-c++-common/raw-string-15.c
index 9dfdaabd87d..1d101dc8393 100644
--- a/gcc/testsuite/c-c++-common/raw-string-15.c
+++ b/gcc/testsuite/c-c++-common/raw-string-15.c
@@ -62,6 +62,47 @@ const char s16[] = R"??(??)??";
 const char s17[] = R"?(?)??)?";
 const char s18[] = R"??(??)??)??)??";
 
+const char u800[] = u8R"??=??()??'??!??-\
+(a)#[{}]^|~";
+)??=??";
+const char u801[] = u8R"a(
+)\
+a"
+)a";
+const char u802[] = u8R"a(
+)a\
+"
+)a";
+const char u803[] = u8R"ab(
+)a\
+b"
+)ab";
+const char u804[] = u8R"a??/(x)a??/";
+const char u805[] = u8R"abcdefghijklmn??(abc)abcdefghijklmn??";
+const char u806[] = u8R"abcdefghijklm??/(abc)abcdefghijklm??/";
+const char u807[] = u8R"abc(??)\
+abc";)abc";
+const char u808[] = u8R"def(de)\
+def";)def";
+const char u809[] = u8R"a(??)\
+a"
+)a";
+const char u810[] = u8R"a(??)a\
+"
+)a";
+const char u811[] = u8R"ab(??)a\
+b"
+)ab";
+const char u812[] = u8R"a#(a#)a??=)a#";
+const char u813[] = u8R"a#(??)a??=??)a#";
+const char u814[] = u8R"??/(x)??/
+";)??/";
+const char u815[] = u8R"??/(??)??/
+";)??/";
+const char u816[] = u8R"??(??)??";
+const char u817[] = u8R"?(?)??)?";
+const char u818[] = u8R"??(??)??)??)??";
+
 const char16_t u00[] = uR"??=??()??'??!??-\
 (a)#[{}]^|~";
 )??=??";
@@ -211,6 +252,25 @@ main (void)
   TEST (s16, "??");
   TEST (s17, "?)??");
   TEST (s18, "??"")??"")??");
+  TEST (u800, u8"??""??"")??""'??""!??""-\\\n(a)#[{}]^|~\";\n");
+  TEST (u801, u8"\n)\\\na\"\n");
+  TEST (u802, u8"\n)a\\\n\"\n");
+  TEST (u803, u8"\n)a\\\nb\"\n");
+  TEST (u804, u8"x");
+  TEST (u805, u8"abc");
+  TEST (u806, u8"abc");
+  TEST (u807, u8"??"")\\\nabc\";");
+  TEST (u808, u8"de)\\\ndef\";");
+  TEST (u809, u8"??"")\\\na\"\n");
+  TEST (u810, u8"??"")a\\\n\"\n");
+  TEST (u811, u8"??"")a

Re: [REVISED PATCH 5/9]: C++ P0482R5 char8_t: Standard library support

2018-12-23 Thread Tom Honermann
Attached is a revised patch that addresses changes in P0482R6.  Changes 
from the prior patch include:

- Updated the value of the __cpp_char8_t feature test macro to 201811.

Tested on x86_64-linux.

gcc/cp/ChangeLog:

2018-11-04  Tom Honermann  

 * name-lookup.c (get_std_name_hint): Added u8string as a name hint.

libstdc++-v3/ChangeLog:

2018-11-04  Tom Honermann  

 * config/abi/pre/gnu-versioned-namespace.ver (CXXABI_2.0): Add
 typeinfo symbols for char8_t.
 * config/abi/pre/gnu.ver: Add CXXABI_1.3.12.
 (GLIBCXX_3.4.26): Add symbols for specializations of
 numeric_limits and codecvt that involve char8_t.
 (CXXABI_1.3.12): Add typeinfo symbols for char8_t.
 * include/bits/atomic_base.h: Add atomic_char8_t.
 * include/bits/basic_string.h: Add std::hash and
 operator""s(const char8_t*, size_t).
 * include/bits/c++config: Define _GLIBCXX_USE_CHAR8_T and
 __cpp_lib_char8_t.
 * include/bits/char_traits.h: Add char_traits.
 * include/bits/codecvt.h: Add
 codecvt,
 codecvt,
 codecvt_byname, and
 codecvt_byname.
 * include/bits/cpp_type_traits.h: Add __is_integer to
 recognize char8_t as an integral type.
 * include/bits/fs_path.h: (path::__is_encoded_char): Recognize
 char8_t.
 (path::u8string): Return std::u8string when char8_t support is
 enabled.
 (path::generic_u8string): Likewise.
 (path::_S_convert): Handle conversion from char8_t input.
 (path::_S_str_convert): Likewise.
 * include/bits/functional_hash.h: Add hash.
 * include/bits/locale_conv.h (__str_codecvt_out): Add overloads for
 char8_t.
 * include/bits/locale_facets.h (_GLIBCXX_NUM_UNICODE_FACETS): Bump
 for new char8_t specializations.
 * include/bits/localefwd.h: Add missing declarations of
 codecvt and
 codecvt.  Add char8_t declarations
 codecvt and
 codecvt.
 * include/bits/postypes.h: Add u8streampos
 * include/bits/stringfwd.h: Add declarations of
 char_traits and u8string.
 * include/c_global/cstddef: Add __byte_operand.
 * include/experimental/bits/fs_path.h (path::__is_encoded_char):
 Recognize char8_t.
 (path::u8string): Return std::u8string when char8_t support is
 enabled.
 (path::generic_u8string): Likewise.
 (path::_S_convert): Handle conversion from char8_t input.
 (path::_S_str_convert): Likewise.
 * include/experimental/string: Add u8string.
 * include/experimental/string_view: Add u8string_view,
 hash, and
 operator""sv(const char8_t*, size_t).
 * include/std/atomic: Add atomic and atomic_char8_t.
 * include/std/charconv (__is_int_to_chars_type): Recognize char8_t
 as a character type.
 * include/std/limits: Add numeric_limits.
 * include/std/string_view: Add u8string_view,
 hash, and
 operator""sv(const char8_t*, size_t).
 * include/std/type_traits: Add __is_integral_helper,
 __make_unsigned, and __make_signed.
 * libsupc++/atomic_lockfree_defines.h: Define
 ATOMIC_CHAR8_T_LOCK_FREE.
 * src/c++11/Makefile.am: Compile with -fchar8_t when compiling
 codecvt.cc and limits.cc so that char8_t specializations of
 numeric_limits and codecvt and emitted.
 * src/c++11/Makefile.in: Likewise.
 * src/c++11/codecvt.cc: Define members of
 codecvt,
 codecvt,
 codecvt_byname, and
 codecvt_byname.
 * src/c++11/limits.cc: Define members of
 numeric_limits.
 * src/c++98/Makefile.am: Compile with -fchar8_t when compiling
 locale_init.cc and localename.cc.
 * src/c++98/Makefile.in: Likewise.
 * src/c++98/locale_init.cc: Add initialization for the
 codecvt and
 codecvt facets.
 * src/c++98/localename.cc: Likewise.
 * testsuite/util/testsuite_abi.cc: Validate ABI bump.

Tom.


diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 08632c382b7..5f2f8e865ca 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5543,6 +5543,7 @@ get_std_name_hint (const char *name)
 {"basic_string", "", cxx98},
 {"string", "", cxx98},
 {"wstring", "", cxx98},
+{"u8string", "", cxx2a},
 {"u16string", "", cxx11},
 {"u32string", "", cxx11},
 /* .  */
diff --git a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
index c448b813331..b26cf1dc8ac 100644
--- a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
+++ b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
@@ -301,6 +301,11 @@ CXXABI_2.0 {
 _ZTSN10__cxxabiv120__si_class_type_infoE;
 _ZTSN10__cxxabiv121__vmi_class_type_infoE;
 
+# typeinfo for char8_t
+_ZTIDu;
+_ZTIPDu;
+_ZTIPKDu;
+
 # typeinfo for char16_t and char32_t
 _ZTIDs;
 _ZTIPDs;
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index e8cd286ef0c..b24ff3bf9ee 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.v

Re: [PATCH 2/9]: C++ P0482R5 char8_t: Core language support

2018-12-23 Thread Tom Honermann
Thanks, Jason.  I just sent a revised set of patches addressing most of 
your feedback with exceptions as described inline below.


On 12/17/18 4:47 PM, Tom Honermann wrote:

On 12/17/18 4:02 PM, Jason Merrill wrote:

On 12/5/18 11:16 AM, Jason Merrill wrote:

On 12/5/18 2:09 AM, Tom Honermann wrote:

On 12/3/18 5:01 PM, Jason Merrill wrote:

On 12/3/18 4:51 PM, Jason Merrill wrote:

On 11/5/18 2:39 PM, Tom Honermann wrote:
This patch adds support for the P0482R5 core language changes.  
This includes:

- The -fchar8_t and -fno_char8_t command line options.
- char8_t as a keyword.
- The char8_t builtin type as a non-aliasing unsigned integral
   character type of size 1.
- Use of char8_t as a simple type specifier.
- u8 character literals with type char8_t.
- u8 string literals with type array of const char8_t.
- User defined literal operators that accept char8_1 and char8_t 
pointer

   types.
- New __cpp_char8_t predefined feature test macro.
- New __CHAR8_TYPE__ and __GCC_ATOMIC_CHAR8_T_LOCK_FREE predefined
   macros .
- Name mangling and demangling for char8_t (using Du).

gcc/ChangeLog:

2018-11-04  Tom Honermann  

  * defaults.h: Define CHAR8_TYPE.

gcc/c-family/ChangeLog:

2018-11-04  Tom Honermann  
  * c-family/c-common.c (c_common_reswords): Add char8_t.
  (fix_string_type): Use char8_t for the type of u8 string 
literals.

  (c_common_get_alias_set): char8_t doesn't alias.
  (c_common_nodes_and_builtins): Define char8_t as a builtin 
type in

  C++.
  (c_stddef_cpp_builtins): Add __CHAR8_TYPE__.
  (keyword_begins_type_specifier): Add RID_CHAR8.
  * gcc/c-family/c-common.h (rid): Add RID_CHAR8.
  (c_tree_index): Add CTI_CHAR8_TYPE and CTI_CHAR8_ARRAY_TYPE.
  Define D_CXX_CHAR8_T and D_CXX_CHAR8_T_FLAGS.
  Define char8_type_node and char8_array_type_node.
  * c-family/c-cppbuiltin.c (cpp_atomic_builtins): Predefine
  __GCC_ATOMIC_CHAR8_T_LOCK_FREE.
  (c_cpp_builtins): Predefine __cpp_char8_t.
  * c-family/c-lex.c (lex_string): Use char8_array_type_node 
as the

  type of CPP_UTF8STRING.
  (lex_charconst): Use char8_type_node as the type of 
CPP_UTF8CHAR.

  * c-family/c.opt: Add the -fchar8_t command line option.

gcc/c/ChangeLog:

2018-11-04  Tom Honermann  

  * c/c-typeck.c (char_type_p): Add char8_type_node.
  (digest_init): Handle initialization by a u8 string 
literal of

  char8_t type.

gcc/cp/ChangeLog:

2018-11-04  Tom Honermann  

  * cp/cvt.c (type_promotes_to): Handle char8_t promotion.
  * cp/decl.c (grokdeclarator): Handle invalid type specifier
  combinations involving char8_t.
  * cp/lex.c (init_reswords): Add char8_t as a reserved word.
  * cp/mangle.c (write_builtin_type): Add name mangling for 
char8_t

  (Du).
  * cp/parser.c (cp_keyword_starts_decl_specifier_p,
  cp_parser_simple_type_specifier): Recognize char8_t as a 
simple

  type specifier.
  (cp_parser_string_literal): Use char8_array_type_node for 
the type

  of CPP_UTF8STRING.
  (cp_parser_set_decl_spec_type): Tolerate char8_t typedefs 
in system

  headers.
  * cp/rtti.c (emit_support_tinfos): type_info support for 
char8_t.
  * cp/tree.c (char_type_p): Recognize char8_t as a 
character type.
  * cp/typeck.c (string_conv_p): Handle conversions of u8 
string

  literals of char8_t type.
  (check_literal_operator_args): Handle UDLs with u8 string 
literals

  of char8_t type.
  * cp/typeck2.c (digest_init_r): Disallow initializing a 
char array

  with a u8 string literal.

libiberty/ChangeLog:

2018-10-31  Tom Honermann  
  * cp-demangle.c (cplus_demangle_builtin_types,
  cplus_demangle_type): Add name demangling for char8_t (Du).
  * cp-demangle.h: Increase D_BUILTIN_TYPE_COUNT to 
accommodate the

  new char8_t type.



@@ -3543,6 +3556,10 @@ c_common_get_alias_set (tree t)
   if (!TYPE_P (t))
 return -1;



+  /* Unlike char, char8_t doesn't alias. */
+  if (flag_char8_t && t == char8_type_node)
+    return -1;


This seems unnecessary; doesn't the existing code have the same 
effect? I think we could do with just an adjustment to the 
existing comment.
I'm not sure.  I had concerns about unintended matching due to 
char8_t having an underlying type of unsigned char.


That shouldn't be a problem: if char8_t is a distinct type, it won't 
match unsigned char, and if it's the same as unsigned char, 
flag_char8_t will be false.
I tried removing this check and that resulted in test 
gcc/testsuite/g++.dg/ext/char8_t-aliasing-1.C (added in patch 3/9) 
failing.  It seems this change is needed.  If you believe that implies 
that something is wrong elsewhere, please let me know.


+  else if (flag_char8_t && TREE_TYPE (value) == 
char8_array_type_node)

+  || (flag_char8_t && type == char8_type_node)
+  bool char8_array = (flag_char8_t && !!comptypes (typ1, 
char8_type_node));

+   || (flag_char8_t && type == char8_type_n

Re: [REVISED PATCH 7/9]: C++ P0482R5 char8_t: New standard library tests

2018-12-23 Thread Tom Honermann
Attached is a revised patch that addresses changes in P0482R6.  Changes 
from the prior patch include:

- Updated the value of the __cpp_char8_t feature test macro to 201811.

Tested on x86_64-linux.

libstdc++-v3/ChangeLog:

2018-11-04  Tom Honermann  

 * testsuite/18_support/numeric_limits/char8_t.cc: New test cloned
 from char16_32_t.cc; validates numeric_limits.
 * testsuite/21_strings/basic_string/literals/types-char8_t.cc: New
 test cloned from types.cc; validates operator""s for char8_t
 returns u8string.
 * testsuite/21_strings/basic_string/literals/values-char8_t.cc: New
 test cloned from values.cc; validates construction and comparison
 of u8string values.
 * testsuite/21_strings/basic_string/requirements/
 /explicit_instantiation/char8_t/1.cc: New test cloned from
 char16_t/1.cc; validates explicit instantiation of
 basic_string.
 * testsuite/21_strings/basic_string_view/literals/types-char8_t.cc:
 New test cloned from types.cc; validates operator""sv for char8_t
 returns u8string_view.
 * testsuite/21_strings/basic_string_view/literals/
 values-char8_t.cc: New test cloned from values.cc; validates
 construction and comparison of u8string_view values.
 * testsuite/21_strings/basic_string_view/requirements/
 explicit_instantiation/char8_t/1.cc: New test cloned from
 char16_t/1.cc; validates explicit instantiation of
 basic_string_view.
 * testsuite/21_strings/char_traits/requirements/char8_t/65049.cc:
 New test cloned from char16_t/65049.cc; validates that
 char_traits is not vulnerable to the concerns in PR65049.
 * testsuite/21_strings/char_traits/requirements/char8_t/
 typedefs.cc: New test cloned from char16_t/typedefs.cc; validates
 that char_traits member typedefs are present and correct.
 * testsuite/21_strings/char_traits/requirements/
 explicit_instantiation/char8_t/1.cc: New test cloned from
 char16_t/1.cc; validates explicit instantiation of
 char_traits.
 * testsuite/22_locale/codecvt/char16_t-char8_t.cc: New test cloned
 from char16_t.cc: validates
 codecvt.
 * testsuite/22_locale/codecvt/char32_t-char8_t.cc: New test cloned
 from char32_t.cc: validates
 codecvt.
 * testsuite/22_locale/codecvt/utf8-char8_t.cc: New test cloned from
 utf8.cc; validates codecvt and
 codecvt.
 * testsuite/27_io/filesystem/path/native/string-char8_t.cc: New
 test cloned from string.cc; validates filesystem::path construction
 from char8_t input.
 * testsuite/experimental/feat-char8_t.cc: New test; validates that
 the __cpp_lib_char8_t feature test macro is defined with the
 correct value.
 * testsuite/experimental/filesystem/path/native/string-char8_t.cc:
 New test cloned from string.cc; validates filesystem::path
 construction from char8_t input.
 * testsuite/experimental/string_view/literals/types-char8_t.cc: New
 test cloned from types.cc; validates operator""sv for char8_t
 returns u8string_view.
 * testsuite/experimental/string_view/literals/values-char8_t.cc:
 New test cloned from values.cc; validates construction and
 comparison of u8string_view values.
 * testsuite/experimental/string_view/requirements/
 explicit_instantiation/char8_t/1.cc: New test cloned from
 char16_t/1.cc; validates explicit instantiation of
 basic_string_view.
 * testsuite/ext/char8_t/atomic-1.cc: New test; validates that
 ATOMIC_CHAR8_T_LOCK_FREE is not defined if char8_t support is not
 enabled.

Tom.


diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits/char8_t.cc b/libstdc++-v3/testsuite/18_support/numeric_limits/char8_t.cc
new file mode 100644
index 000..346463d7244
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/numeric_limits/char8_t.cc
@@ -0,0 +1,71 @@
+// { dg-do run { target c++11 } }
+// { dg-require-cstdint "" }
+// { dg-options "-fchar8_t" }
+
+// Copyright (C) 2017 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
+// .
+
+#include 
+#include 
+#include 
+
+// Test specializations for char8_t.
+template
+  void
+  do_test()
+  {
+typedef std::numeric_limits char_type;
+typedef std::numeric_limits impl_type;
+
+VERIFY( char_type::is_specialized == 

Re: [PATCH 1/9]: C++ P0482R5 char8_t: Documentation updates

2018-12-23 Thread Tom Honermann
Thank you, Sandra!  I just sent a revised patch to the list that I 
believe addresses all of your comments.  Thanks for the suggestion to 
generate and check the pdf, that was helpful to ensure the changes 
rendered correctly.


Tom.

On 12/11/18 6:35 PM, Sandra Loosemore wrote:

On 11/5/18 12:39 PM, Tom Honermann wrote:
This patch adds documentation for new -fchar8_t and -fno-char8_t 
options.


gcc/ChangeLog:

2018-11-04  Tom Honermann  
  * doc/invoke.texi (-fchar8_t): Document new option.



My comments are all about nitpicky formatting things.


diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 57491f1033c..cd3a2a715db 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -206,7 +206,7 @@ in the following sections.
 @item C++ Language Options
 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
 @gccoptlist{-fabi-version=@var{n}  -fno-access-control @gol
--faligned-new=@var{n}  -fargs-in-order=@var{n}  -fcheck-new @gol
+-faligned-new=@var{n}  -fargs-in-order=@var{n}  -fchar8_t 
-fcheck-new @gol


Please consistently use 2 spaces (not just 1) to separate options on 
the same line in a @gccoptlist environment.



 -fconstexpr-depth=@var{n} -fconstexpr-loop-limit=@var{n} @gol
 -fno-elide-constructors @gol
 -fno-enforce-eh-specs @gol
@@ -2432,6 +2432,53 @@ but few users will need to override the 
default of


 This flag is enabled by default for @option{-std=c++17}.

+@item -fchar8_t
+@itemx -fno-char8_t
+@opindex fchar8_t
+@opindex fno-char8_t
+Enable support for the P0482 proposal including the addition of a
+new @code{char8_t} fundamental type, changes to the types of UTF-8
+string and character literals, new signatures for user defined
+literals, and new specializations of standard library class templates
+@code{std::numeric_limits}, @code{std::char_traits},
+and @code{std::hash}.
+
+This option enables functions to be overloaded for ordinary and UTF-8
+strings:
+
+@smallexample
+int f(const char *);    // #1
+int f(const char8_t *); // #2
+int v1 = f("text"); // Calls #1
+int v2 = f(u8"text");   // Calls #2
+@end smallexample
+
+and introduces new signatures for user defined literals:


@noindent immediately before the continued sentence of the paragraph 
before the example.


Also please hyphenate "user-defined" here.


+
+@smallexample
+int operator""_udl1(char8_t);
+int v3 = u8'x'_udl1;
+int operator""_udl2(const char8_t*, std::size_t);
+int v4 = u8"text"_udl2;
+template int operator""_udl3();
+int v5 = u8"text"_udl3;
+@end smallexample
+
+The change to the types of UTF-8 string and character literals 
introduces

+incompatibilities with ISO C++11 and later standards.  For example, the
+following code is well-formed under ISO C++11, but is ill-formed when
+@option{-fchar8_t} is specified.
+
+@smallexample
+char ca[] = u8"text";   // error: char-array initialized from 
wide string
+const char *cp = u8"text";  // error: invalid conversion from 'const 
char8_t*' to 'const char*'

+int f(const char*);
+auto v = f(u8"text");   // error: invalid conversion from 'const 
char8_t*' to 'const char*'
+std::string s1@{u8"text"@};   // error: no matching function for 
call to 'std::basic_string::basic_string()'

+using namespace std::literals;
+std::string s2 = u8"text"s; // error: conversion from 
'basic_string' to non-scalar type 'basic_string' 
requested

+@end smallexample


The formatting of this code example is way too wide to fit on the page 
of the printed/PDF manual.  I suggest putting the comments on separate 
lines from the code and breaking them across multiple lines where 
necessary.  If you format the example for <80 columns it will probably 
fit, although you should check the PDF if at all possible.



+
 @item -fcheck-new
 @opindex fcheck-new
 Check that the pointer returned by @code{operator new} is non-null



-Sandra





Re: [PATCH] PR fortran/81509 and fortran/45513

2018-12-23 Thread Jerry DeLisle

On 12/23/18 10:49 AM, Steve Kargl wrote:

This is a re-submission of a patch I submitted 15 months ago.
See https://gcc.gnu.org/ml/fortran/2017-09/msg00124.html

At that time one reviewer OK'd the patch for committing,
and one reviewer raised objections to the patch as I
chose to remove dubious extensions to the Fortran standard.
I withdrew that patch with the expection that Someone
would fix the bug.  Well, Someone has not materialized.

The patch has been retested on i586-*-freebsd and x86_64-*-freebsd.

OK to commit as-is?


I say OK to commit.



Here's the text from the above URL.

In short, F2008 now allows boz-literal-constants in IAND, IOR, IEOR,
DSHIFTL, DSHIFTR, and MERGE_BITS.  gfortran currently allows a BOZ
argument, but she was not enforcing restrictions in F2008.  The
attach patch causes gfortran to conform to F2008.

As a side effect, the patch removes a questionable GNU Fortran
extension that allowed arguments to IAND, IOR, and IEOR to have
different kind type parameters.  The behavior of this extension
was not documented.

2017-09-27  Steven G. Kargl  

PR fortran/45513
PR fortran/81509
* check.c: Rename function gfc_check_iand to gfc_check_iand_ieor_ior.
* check.c (boz_args_check): New function.  Check I and J not both BOZ.
(gfc_check_dshift,gfc_check_iand_ieor_ior, gfc_check_ishft,
 gfc_check_and, gfc_check_merge_bits): Use it.
* check.c (gfc_check_iand_ieor_ior): Force conversion of BOZ to kind
type of other agrument.  Remove silly GNU extension.
(gfc_check_ieor, gfc_check_ior): Delete now unused functions.
* intrinsic.c (add_functions): Use gfc_check_iand_ieor_ior. Wrap long
line.
* intrinsic.h: Rename gfc_check_iand to gfc_check_iand_ieor_ior.
Delete prototype for bool gfc_check_ieor and gfc_check_ior
* intrinsic.texi: Update documentation for boz-literal-constant.

2017-09-27  Steven G. Kargl  

PR fortran/45513
PR fortran/81509
* gfortran.dg/graphite/id-26.f03: Fix non-conforming use of IAND.
* gfortran.dg/pr81509_1.f90: New test.
* gfortran.dg/pr81509_2.f90: New test.