[committed] d/dmd: Merge upstream dmd 62ce36f37 (PR94623)

2020-04-21 Thread Iain Buclaw via Gcc-patches
Hi,

This patch merges the D front-end implementation with dmd upstream
62ce36f37.  Adjusts the hardcoded index of Error.bypassException.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain

---
 gcc/d/dmd/MERGE|  2 +-
 gcc/d/dmd/dinterpret.c | 19 +--
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index cd3d48ded8e..155286dd765 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-ba99ee345694da61eca7b17d540ff3dc0a56
+62ce36f3737de691217c21f0173f411734eb1d43
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/dinterpret.c b/gcc/d/dmd/dinterpret.c
index 61f5cdb0730..e2d49b9e8f1 100644
--- a/gcc/d/dmd/dinterpret.c
+++ b/gcc/d/dmd/dinterpret.c
@@ -1652,21 +1652,28 @@ public:
 {
 // Little sanity check to make sure it's really a Throwable
 ClassReferenceExp *boss = oldest->thrown;
-assert((*boss->value->elements)[4]->type->ty == Tclass);// 
Throwable.next
+const int next = 4; // index of Throwable.next
+assert((*boss->value->elements)[next]->type->ty == Tclass); // 
Throwable.next
 ClassReferenceExp *collateral = newest->thrown;
 if ( isAnErrorException(collateral->originalClass()) &&
 !isAnErrorException(boss->originalClass()))
 {
+/* Find the index of the Error.bypassException field
+ */
+int bypass = next + 1;
+if ((*collateral->value->elements)[bypass]->type->ty == Tuns32)
+bypass += 1;  // skip over _refcount field
+assert((*collateral->value->elements)[bypass]->type->ty == Tclass);
+
 // The new exception bypass the existing chain
-assert((*collateral->value->elements)[5]->type->ty == Tclass);
-(*collateral->value->elements)[5] = boss;
+(*collateral->value->elements)[bypass] = boss;
 return newest;
 }
-while ((*boss->value->elements)[4]->op == TOKclassreference)
+while ((*boss->value->elements)[next]->op == TOKclassreference)
 {
-boss = (ClassReferenceExp *)(*boss->value->elements)[4];
+boss = (ClassReferenceExp *)(*boss->value->elements)[next];
 }
-(*boss->value->elements)[4] = collateral;
+(*boss->value->elements)[next] = collateral;
 return oldest;
 }
 
-- 
2.20.1



[PATCH PR94678] aarch64: unexpected result with -mgeneral-regs-only and sve

2020-04-21 Thread Yangfei (Felix)
Hi,

  It looks like there are several issues out there for sve codegen with 
-mgeneral-regs-only. 
  I have created a bug for that: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94678 

  We do ISA extension checks for SVE in 
check_required_extensions(aarch64-sve-builtins.cc). 
  I think we may also need to check -mgeneral-regs-only there and issue an 
error message when this option is specified. 
  This would be cheaper as compared with adding && TARGET_GENERAL_REGS_ONLY to 
TARGET_SVE and similar macros. 
  Attached please find the proposed patch.  Bootstrap and tested on aarch64 
Linux platform.  
  Suggestions?

Thanks,
Felix


pr94678-v1.patch
Description: pr94678-v1.patch


[PATCH] doc: Document all D-specific configuration options.

2020-04-21 Thread Iain Buclaw via Gcc-patches
Hi,

This patch adds documentation for --enable-libphobos-checking and
--with-libphobos-druntime-only options.

Does it read and explain clearly enough?

Regards
Iain.

gcc/ChangeLog:

* doc/install.texi (D-Specific Options): Document
--enable-libphobos-checking and --with-libphobos-druntime-only.
---
 gcc/doc/install.texi | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index bc5259d74c5..39ae0680260 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -2460,6 +2460,37 @@ default locations.
 The following options apply to the build of the D runtime library.
 
 @table @code
+@item --enable-libphobos-checking
+@itemx --disable-libphobos-checking
+@itemx --enable-libphobos-checking=@var{list}
+This option controls whether run-time checks and contracts are compiled into
+the D runtime library.  When the option is not specified, the library is built
+with @samp{release} checking.  When the option is specified without a
+@var{list}, the result is the same as @samp{--enable-libphobos-checking=yes}.
+Likewise, @samp{--disable-libphobos-checking} is equivalent to
+@samp{--enable-libphobos-checking=no}.
+
+The categories of checks available in @var{list} are @samp{yes} (compiles
+libphobos with @option{-fno-release}), @samp{no} (compiles libphobos with
+@option{-frelease}), @samp{all} (same as @samp{yes}), @samp{none} or
+@samp{release} (same as @samp{no}).
+
+Individual checks available in @var{list} are @samp{assert} (compiles libphobos
+with an extra option @option{-fassert}).
+
+@item --with-libphobos-druntime-only
+@itemx --with-libphobos-druntime-only=@var{choice}
+Specify whether to build only the core D runtime library (druntime), or both
+the core and standard library (phobos) into libphobos.  This is useful for
+targets that have full support in druntime, but no or incomplete support
+in phobos.  @var{choice} can be one of @samp{auto}, @samp{yes}, and @samp{no}
+where @samp{auto} is the default.
+
+When the option is not specified, the default choice @samp{auto} means that it
+is inferred whether the target has support for the phobos standard library.
+When the option is specified without a @var{choice},  the result is the same as
+@samp{--with-libphobos-druntime-only=yes}.
+
 @item --with-target-system-zlib
 Use installed @samp{zlib} rather than that included with GCC@.  This needs
 to be available for each multilib variant, unless configured with
-- 
2.20.1



[PATCH v2] ubsan: Avoid -Wpadded warnings [PR94641]

2020-04-21 Thread Jakub Jelinek via Gcc-patches
Hi!

On Tue, Apr 21, 2020 at 08:21:36AM +0200, Richard Biener wrote:
> I believe most of those warnings should simply not look at
> TYPE_ARTIFICIAL types.  So why the above kludge certainly
> works a better fix is on the -Wpadded side IMHO.

So like this if it passes bootstrap/regtest?

2020-04-21  Jakub Jelinek  

PR c/94641
* stor-layout.c (place_field, finalize_record_size): Don't emit
-Wpadded warning on TYPE_ARTIFICIAL rli->t.
* ubsan.c (ubsan_get_type_descriptor_type,
ubsan_get_source_location_type, ubsan_create_data): Set
TYPE_ARTIFICIAL.
* asan.c (asan_global_struct): Likewise.

* c-c++-common/ubsan/pr94641.c: New test.

--- gcc/stor-layout.c.jj2020-01-12 11:54:36.935405533 +0100
+++ gcc/stor-layout.c   2020-04-21 09:34:27.743871177 +0200
@@ -1341,7 +1341,8 @@ place_field (record_layout_info rli, tre
 Bump the cumulative size to multiple of field alignment.  */
 
   if (!targetm.ms_bitfield_layout_p (rli->t)
-  && DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION)
+  && DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION
+  && !TYPE_ARTIFICIAL (rli->t))
warning (OPT_Wpadded, "padding struct to align %q+D", field);
 
   /* If the alignment is still within offset_align, just align
@@ -1775,7 +1776,8 @@ finalize_record_size (record_layout_info
 
   if (TREE_CONSTANT (unpadded_size)
   && simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) == 0
-  && input_location != BUILTINS_LOCATION)
+  && input_location != BUILTINS_LOCATION
+  && !TYPE_ARTIFICIAL (rli->t))
 warning (OPT_Wpadded, "padding struct size to alignment boundary");
 
   if (warn_packed && TREE_CODE (rli->t) == RECORD_TYPE
--- gcc/ubsan.c.jj  2020-04-20 11:46:07.892145312 +0200
+++ gcc/ubsan.c 2020-04-21 09:25:46.494055822 +0200
@@ -229,6 +229,7 @@ ubsan_get_type_descriptor_type (void)
   TYPE_FIELDS (ret) = fields[0];
   TYPE_NAME (ret) = type_decl;
   TYPE_STUB_DECL (ret) = type_decl;
+  TYPE_ARTIFICIAL (ret) = 1;
   layout_type (ret);
   ubsan_type_descriptor_type = ret;
   return ret;
@@ -277,6 +278,7 @@ ubsan_get_source_location_type (void)
   TYPE_FIELDS (ret) = fields[0];
   TYPE_NAME (ret) = type_decl;
   TYPE_STUB_DECL (ret) = type_decl;
+  TYPE_ARTIFICIAL (ret) = 1;
   layout_type (ret);
   ubsan_source_location_type = ret;
   return ret;
@@ -593,6 +595,7 @@ ubsan_create_data (const char *name, int
   TYPE_FIELDS (ret) = fields[0];
   TYPE_NAME (ret) = type_decl;
   TYPE_STUB_DECL (ret) = type_decl;
+  TYPE_ARTIFICIAL (ret) = 1;
   layout_type (ret);
 
   /* Now, fill in the type.  */
--- gcc/asan.c.jj   2020-03-18 13:36:22.004021340 +0100
+++ gcc/asan.c  2020-04-21 09:28:00.692968875 +0200
@@ -2661,6 +2661,7 @@ asan_global_struct (void)
   TYPE_FIELDS (ret) = fields[0];
   TYPE_NAME (ret) = type_decl;
   TYPE_STUB_DECL (ret) = type_decl;
+  TYPE_ARTIFICIAL (ret) = 1;
   layout_type (ret);
   return ret;
 }
--- gcc/testsuite/c-c++-common/ubsan/pr94641.c.jj   2020-04-21 
09:24:36.694141289 +0200
+++ gcc/testsuite/c-c++-common/ubsan/pr94641.c  2020-04-21 09:24:36.694141289 
+0200
@@ -0,0 +1,11 @@
+/* PR c/94641 */
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=undefined -Wpadded" } */
+
+void foo (void *) __attribute__((nonnull));
+
+void
+bar (void *p)
+{
+  foo (p);
+}


Jakub



Re: [PATCH v2] ubsan: Avoid -Wpadded warnings [PR94641]

2020-04-21 Thread Richard Biener
On Tue, 21 Apr 2020, Jakub Jelinek wrote:

> Hi!
> 
> On Tue, Apr 21, 2020 at 08:21:36AM +0200, Richard Biener wrote:
> > I believe most of those warnings should simply not look at
> > TYPE_ARTIFICIAL types.  So why the above kludge certainly
> > works a better fix is on the -Wpadded side IMHO.
> 
> So like this if it passes bootstrap/regtest?

Yes.

Thanks,
Richard.

> 2020-04-21  Jakub Jelinek  
> 
>   PR c/94641
>   * stor-layout.c (place_field, finalize_record_size): Don't emit
>   -Wpadded warning on TYPE_ARTIFICIAL rli->t.
>   * ubsan.c (ubsan_get_type_descriptor_type,
>   ubsan_get_source_location_type, ubsan_create_data): Set
>   TYPE_ARTIFICIAL.
>   * asan.c (asan_global_struct): Likewise.
> 
>   * c-c++-common/ubsan/pr94641.c: New test.
> 
> --- gcc/stor-layout.c.jj  2020-01-12 11:54:36.935405533 +0100
> +++ gcc/stor-layout.c 2020-04-21 09:34:27.743871177 +0200
> @@ -1341,7 +1341,8 @@ place_field (record_layout_info rli, tre
>Bump the cumulative size to multiple of field alignment.  */
>  
>if (!targetm.ms_bitfield_layout_p (rli->t)
> -  && DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION)
> +  && DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION
> +  && !TYPE_ARTIFICIAL (rli->t))
>   warning (OPT_Wpadded, "padding struct to align %q+D", field);
>  
>/* If the alignment is still within offset_align, just align
> @@ -1775,7 +1776,8 @@ finalize_record_size (record_layout_info
>  
>if (TREE_CONSTANT (unpadded_size)
>&& simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) == 0
> -  && input_location != BUILTINS_LOCATION)
> +  && input_location != BUILTINS_LOCATION
> +  && !TYPE_ARTIFICIAL (rli->t))
>  warning (OPT_Wpadded, "padding struct size to alignment boundary");
>  
>if (warn_packed && TREE_CODE (rli->t) == RECORD_TYPE
> --- gcc/ubsan.c.jj2020-04-20 11:46:07.892145312 +0200
> +++ gcc/ubsan.c   2020-04-21 09:25:46.494055822 +0200
> @@ -229,6 +229,7 @@ ubsan_get_type_descriptor_type (void)
>TYPE_FIELDS (ret) = fields[0];
>TYPE_NAME (ret) = type_decl;
>TYPE_STUB_DECL (ret) = type_decl;
> +  TYPE_ARTIFICIAL (ret) = 1;
>layout_type (ret);
>ubsan_type_descriptor_type = ret;
>return ret;
> @@ -277,6 +278,7 @@ ubsan_get_source_location_type (void)
>TYPE_FIELDS (ret) = fields[0];
>TYPE_NAME (ret) = type_decl;
>TYPE_STUB_DECL (ret) = type_decl;
> +  TYPE_ARTIFICIAL (ret) = 1;
>layout_type (ret);
>ubsan_source_location_type = ret;
>return ret;
> @@ -593,6 +595,7 @@ ubsan_create_data (const char *name, int
>TYPE_FIELDS (ret) = fields[0];
>TYPE_NAME (ret) = type_decl;
>TYPE_STUB_DECL (ret) = type_decl;
> +  TYPE_ARTIFICIAL (ret) = 1;
>layout_type (ret);
>  
>/* Now, fill in the type.  */
> --- gcc/asan.c.jj 2020-03-18 13:36:22.004021340 +0100
> +++ gcc/asan.c2020-04-21 09:28:00.692968875 +0200
> @@ -2661,6 +2661,7 @@ asan_global_struct (void)
>TYPE_FIELDS (ret) = fields[0];
>TYPE_NAME (ret) = type_decl;
>TYPE_STUB_DECL (ret) = type_decl;
> +  TYPE_ARTIFICIAL (ret) = 1;
>layout_type (ret);
>return ret;
>  }
> --- gcc/testsuite/c-c++-common/ubsan/pr94641.c.jj 2020-04-21 
> 09:24:36.694141289 +0200
> +++ gcc/testsuite/c-c++-common/ubsan/pr94641.c2020-04-21 
> 09:24:36.694141289 +0200
> @@ -0,0 +1,11 @@
> +/* PR c/94641 */
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize=undefined -Wpadded" } */
> +
> +void foo (void *) __attribute__((nonnull));
> +
> +void
> +bar (void *p)
> +{
> +  foo (p);
> +}
> 
> 
>   Jakub
> 
> 

-- 
Richard Biener 
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)


[PATCH] favor bcrypt over wincrypt for the random generator on Windows

2020-04-21 Thread Steve Lhomme
BCrypt is more modern and supported in Universal Apps, Wincrypt is not and
CryptGenRandom is deprecated:
https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom

BCrypt is available since Vista
https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptopenalgorithmprovider

It requires linking with bcrypt rather than advapi32 for wincrypt.
---
 libssp/configure.ac | 16 
 libssp/ssp.c| 20 
 2 files changed, 36 insertions(+)

diff --git a/libssp/configure.ac b/libssp/configure.ac
index f30f81c54f6..a39d9e9c992 100644
--- a/libssp/configure.ac
+++ b/libssp/configure.ac
@@ -158,6 +158,22 @@ else
 fi
 AC_SUBST(ssp_have_usable_vsnprintf)
 
+AC_ARG_ENABLE(bcrypt,
+AS_HELP_STRING([--disable-bcrypt],
+  [use bcrypt for random generator on Windows (otherwise wincrypt)]),
+  use_win_bcrypt=$enableval,
+  use_win_bcrypt=yes)
+if test "x$use_win_bcrypt" != xno; then
+  case "$target_os" in
+win32 | pe | mingw32*)
+  AC_CHECK_TYPES([BCRYPT_ALG_HANDLE],[
+  LDFLAGS="$LDFLAGS -lbcrypt"
+],[],[#include 
+#include ])
+;;
+  esac
+fi
+
 AM_PROG_LIBTOOL
 ACX_LT_HOST_FLAGS
 AC_SUBST(enable_shared)
diff --git a/libssp/ssp.c b/libssp/ssp.c
index 28f3e9cc64a..f07cc41fd4f 100644
--- a/libssp/ssp.c
+++ b/libssp/ssp.c
@@ -56,7 +56,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
to the console using  "CONOUT$"   */
 #if defined (_WIN32) && !defined (__CYGWIN__)
 #include 
+#ifdef HAVE_BCRYPT_ALG_HANDLE
+#include 
+#else
 #include 
+#endif
 # define _PATH_TTY "CONOUT$"
 #else
 # define _PATH_TTY "/dev/tty"
@@ -77,6 +81,21 @@ __guard_setup (void)
 return;
 
 #if defined (_WIN32) && !defined (__CYGWIN__)
+#ifdef HAVE_BCRYPT_ALG_HANDLE
+  BCRYPT_ALG_HANDLE algo = 0;
+  NTSTATUS err = BCryptOpenAlgorithmProvider(&algo, BCRYPT_RNG_ALGORITHM, 
+ NULL, 0);
+  if (BCRYPT_SUCCESS(err))
+{
+  if (BCryptGenRandom(algo, (BYTE *)&__stack_chk_guard,
+  sizeof (__stack_chk_guard), 0) && __stack_chk_guard 
!= 0)
+{
+   BCryptCloseAlgorithmProvider(algo, 0);
+   return;
+}
+  BCryptCloseAlgorithmProvider(algo, 0);
+}
+#else /* !HAVE_BCRYPT_ALG_HANDLE */
   HCRYPTPROV hprovider = 0;
   if (CryptAcquireContext(&hprovider, NULL, NULL, PROV_RSA_FULL,
   CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
@@ -89,6 +108,7 @@ __guard_setup (void)
 }
   CryptReleaseContext(hprovider, 0);
 }
+#endif /* !HAVE_BCRYPT_ALG_HANDLE */
 #else
   int fd = open ("/dev/urandom", O_RDONLY);
   if (fd != -1)
-- 
2.17.1



Re: [PATCH PR94678] aarch64: unexpected result with -mgeneral-regs-only and sve

2020-04-21 Thread Richard Sandiford
"Yangfei (Felix)"  writes:
> Hi,
>
>   It looks like there are several issues out there for sve codegen with 
> -mgeneral-regs-only. 
>   I have created a bug for that: 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94678 
>
>   We do ISA extension checks for SVE in 
> check_required_extensions(aarch64-sve-builtins.cc). 
>   I think we may also need to check -mgeneral-regs-only there and issue an 
> error message when this option is specified. 
>   This would be cheaper as compared with adding && TARGET_GENERAL_REGS_ONLY 
> to TARGET_SVE and similar macros. 

We should probably do both.

The middle end should never try to use vector patterns when the vector
modes have been disabled by !have_regs_of_mode.  But it's still wrong
for the target to provide patterns that would inevitably lead to spill
failure due to lack of registers.  So I think we should check
!TARGET_GENERAL_REGS_ONLY in TARGET_SVE.

I guess the main danger is for instructions like ADDVL, ADDPL and
CNT[BHWD] that do actually operate on general registers.  Perhaps
there'll be weird corner cases in which the compiler wants to know
the VL even for -mgeneral-regs.  I can't think of one off-hand though.

If that becomes a problem, we can introduce a second macro to control
the general register operations.  But I think we can safely assume for
now that one macro is enough.

>   Attached please find the proposed patch.  Bootstrap and tested on aarch64 
> Linux platform.  
>   Suggestions?
>
> Thanks,
> Felix
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 721928d..c109d7b 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,11 @@
> +2020-04-21  Felix Yang  
> +
> + PR target/94678
> + * config/aarch64/aarch64-sve-builtins.cc (check_required_extensions):
> + Add check for TARGET_GENERAL_REGS_ONLY.
> + (report_missing_extension): Print different error message under
> + TARGET_GENERAL_REGS_ONLY.
> +
>  2020-04-20  Andreas Krebbel  
>  
>   * config/s390/vector.md ("popcountv8hi2_vx", "popcountv4si2_vx")
> diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc 
> b/gcc/config/aarch64/aarch64-sve-builtins.cc
> index ca4a0eb..4a77db7 100644
> --- a/gcc/config/aarch64/aarch64-sve-builtins.cc
> +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
> @@ -649,11 +649,21 @@ report_missing_extension (location_t location, tree 
> fndecl,
>if (reported_missing_extension_p)
>  return;
>  
> -  error_at (location, "ACLE function %qD requires ISA extension %qs",
> - fndecl, extension);
> -  inform (location, "you can enable %qs using the command-line"
> -   " option %<-march%>, or by using the %"
> -   " attribute or pragma", extension);
> +  if (TARGET_GENERAL_REGS_ONLY)
> +{
> +  error_at (location, "ACLE function %qD requires ISA extension %qs"
> + " which is incompatible with the use of %qs",
> + fndecl, extension, "-mgeneral-regs-only");
> +}
> +  else
> +{
> +  error_at (location, "ACLE function %qD requires ISA extension %qs",
> + fndecl, extension);
> +  inform (location, "you can enable %qs using the command-line"
> +   " option %<-march%>, or by using the %"
> +   " attribute or pragma", extension);
> +}
> +
>reported_missing_extension_p = true;
>  }
>  
> @@ -666,7 +676,14 @@ check_required_extensions (location_t location, tree 
> fndecl,
>  {
>uint64_t missing_extensions = required_extensions & ~aarch64_isa_flags;
>if (missing_extensions == 0)
> -return true;
> +{
> +  if (TARGET_GENERAL_REGS_ONLY
> +   && ((DECL_MD_FUNCTION_CODE (fndecl) & AARCH64_BUILTIN_CLASS)
> +   == AARCH64_BUILTIN_SVE))
> +   missing_extensions = required_extensions;
> +  else
> + return true;
> +}

All functions processed here are SVE functions.

Rather than structure it as above, I think we should just have a
dedicated function for checking and reporting TARGET_GENERAL_REGS_ONLY,
with its own static variable to protect against streams of messages.
Maybe "check_required_registers"?  We can then call it in the return
statement above, instead of always returning true.

That way, we'll prefer to give error messages about missing extensions,
which seems like the more fundamental requirement.  We'll only mention
-mgeneral-regs-only if all extensions are present and the problem really
is that option.

I think we can then shorten the message to:

  ACLE function %qs is incompatible with the use of %qs

Thanks,
Richard


Re: [PATCH][libstd++][PR92156]

2020-04-21 Thread kamlesh kumar via Gcc-patches
Added the fix for emplace.

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 6b7e68f0e63..f35d90e548d 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -178,30 +178,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 /// Construct with a copy of @p __value as the contained object.
 template ,
   typename _Mgr = _Manager<_Tp>,
-  __any_constructible_t<_Tp, _ValueType&&> = true,
-  enable_if_t::value, bool> = true>
+  enable_if_t::value &&
+  !__is_in_place_type<_Tp>::value, bool> = true>
   any(_ValueType&& __value)
   : _M_manager(&_Mgr::_S_manage)
   {
 _Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
   }

-/// Construct with a copy of @p __value as the contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  enable_if_t<__and_v,
-  __not_>,
-  __not_<__is_in_place_type<_Tp>>>,
-  bool> = false>
-  any(_ValueType&& __value)
-  : _M_manager(&_Mgr::_S_manage)
-  {
-_Mgr::_S_create(_M_storage, __value);
-  }
-
 /// Construct with an object created from @p __args as the contained
object.
 template ,
+  typename _Tp = decay_t<_ValueType>,
   typename _Mgr = _Manager<_Tp>,
   __any_constructible_t<_Tp, _Args&&...> = false>
   explicit
@@ -214,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 /// Construct with an object created from @p __il and @p __args as
 /// the contained object.
 template ,
+  typename _Tp = decay_t<_ValueType>,
   typename _Mgr = _Manager<_Tp>,
   __any_constructible_t<_Tp, initializer_list<_Up>,
 _Args&&...> = false>
@@ -267,31 +254,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }

 /// Emplace with an object created from @p __args as the contained
object.
-template 
-  typename __any_constructible<_Decay<_ValueType>&,
-   _Decay<_ValueType>, _Args&&...>::type
+template >
+  typename __any_constructible<_Tp&,
+   _Tp, _Args&&...>::type
   emplace(_Args&&... __args)
   {
- __do_emplace<_Decay<_ValueType>>(std::forward<_Args>(__args)...);
+ __do_emplace<_Tp>(std::forward<_Args>(__args)...);
  any::_Arg __arg;
  this->_M_manager(any::_Op_access, this, &__arg);
- return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
+ return *static_cast<_Tp*>(__arg._M_obj);
   }

 /// Emplace with an object created from @p __il and @p __args as
 /// the contained object.
-template 
-  typename __any_constructible<_Decay<_ValueType>&,
-   _Decay<_ValueType>,
+template >
+  typename __any_constructible<_Tp&,
+   _Tp,
initializer_list<_Up>,
_Args&&...>::type
   emplace(initializer_list<_Up> __il, _Args&&... __args)
   {
- __do_emplace<_Decay<_ValueType>, _Up>(__il,
+ __do_emplace<_Tp, _Up>(__il,
   std::forward<_Args>(__args)...);
  any::_Arg __arg;
  this->_M_manager(any::_Op_access, this, &__arg);
- return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
+ return *static_cast<_Tp*>(__arg._M_obj);
   }

 // modifiers
diff --git a/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
new file mode 100644
index 000..c4f1ed55aee
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2014-2020 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 
+
+int main() {
+auto a = std::any(std::in_place_type, 5);
+auto b = std::any(std::in_place_type, {1});
+std::any p = std::pair(1, 1);
+(void)p;
+std::any t = std::tuple(1);
+(void)t;
+return 0;
+}
+

thanks,


On Tue, Apr 21, 2020 at 12:09 PM Ville Voutilainen <
ville.voutilai...@gmail.com> wrote:

> On Tue, 21 Apr 2020 at 09:11, Ville Voutilainen
>  wrote:
> >
> > On Tue, 21 Apr 2020 at 04:10, kamlesh kumar 
> wrote:
> > >
> > > Thank you for reviewing.
> > > without  _Decay to decay_t in the constructor which takes
> inplace_type_t,
> > > cases like this fails
> > > auto a = std::any(std::in_place_type, 5);
> > >
> > > for these constructors, standard does not say anything about
> > > not-sameness checks with any.
> > > 

RE: [PATCH v2] aarch64: Add TX3 machine model

2020-04-21 Thread Kyrylo Tkachov
Hi Anton,

> -Original Message-
> From: Gcc-patches  On Behalf Of Anton
> Youdkevitch
> Sent: 20 April 2020 19:29
> To: gcc-patches@gcc.gnu.org
> Cc: jo...@marvell.com
> Subject: [PATCH v2] aarch64: Add TX3 machine model
> 
> Here is the patch introducing thunderxt311 maching model
> for the scheduler. A name for the new chip was added to the
> list of the names to be recognized as a valid parameter for mcpu
> and mtune flags. The TX2 cost model was reused for TX3.
> 
> The previously used "cryptic" name for the command line
> parameter is replaced with the same "thunderxt311" name.
> 
> Bootstrapped on AArch64.

Thanks for the patch. I had meant to ask, do you have a copyright assignment in 
place?
We'd need one to accept a contribution of this size.
Thanks,
Kyrill

> 
> 2020-04-20 Anton Youdkevitch 
> 
> * config/aarch64/aarch64-cores.def: Add the chip name.
> * config/aarch64/aarch64-tune.md: Regenerated.
> * gcc/config/aarch64/aarch64.c: Add the cost tables for the chip.
> * gcc/config/aarch64/thunderx3t11.md: New file: add the new
> machine model for the scheduler
> * gcc/config/aarch64/aarch64.md: Include the new model.
> 
> ---
>  gcc/config/aarch64/aarch64-cores.def |   3 +
>  gcc/config/aarch64/aarch64-tune.md   |   2 +-
>  gcc/config/aarch64/aarch64.c |  27 +
>  gcc/config/aarch64/aarch64.md|   1 +
>  gcc/config/aarch64/thunderx3t11.md   | 686 +++
>  5 files changed, 718 insertions(+), 1 deletion(-)


RE: [PATCH PR94678] aarch64: unexpected result with -mgeneral-regs-only and sve

2020-04-21 Thread Yangfei (Felix)
> -Original Message-
> From: Richard Sandiford [mailto:richard.sandif...@arm.com]
> Sent: Tuesday, April 21, 2020 4:01 PM
> To: Yangfei (Felix) 
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH PR94678] aarch64: unexpected result with -mgeneral-
> regs-only and sve
> 
> "Yangfei (Felix)"  writes:
> > Hi,
> >
> >   It looks like there are several issues out there for sve codegen with -
> mgeneral-regs-only.
> >   I have created a bug for that:
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94678
> >
> >   We do ISA extension checks for SVE in
> check_required_extensions(aarch64-sve-builtins.cc).
> >   I think we may also need to check -mgeneral-regs-only there and issue an
> error message when this option is specified.
> >   This would be cheaper as compared with adding &&
> TARGET_GENERAL_REGS_ONLY to TARGET_SVE and similar macros.
> 
> We should probably do both.
> 
> The middle end should never try to use vector patterns when the vector
> modes have been disabled by !have_regs_of_mode.  But it's still wrong for
> the target to provide patterns that would inevitably lead to spill failure 
> due to
> lack of registers.  So I think we should check !TARGET_GENERAL_REGS_ONLY
> in TARGET_SVE.

Yes, that's right.  And I have a question here:
Should aarch64_sve::init_builtins ()/aarch64_sve::handle_arm_sve_h () be 
guarded by TARGET_SVE?

I mean in aarch64_init_builtins:
if (TARGET_SVE)
  aarch64_sve::init_builtins ();

and in aarch64_pragma_aarch64:
if (TARGET_SVE)
  aarch64_sve::handle_arm_sve_h ();

It looks to me that this is not wanted from the following two tests: 
./gcc.target/aarch64/sve/acle/general/nosve_1.c
./gcc.target/aarch64/sve/acle/general/nosve_2.c

Could you please confirm that?  

> I guess the main danger is for instructions like ADDVL, ADDPL and CNT[BHWD]
> that do actually operate on general registers.  Perhaps there'll be weird
> corner cases in which the compiler wants to know the VL even for -mgeneral-
> regs.  I can't think of one off-hand though.
> 
> If that becomes a problem, we can introduce a second macro to control the
> general register operations.  But I think we can safely assume for now that
> one macro is enough.

OK, let's see.


> >   Attached please find the proposed patch.  Bootstrap and tested on
> aarch64 Linux platform.
> >   Suggestions?
> >
> > Thanks,
> > Felix
> >
> > diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 721928d..c109d7b
> > 100644
> > --- a/gcc/ChangeLog
> > +++ b/gcc/ChangeLog
> > @@ -1,3 +1,11 @@
> > +2020-04-21  Felix Yang  
> > +
> > +   PR target/94678
> > +   * config/aarch64/aarch64-sve-builtins.cc
> (check_required_extensions):
> > +   Add check for TARGET_GENERAL_REGS_ONLY.
> > +   (report_missing_extension): Print different error message under
> > +   TARGET_GENERAL_REGS_ONLY.
> > +
> >  2020-04-20  Andreas Krebbel  
> >
> > * config/s390/vector.md ("popcountv8hi2_vx", "popcountv4si2_vx")
> > diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc
> > b/gcc/config/aarch64/aarch64-sve-builtins.cc
> > index ca4a0eb..4a77db7 100644
> > --- a/gcc/config/aarch64/aarch64-sve-builtins.cc
> > +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
> > @@ -649,11 +649,21 @@ report_missing_extension (location_t location,
> tree fndecl,
> >if (reported_missing_extension_p)
> >  return;
> >
> > -  error_at (location, "ACLE function %qD requires ISA extension %qs",
> > -   fndecl, extension);
> > -  inform (location, "you can enable %qs using the command-line"
> > - " option %<-march%>, or by using the %"
> > - " attribute or pragma", extension);
> > +  if (TARGET_GENERAL_REGS_ONLY)
> > +{
> > +  error_at (location, "ACLE function %qD requires ISA extension %qs"
> > +   " which is incompatible with the use of %qs",
> > +   fndecl, extension, "-mgeneral-regs-only");
> > +}
> > +  else
> > +{
> > +  error_at (location, "ACLE function %qD requires ISA extension %qs",
> > +   fndecl, extension);
> > +  inform (location, "you can enable %qs using the command-line"
> > + " option %<-march%>, or by using the %"
> > + " attribute or pragma", extension);
> > +}
> > +
> >reported_missing_extension_p = true;  }
> >
> > @@ -666,7 +676,14 @@ check_required_extensions (location_t location,
> > tree fndecl,  {
> >uint64_t missing_extensions = required_extensions & ~aarch64_isa_flags;
> >if (missing_extensions == 0)
> > -return true;
> > +{
> > +  if (TARGET_GENERAL_REGS_ONLY
> > + && ((DECL_MD_FUNCTION_CODE (fndecl) &
> AARCH64_BUILTIN_CLASS)
> > + == AARCH64_BUILTIN_SVE))
> > + missing_extensions = required_extensions;
> > +  else
> > +   return true;
> > +}
> 
> All functions processed here are SVE functions.
> 
> Rather than structure it as above, I think we should just have a dedicated
> function for checking and reporting TARGET_GENERAL_REGS_ONLY, with its
> own static variable to protect against streams of messages.
> Ma

Re: [PATCH PR94678] aarch64: unexpected result with -mgeneral-regs-only and sve

2020-04-21 Thread Jakub Jelinek via Gcc-patches
On Tue, Apr 21, 2020 at 08:37:09AM +, Yangfei (Felix) wrote:
> Yes, that's right.  And I have a question here:
> Should aarch64_sve::init_builtins ()/aarch64_sve::handle_arm_sve_h () be 
> guarded by TARGET_SVE?
> 
> I mean in aarch64_init_builtins:
> if (TARGET_SVE)
>   aarch64_sve::init_builtins ();
> 
> and in aarch64_pragma_aarch64:
> if (TARGET_SVE)
>   aarch64_sve::handle_arm_sve_h ();

If aarch64 supports target attribute/pragma, can't one function be target 
("msve")
and another one not?  Would something then register the builtins for the
functions that need it?  And on the other side, if the builtins are already
registered because of some earlier "msve" function, something should ensure
there are no ICEs even in target ("mgeneral-regs-only") functions later.

Jakub



Re: [PATCH 1/1] testsuite: Handle --save-temps in schedule-cleanups

2020-04-21 Thread Bernhard Reutner-Fischer via Gcc-patches
On 20 April 2020 13:43:42 CEST, Christophe Lyon via Gcc-patches 
 wrote:
>Some tests use --save-temps, but schedule-cleanups strictly matches
>-save-temps, so we leave many temporary files after validation.
>Instead of fixing every offending testcase, it's simpler and
>future-proof to make schedule-cleanups handle both --save-temps and
>-save-temps.

LGTM.

>
>2020-04-20  Christophe Lyon  
>
>   gcc/testsuite/
>   * lib/gcc-dg.exp (schedule-cleanups): Accept --save-temps.
>---
> gcc/testsuite/lib/gcc-dg.exp | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/gcc/testsuite/lib/gcc-dg.exp
>b/gcc/testsuite/lib/gcc-dg.exp
>index cccd3ce..27cc7c1 100644
>--- a/gcc/testsuite/lib/gcc-dg.exp
>+++ b/gcc/testsuite/lib/gcc-dg.exp
>@@ -171,7 +171,7 @@ proc schedule-cleanups { opts } {
>   verbose "dg-keep-saved-temps ${keep_saved_temps_suffixes}" 2
> }
> # -save-temps -> cleanup-saved-temps()
>-if [regexp -- {(^|\s+)-save-temps(\s+|$)} $opts] {
>+if [regexp -- {(^|\s+)-?-save-temps(\s+|$)} $opts] {
>   verbose "Cleanup -save-temps seen" 4
>   if [info exists keep_saved_temps_suffixes] {
>   append finalcode "cleanup-saved-temps
>${keep_saved_temps_suffixes}\n"



Re: [PATCH] correct strncpy range computation in restrict pass (PR 94647)

2020-04-21 Thread Richard Biener via Gcc-patches
On Mon, Apr 20, 2020 at 11:29 PM Martin Sebor via Gcc-patches
 wrote:
>
> The restrict pass computes the wrong lower bound of the size
> of accesses to member arrays passed to strncpy as the source:
> it uses the third argument to the function even though the size
> of the read is limited by the length of the source when it is
> a string.  This results in false positive -Warray-bounds
> warnings in such cases.
>
> The attached patch corrects this bug.  In addition, it adjusts
> the range of offsets of the overlap printed in diagnostics to
> be in an increasing order (i.e., [LOW, HIGH]), and removes
> a hack was in place to adjust the offsets that's obviated by
> the fix above.
>
> Tested on x86_64-linux.

OK.

Richard.

> Martin


Re: [PATCH] reject scalar array initialization with nullptr [PR94510]

2020-04-21 Thread Bernhard Reutner-Fischer via Gcc-patches
On 17 April 2020 23:18:05 CEST, Martin Sebor via Gcc-patches 
 wrote:

+   zero-initialialization for its type, taking pointers to members

s/initialialization/initialization/


Re: [PATCH] gcc-[89]: Fix sra_modify_expr handling of partial writes (PR 94482)

2020-04-21 Thread Martin Jambor
On Wed, Apr 08 2020, Martin Jambor wrote:
>
[...]
>
> 2020-04-08  Martin Jambor  
>   Richard Biener  
>
>   PR tree-optimization/94482
>   * tree-sra.c (create_access_replacement): Dump new replacement with
>   TDF_UID.
>   (sra_modify_expr): Fix handling of cases when the original EXPR writes
>   to only part of the replacement.
>   * tree-ssa-forwprop.c (pass_forwprop::execute): Properly verify
>   the first operand of combinations into REAL/IMAGPART_EXPR and
>   BIT_FIELD_REF.
>
>   testsuite/
>   * gcc.dg/torture/pr94482.c: New test.
>   * gcc.dg/tree-ssa/pr94482-2.c: Likewise.

I'd like to backport the patch to the gcc-9 and gcc-8 branches.  The
backport patch is the same for both release branches, the differences
compared to the mainline one are:

1. the code handling BIT_FIELD_REF if fwprop is not present on the
   release branches so the "fixing" hunk was dropped, and

2. the testcase options were changed to what Jakub put there on
   the mainline to suppress all vector ABI warnings.

Bootstrapped and tested on x86_64-linux.  OK for both?

Thanks,

Martin


2020-04-21  Martin Jambor  

Backport from master
2020-04-09  Martin Jambor  
Richard Biener  

PR tree-optimization/94482
* tree-sra.c (create_access_replacement): Dump new replacement with
TDF_UID.
(sra_modify_expr): Fix handling of cases when the original EXPR writes
to only part of the replacement.
* tree-ssa-forwprop.c (pass_forwprop::execute): Properly verify
the first operand of combinations into REAL/IMAGPART_EXPR and
BIT_FIELD_REF.

testsuite/
* gcc.dg/torture/pr94482.c: New test.
* gcc.dg/tree-ssa/pr94482-2.c: Likewise.
---
 gcc/ChangeLog | 15 +++
 gcc/testsuite/ChangeLog   |  9 
 gcc/testsuite/gcc.dg/torture/pr94482.c| 36 
 gcc/testsuite/gcc.dg/tree-ssa/pr94482-2.c | 50 +++
 gcc/tree-sra.c| 31 --
 gcc/tree-ssa-forwprop.c   |  3 +-
 6 files changed, 139 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr94482.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr94482-2.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7df3a0d0990..be843b53e6c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2020-04-21  Martin Jambor  
+
+   Backport from master
+   2020-04-09  Martin Jambor  
+   Richard Biener  
+
+   PR tree-optimization/94482
+   * tree-sra.c (create_access_replacement): Dump new replacement with
+   TDF_UID.
+   (sra_modify_expr): Fix handling of cases when the original EXPR writes
+   to only part of the replacement.
+   * tree-ssa-forwprop.c (pass_forwprop::execute): Properly verify
+   the first operand of combinations into REAL/IMAGPART_EXPR and
+   BIT_FIELD_REF.
+
 2020-04-17  H.J. Lu  
 
Backport from master
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3df9dd78d0c..248244343c4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2020-04-21  Martin Jambor  
+
+   Backport from master
+   2020-04-09  Martin Jambor  
+
+   PR tree-optimization/94482
+   * gcc.dg/torture/pr94482.c: New test.
+   * gcc.dg/tree-ssa/pr94482-2.c: Likewise.
+
 2020-04-17  H.J. Lu  
 
Backport from master
diff --git a/gcc/testsuite/gcc.dg/torture/pr94482.c 
b/gcc/testsuite/gcc.dg/torture/pr94482.c
new file mode 100644
index 000..9264842e349
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr94482.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-additional-options "-Wno-psabi -w" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+
+typedef unsigned V __attribute__ ((__vector_size__ (16)));
+union U
+{
+  V j;
+  unsigned long long i __attribute__ ((__vector_size__ (16)));
+};
+
+static inline __attribute__((always_inline)) V
+foo (unsigned long long a)
+{
+  union U z = { .j = (V) {} };
+  for (unsigned long i = 0; i < 1; i++)
+z.i[i] = a;
+  return z.j;
+}
+
+static inline __attribute__((always_inline)) V
+bar (V a, unsigned long long i, int q)
+{
+  union U z = { .j = a };
+  z.i[q] = i;
+  return z.j;
+}
+
+int
+main ()
+{
+  union U z = { .j = bar (foo (1729), 2, 1) };
+  if (z.i[0] != 1729)
+__builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94482-2.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr94482-2.c
new file mode 100644
index 000..fcac9d5e439
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr94482-2.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+
+typedef unsigned long V __attribute__ ((__vector_size__ (8)));
+typedef _Complex int Ci;
+typedef _Complex float Cf;
+
+union U
+{
+  Ci ci;
+  Cf cf;
+};
+
+volatile Ci vgi;
+
+Cf foo (Cf c)
+{
+  

Re: introduce target tmpnam and require it in tests relying on it

2020-04-21 Thread Bernhard Reutner-Fischer via Gcc-patches
On 17 April 2020 21:21:41 CEST, Martin Sebor via Gcc-patches 
 wrote:
>On 4/17/20 11:48 AM, Alexandre Oliva wrote:
>> On Apr  9, 2020, Alexandre Oliva  wrote:
>> 
>>> Some target C libraries that aren't recognized as freestanding don't
>>> have filesystem support, so calling tmpnam, fopen/open and
>>> remove/unlink fails to link.
>> 
>>> This patch introduces a tmpnam effective target to the testsuite,
>and
>>> requires it in the tests that call tmpnam.
>> 
>>> Tested on x86_64-linux-gnu, and with a cross to arm-eabi.
>>> Ok to install?
>> 
>> 
>>> for  gcc/testsuite/ChangeLog
>> 
>>> * lib/target-supports.exp (check_effective_target_tmpnam): New.
>>> * gcc.c-torture/execute/fprintf-2.c: Require it.
>>> * gcc.c-torture/execute/printf-2.c: Likewise.
>>> * gcc.c-torture/execute/user-printf.c: Likewise.
>> 
>> Ping?
>> 
>> https://gcc.gnu.org/pipermail/gcc-patches/2020-April/543672.html
>
>I'm okay with the changes to the tests.
>
>The target-supports.exp changes look reasonable to me as well but
>I can't approve them.  Since you said it's for targets that don't
>have file I/O functions I wonder if the name would better reflect
>that if it were called, say, check_effective_target_fileio?

Since tmpnam is obsolescent in SUSv4 and hence a libc is fine to omit it, I'd 
rather fix the tests to use functions that are known to stay.

If you want a fileio predicate then please do not keys it off obsolescent 
functions.

TIA,
>
>I don't expect it's necessary to worry about handling errors in
>the .exp test.
>
>Martin



Re: [PATCH] gcc-[89]: Fix sra_modify_expr handling of partial writes (PR 94482)

2020-04-21 Thread Richard Biener
On Tue, 21 Apr 2020, Martin Jambor wrote:

> On Wed, Apr 08 2020, Martin Jambor wrote:
> >
> [...]
> >
> > 2020-04-08  Martin Jambor  
> > Richard Biener  
> >
> > PR tree-optimization/94482
> > * tree-sra.c (create_access_replacement): Dump new replacement with
> > TDF_UID.
> > (sra_modify_expr): Fix handling of cases when the original EXPR writes
> > to only part of the replacement.
> > * tree-ssa-forwprop.c (pass_forwprop::execute): Properly verify
> > the first operand of combinations into REAL/IMAGPART_EXPR and
> > BIT_FIELD_REF.
> >
> > testsuite/
> > * gcc.dg/torture/pr94482.c: New test.
> > * gcc.dg/tree-ssa/pr94482-2.c: Likewise.
> 
> I'd like to backport the patch to the gcc-9 and gcc-8 branches.  The
> backport patch is the same for both release branches, the differences
> compared to the mainline one are:
> 
> 1. the code handling BIT_FIELD_REF if fwprop is not present on the
>release branches so the "fixing" hunk was dropped, and
> 
> 2. the testcase options were changed to what Jakub put there on
>the mainline to suppress all vector ABI warnings.
> 
> Bootstrapped and tested on x86_64-linux.  OK for both?

OK.

Thanks,
Richard.

> Thanks,
> 
> Martin
> 
> 
> 2020-04-21  Martin Jambor  
> 
> Backport from master
>   2020-04-09  Martin Jambor  
> Richard Biener  
> 
>   PR tree-optimization/94482
>   * tree-sra.c (create_access_replacement): Dump new replacement with
>   TDF_UID.
>   (sra_modify_expr): Fix handling of cases when the original EXPR writes
>   to only part of the replacement.
>   * tree-ssa-forwprop.c (pass_forwprop::execute): Properly verify
>   the first operand of combinations into REAL/IMAGPART_EXPR and
>   BIT_FIELD_REF.
> 
>   testsuite/
>   * gcc.dg/torture/pr94482.c: New test.
>   * gcc.dg/tree-ssa/pr94482-2.c: Likewise.
> ---
>  gcc/ChangeLog | 15 +++
>  gcc/testsuite/ChangeLog   |  9 
>  gcc/testsuite/gcc.dg/torture/pr94482.c| 36 
>  gcc/testsuite/gcc.dg/tree-ssa/pr94482-2.c | 50 +++
>  gcc/tree-sra.c| 31 --
>  gcc/tree-ssa-forwprop.c   |  3 +-
>  6 files changed, 139 insertions(+), 5 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/torture/pr94482.c
>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr94482-2.c
> 
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 7df3a0d0990..be843b53e6c 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,18 @@
> +2020-04-21  Martin Jambor  
> +
> + Backport from master
> + 2020-04-09  Martin Jambor  
> + Richard Biener  
> +
> + PR tree-optimization/94482
> + * tree-sra.c (create_access_replacement): Dump new replacement with
> + TDF_UID.
> + (sra_modify_expr): Fix handling of cases when the original EXPR writes
> + to only part of the replacement.
> + * tree-ssa-forwprop.c (pass_forwprop::execute): Properly verify
> + the first operand of combinations into REAL/IMAGPART_EXPR and
> + BIT_FIELD_REF.
> +
>  2020-04-17  H.J. Lu  
>  
>   Backport from master
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index 3df9dd78d0c..248244343c4 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,12 @@
> +2020-04-21  Martin Jambor  
> +
> + Backport from master
> + 2020-04-09  Martin Jambor  
> +
> + PR tree-optimization/94482
> + * gcc.dg/torture/pr94482.c: New test.
> + * gcc.dg/tree-ssa/pr94482-2.c: Likewise.
> +
>  2020-04-17  H.J. Lu  
>  
>   Backport from master
> diff --git a/gcc/testsuite/gcc.dg/torture/pr94482.c 
> b/gcc/testsuite/gcc.dg/torture/pr94482.c
> new file mode 100644
> index 000..9264842e349
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/torture/pr94482.c
> @@ -0,0 +1,36 @@
> +/* { dg-do run } */
> +/* { dg-additional-options "-Wno-psabi -w" } */
> +/* { dg-additional-options "-msse2" { target sse2_runtime } } */
> +
> +typedef unsigned V __attribute__ ((__vector_size__ (16)));
> +union U
> +{
> +  V j;
> +  unsigned long long i __attribute__ ((__vector_size__ (16)));
> +};
> +
> +static inline __attribute__((always_inline)) V
> +foo (unsigned long long a)
> +{
> +  union U z = { .j = (V) {} };
> +  for (unsigned long i = 0; i < 1; i++)
> +z.i[i] = a;
> +  return z.j;
> +}
> +
> +static inline __attribute__((always_inline)) V
> +bar (V a, unsigned long long i, int q)
> +{
> +  union U z = { .j = a };
> +  z.i[q] = i;
> +  return z.j;
> +}
> +
> +int
> +main ()
> +{
> +  union U z = { .j = bar (foo (1729), 2, 1) };
> +  if (z.i[0] != 1729)
> +__builtin_abort ();
> +  return 0;
> +}
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94482-2.c 
> b/gcc/testsuite/gcc.dg/tree-ssa/pr94482-2.c
> new file mode 100644
> index 000..fcac9d5e439
> --- /dev/null
> +++ b/gcc/testsuite/gcc.d

Re: [PR93488] [OpenACC] ICE in type-cast 'async', 'wait' clauses

2020-04-21 Thread Thomas Schwinge
Hi Andrew!

On 2020-01-30T21:12:59+, Andrew Stubbs  wrote:
> On 29/01/2020 12:30, Thomas Schwinge wrote:
>> As can be seen in the code a few lines below, the very same problem also
>> exists for the 'wait' clause; it seems reasonable to fix both at the same
>> time.  This is not a recent regression, but a user-visible valid-code ICE
>> that has existed "forever"; I filed  "ICE in
>> type-cast 'async', 'wait' clauses" for tracking.  This problem is similar
>> to the OpenMP 'device' clause  "ICE in
>> verify_gimple_in_cfg, at tree-cfg.c:5212"; I suggest we also use
>> 'force_gimple_operand_gsi' instead of manually doing your suggested
>> 'create_tmp_var', 'gimple_build_assign', 'gsi_insert_before'.  Include a
>> test case that covers all relevant code paths; I've attached a test case
>> to the PR, but I've not verified whether "that covers *all* relevant code
>> paths".  This should then be backported to all GCC release branches; I
>> can easily test the backports for you, if you're not already set up to do
>> such testing.
>
> How's this?

Thanks, looks good!

> Normalize GOACC_parallel_keyed async and wait parameters

Oh, not only 'GOACC_parallel_keyed', but also other OpenACC directives.
Maybe simply "[OpenACC] Avoid ICE in type-cast 'async', 'wait' clauses"?
;-P

To record the review effort, please include "Reviewed-by: Thomas Schwinge
" in the commit log, see
.


Grüße
 Thomas


> diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
> index cd423ad799e..ec4baf46965 100644
> --- a/gcc/omp-expand.c
> +++ b/gcc/omp-expand.c
> @@ -8418,7 +8418,9 @@ expand_omp_target (struct omp_region *region)
> i_async));
> }
>   if (t_async)
> -   args.safe_push (t_async);
> +   args.safe_push (force_gimple_operand_gsi (&gsi, t_async, true,
> + NULL_TREE, true,
> + GSI_SAME_STMT));
>
>   /* Save the argument index, and ... */
>   unsigned t_wait_idx = args.length ();
> @@ -8431,9 +8433,12 @@ expand_omp_target (struct omp_region *region)
>   for (; c; c = OMP_CLAUSE_CHAIN (c))
> if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_WAIT)
>   {
> -   args.safe_push (fold_convert_loc (OMP_CLAUSE_LOCATION (c),
> - integer_type_node,
> - OMP_CLAUSE_WAIT_EXPR (c)));
> +   tree arg = fold_convert_loc (OMP_CLAUSE_LOCATION (c),
> +integer_type_node,
> +OMP_CLAUSE_WAIT_EXPR (c));
> +   arg = force_gimple_operand_gsi (&gsi, arg, true, NULL_TREE, true,
> +   GSI_SAME_STMT);
> +   args.safe_push (arg);
> num_waits++;
>   }
>
> diff --git a/gcc/testsuite/c-c++-common/goacc/pr93488.c 
> b/gcc/testsuite/c-c++-common/goacc/pr93488.c
> new file mode 100644
> index 000..6fddad919d2
> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/goacc/pr93488.c
> @@ -0,0 +1,22 @@
> +/* PR middle-end/93488
> +
> +   Ensure that wait and async arguments can be cast to the correct type
> +   without breaking gimple verification.  */
> +
> +void test()
> +{
> +  /* int */ unsigned char a = 1;
> +  /* int */ unsigned char w = 1;
> +
> +#pragma acc parallel wait(w) async(a)
> +  ;
> +#pragma acc kernels wait(w) async(a)
> +  ;
> +#pragma acc serial wait(w) async(a)
> +  ;
> +  int data = 0;
> +#pragma acc enter data wait(w) async(a) create(data)
> +#pragma acc update wait(w) async(a) device(data)
> +#pragma acc exit data wait(w) async(a) delete(data)
> +#pragma acc wait(w) async(a)
> +}
-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter


[PATCH] testsuite: Extend C++ struct-layout-1.exp testing to test C++14 vs. C++17 interoperability of structs with empty bases [PR94383]

2020-04-21 Thread Jakub Jelinek via Gcc-patches
Hi!

Jonathan reported an ABI incompatibility between C++14 and C++17 in
passing some aggregates with empty bases on aarch64 (and apparently on arm
too).

The following patch adds 3000 (by default) tests for such interoperability,
using the struct-layout-1* framework.  The current 3000 tests are generated
as is (so unchanged from previous ones), and afterwards there is another set
of 3000 ones, where always one of the tNNN_x.C and tNNN_y.C tests get added
-std=c++14 -DCXX14_VS_CXX17 and another one -std=c++17 -DCXX14_VS_CXX17
options (which one which is chosen pseudo-randomly), which causes the
structs to have an empty base.

I haven't added (yet) checks if the alternate compiler does support these
options (I think that can be done incrementally), so for now this testing is
done only if the alternate compiler is not used.

I had to fix a bug in the flexible array handling, because while we were
lucky in the 3000 generated tests not to have toplevel fields after field
with flexible array members, in the next 3000 we aren't lucky anymore.
But even with that change, diff -upr between old and new
testsuite/g++/g++.dg/g++.dg-struct-layout-1/ doesn't show any differences
except for the ^Only in... messages for the new tests in there.

Bootstrapped/regtested on x86_64-linux and i686-linux and additionally
tested on aarch64-linux, where
FAIL: tmpdir-g++.dg-struct-layout-1/t032 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute 
FAIL: tmpdir-g++.dg-struct-layout-1/t056 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute 
FAIL: tmpdir-g++.dg-struct-layout-1/t057 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute 
FAIL: tmpdir-g++.dg-struct-layout-1/t058 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute 
FAIL: tmpdir-g++.dg-struct-layout-1/t059 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute 
because of the backend bug, and with that bug fixed it succeeds.
Matthew has kindly tested it also on aarch64-linux and arm*-*.

The primary goal of the patch is catch if some targets other than aarch64 or
arm aren't affected too.

Ok for trunk?

2020-04-21  Jakub Jelinek  

PR c++/94383
* g++.dg/compat/struct-layout-1.exp: If !$use_alt, add -c to generator
args.
* g++.dg/compat/struct-layout-1_generate.c (dg_options): Add another
%s to the start of dg-options arg.
(cxx14_vs_cxx17, do_cxx14_vs_cxx17): New variables.
(switchfiles): If cxx14_vs_cxx17, prepend -std=c++14 -DCXX14_VS_CXX17
or -std=c++17 -DCXX17_VS_CXX14 - randomly - to dg-options.
(output): Don't append further fields once one with flexible array
member is added.
(generate_random_tests): Don't use toplevel unions if cxx14_vs_cxx17.
(main): If -c, emit second set of tests for -std=c++14 vs. -std=c++17
testing.
* g++.dg/compat/struct-layout-1_x1.h (empty_base): New type.
(EMPTY_BASE): Define.
(TX): Use EMPTY_BASE.
* g++.dg/compat/struct-layout-1_y1.h (empty_base): New type.
(EMPTY_BASE): Define.
(TX): Use EMPTY_BASE.

--- gcc/testsuite/g++.dg/compat/struct-layout-1.exp.jj  2020-01-12 
11:54:37.044403889 +0100
+++ gcc/testsuite/g++.dg/compat/struct-layout-1.exp 2020-04-20 
19:00:54.956968103 +0200
@@ -142,6 +142,9 @@ if { $status == 0 } then {
 file delete -force $tstobjdir
 file mkdir $tstobjdir
 set generator_args "-s $srcdir/$subdir -d $tstobjdir"
+if { $use_alt == 0 } then {
+   set generator_args "$generator_args -c"
+}
 if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
set generator_args "$generator_args -n 15000"
 }
--- gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c.jj   2020-01-12 
11:54:37.045403874 +0100
+++ gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c  2020-04-20 
20:00:35.428544841 +0200
@@ -1,5 +1,5 @@
 /* Structure layout test generator.
-   Copyright (C) 2004-2014
+   Copyright (C) 2004-2020
Free Software Foundation, Inc.
Contributed by Jakub Jelinek .
 
@@ -44,12 +44,12 @@ along with GCC; see the file COPYING3.
 #endif
 
 const char *dg_options[] = {
-"/* { dg-options \"%s-I%s -Wno-abi\" } */\n",
-"/* { dg-options \"%s-I%s -mno-mmx -Wno-abi\" { target i?86-*-* x86_64-*-* } } 
*/\n",
-"/* { dg-options \"%s-I%s -fno-common\" { target hppa*-*-hpux* 
powerpc*-*-darwin* *-*-mingw32* *-*-cygwin* } } */\n",
-"/* { dg-options \"%s-I%s -mno-mmx -fno-common -Wno-abi\" { target 
i?86-*-darwin* x86_64-*-darwin* i?86-*-mingw32* x86_64-*-mingw32* 
i?86-*-cygwin* } } */\n",
-"/* { dg-options \"%s-I%s -mno-base-addresses\" { target mmix-*-* } } */\n",
-"/* { dg-options \"%s-I%s -mlongcalls -mtext-section-literals\" { target 
xtensa*-*-* } } */\n"
+"/* { dg-options \"%s%s-I%s -Wno-abi\" } */\n",
+"/* { dg-options \"%s%s-I%s -mno-mmx -Wno-abi\" { target i?86-*-* x86_64-*-* } 
} */\n",
+"/* { dg-options \"%s%s-I%s -fno-common\" { target hppa*-*-hpux* 
powerpc*-*-darwin* *-*-mingw32* *-*-cygwin* } } */\n",
+"/* { dg-options \"%s%s-I%s -mno-mmx -fno-common -Wno-abi\" { target 
i

Re: [PATCH PR94678] aarch64: unexpected result with -mgeneral-regs-only and sve

2020-04-21 Thread Richard Sandiford
"Yangfei (Felix)"  writes:
>> -Original Message-
>> From: Richard Sandiford [mailto:richard.sandif...@arm.com]
>> Sent: Tuesday, April 21, 2020 4:01 PM
>> To: Yangfei (Felix) 
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [PATCH PR94678] aarch64: unexpected result with -mgeneral-
>> regs-only and sve
>> 
>> "Yangfei (Felix)"  writes:
>> > Hi,
>> >
>> >   It looks like there are several issues out there for sve codegen with -
>> mgeneral-regs-only.
>> >   I have created a bug for that:
>> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94678
>> >
>> >   We do ISA extension checks for SVE in
>> check_required_extensions(aarch64-sve-builtins.cc).
>> >   I think we may also need to check -mgeneral-regs-only there and issue an
>> error message when this option is specified.
>> >   This would be cheaper as compared with adding &&
>> TARGET_GENERAL_REGS_ONLY to TARGET_SVE and similar macros.
>> 
>> We should probably do both.
>> 
>> The middle end should never try to use vector patterns when the vector
>> modes have been disabled by !have_regs_of_mode.  But it's still wrong for
>> the target to provide patterns that would inevitably lead to spill failure 
>> due to
>> lack of registers.  So I think we should check !TARGET_GENERAL_REGS_ONLY
>> in TARGET_SVE.
>
> Yes, that's right.  And I have a question here:
> Should aarch64_sve::init_builtins ()/aarch64_sve::handle_arm_sve_h () be 
> guarded by TARGET_SVE?
>
> I mean in aarch64_init_builtins:
> if (TARGET_SVE)
>   aarch64_sve::init_builtins ();
>
> and in aarch64_pragma_aarch64:
> if (TARGET_SVE)
>   aarch64_sve::handle_arm_sve_h ();
>
> It looks to me that this is not wanted from the following two tests: 
> ./gcc.target/aarch64/sve/acle/general/nosve_1.c
> ./gcc.target/aarch64/sve/acle/general/nosve_2.c
>
> Could you please confirm that?  

Yeah, that's right.  As Jakub says, the SVE stuff is (deliberately)
registered unconditionally because it's possible to switch SVE on
and off later.  Also, protecting it with just TARGET_SVE would mean
that we'd continue to register SVE2 functions even if SVE2 isn't
currently enabled.

So what matters is whether SVE is enabled at the point of use, not the
point of the #include.  FWIW, arm_neon.h works the same way: the same
functions are defined regardless of what the current prevailing
architecture is, and what matters is whether the necessary features are
enabled when the functions are called.  (Inlining fails if they're not.)
But because we're implementing arm_sve.h directly in the compiler,
we don't need the overhead of a full target switch when defining
the functions.

And like you say, the second of the above tests makes sure that turning
SVE on later does indeed work, while the first makes sure that we get an
appropriate error if SVE is disabled at the point of use.

Thanks,
Richard


[PATCH] coroutines: Pass class reference to promise param preview [PR94682]

2020-04-21 Thread Iain Sandoe
Hi

As reported in the PR, per [dcl.fct.def.coroutine]/4 we should
be passing a reference to the object to the promise parameter
preview, and we are currently passing a pointer (this).

tested on x86_64-darwin, and in progress on x86_64/powerpc64-linux.
OK for master if regtesting is successful on Linux?
thanks
Iain

P.S. Probably:

tree ct = TREE_TYPE (tt);
tree rt = cp_build_reference_type (ct, false);
tree this_ref = build_nop (rt, arg);

would be sufficient, but I’m a bit nervous about using short-circuits
after the experience with the ramp return.



gcc/cp/ChangeLog:

2020-04-21  Iain Sandoe  

* coroutines.cc (struct param_info): Add a field to
note that the param is 'this'.
(morph_fn_to_coro): Convert this to a reference before
using it in the promise parameter preview.

gcc/testsuite/ChangeLog:

2020-04-21  Iain Sandoe  

* g++.dg/coroutines/promise-parm-preview-this.C: New test.
---
 gcc/cp/coroutines.cc  | 32 +--
 .../coroutines/promise-parm-preview-this.C| 27 
 2 files changed, 50 insertions(+), 9 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/coroutines/promise-parm-preview-this.C

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 30676eba6c2..b1d91f84cae 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -1760,14 +1760,15 @@ transform_await_wrapper (tree *stmt, int *do_subtree, 
void *d)
 
 struct param_info
 {
-  tree field_id;  /* The name of the copy in the coroutine frame.  */
+  tree field_id; /* The name of the copy in the coroutine frame.  */
   vec *body_uses; /* Worklist of uses, void if there are none.  */
-  tree frame_type; /* The type used to represent this parm in the frame.  */
-  tree orig_type;  /* The original type of the parm (not as passed).  */
-  bool by_ref;  /* Was passed by reference.  */
-  bool rv_ref;  /* Was an rvalue reference.  */
-  bool pt_ref;  /* Was a pointer to object.  */
+  tree frame_type;   /* The type used to represent this parm in the frame.  */
+  tree orig_type;/* The original type of the parm (not as passed).  */
+  bool by_ref;   /* Was passed by reference.  */
+  bool rv_ref;   /* Was an rvalue reference.  */
+  bool pt_ref;   /* Was a pointer to object.  */
   bool trivial_dtor; /* The frame type has a trivial DTOR.  */
+  bool this_ptr; /* Is 'this' */
 };
 
 struct local_var_info
@@ -3279,7 +3280,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree 
*destroyer)
}
  else
parm.frame_type = actual_type;
-
+ parm.this_ptr = is_this_parameter (arg);
  parm.trivial_dtor = TYPE_HAS_TRIVIAL_DESTRUCTOR (parm.frame_type);
  tree pname = DECL_NAME (arg);
  char *buf = xasprintf ("__parm.%s", IDENTIFIER_POINTER (pname));
@@ -3617,8 +3618,21 @@ morph_fn_to_coro (tree orig, tree *resumer, tree 
*destroyer)
  false, tf_warning_or_error);
 
  /* Add this to the promise CTOR arguments list, accounting for
-refs.  */
- if (parm.by_ref)
+refs and this ptr.  */
+ if (parm.this_ptr)
+   {
+ /* We pass a reference to *this to the param preview.  */
+ tree tt = TREE_TYPE (arg);
+ gcc_checking_assert (POINTER_TYPE_P (tt));
+ tree ct = TREE_TYPE (tt);
+ tree this_ref = build1 (INDIRECT_REF, ct, arg);
+ tree rt = cp_build_reference_type (ct, false);
+ this_ref = convert_to_reference (rt, this_ref, CONV_STATIC,
+  LOOKUP_NORMAL , NULL_TREE,
+  tf_warning_or_error);
+ vec_safe_push (promise_args, this_ref);
+   }
+ else if (parm.by_ref)
vec_safe_push (promise_args, fld_idx);
  else if (parm.rv_ref)
vec_safe_push (promise_args, rvalue (fld_idx));
diff --git a/gcc/testsuite/g++.dg/coroutines/promise-parm-preview-this.C 
b/gcc/testsuite/g++.dg/coroutines/promise-parm-preview-this.C
new file mode 100644
index 000..ca96f373da2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/promise-parm-preview-this.C
@@ -0,0 +1,27 @@
+#include "coro.h"
+
+struct promise;
+
+struct future
+{
+using promise_type = promise;
+};
+
+struct promise
+{
+  template
+  promise(Class &,int) { static_assert(!std::is_pointer::value, ""); }
+
+  coro::suspend_never initial_suspend() { return {}; }
+  coro::suspend_never final_suspend() { return {}; }
+
+  future get_return_object() { return {}; }
+
+  void return_value(int) {}
+  void unhandled_exception() {}
+};
+
+struct bar
+{
+  future foo(int param) { co_return 0; }
+};
\ No newline at end of file
-- 
2.24.1




[committed] testsuite: Add testcase for already fixed PR [PR94686]

2020-04-21 Thread Jakub Jelinek via Gcc-patches
Hi!

This has been fixed by the PR71311 r7-1170-g4618c453205f18 change.

Tested on x86_64-linux (also with gcc 6 where it ICEs), committed to trunk
as obvious.

2020-04-21  Jakub Jelinek  

PR c/94686
* gcc.c-torture/compile/pr94686.c: New test.

--- gcc/testsuite/gcc.c-torture/compile/pr94686.c.jj2020-04-21 
12:44:51.039614140 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr94686.c   2020-04-21 
12:44:11.444223427 +0200
@@ -0,0 +1,9 @@
+/* PR c/94686 */
+
+int a = 0, b = 0;
+
+int
+foo (void)
+{
+  return (int) (long) (b * 0 >= a & b * 0 >= a);
+}


Jakub



[Patch v2, fortran] PR fortran/90350 - ubound ICE on assumed size array even though explicit bound is specified

2020-04-21 Thread José Rui Faustino de Sousa via Gcc-patches

Hi again!

Proposed patch to Bug 90350 - ubound ICE on assumed size array even 
though explicit bound is specified


Patch tested only on x86_64-pc-linux-gnu.

Best regards,
José Rui

2020-4-19  José Rui Faustino de Sousa  

 PR fortran/90350
 * simplify.c (simplify_bound): In the case of assumed-size arrays check
 if the reference is to a full array.

2020-4-19  José Rui Faustino de Sousa  

 PR fortran/90350
 * PR90350.f90: New test.

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index c7a4f77..eb8b2af 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -4157,6 +4157,7 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr 
*kind, int upper)
 {
   gfc_ref *ref;
   gfc_array_spec *as;
+  ar_type type = AR_UNKNOWN;
   int d;
 
   if (array->ts.type == BT_CLASS)
@@ -4180,6 +4181,7 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr 
*kind, int upper)
   switch (ref->type)
{
case REF_ARRAY:
+ type = ref->u.ar.type;
  switch (ref->u.ar.type)
{
case AR_ELEMENT:
@@ -4233,7 +4235,7 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr 
*kind, int upper)
   int k;
 
   /* UBOUND(ARRAY) is not valid for an assumed-size array.  */
-  if (upper && as && as->type == AS_ASSUMED_SIZE)
+  if (upper && type == AR_FULL && as && as->type == AS_ASSUMED_SIZE)
{
  /* An error message will be emitted in
 check_assumed_size_reference (resolve.c).  */
diff --git a/gcc/testsuite/gfortran.dg/PR90350.f90 
b/gcc/testsuite/gfortran.dg/PR90350.f90
new file mode 100644
index 000..2e2cf10
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR90350.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+!
+! Test the fix for PR90350
+!
+! Contributed by  
+!
+
+program artificial
+implicit none
+integer :: arr(-10:10)
+   call asub(arr,size(arr))
+end program artificial
+subroutine asub(arr,n)
+integer,intent(in) :: arr(*)
+integer,intent(in) :: n
+   write(*,*)'UPPER=',ubound(arr(:n))
+   write(*,*)'LOWER=',lbound(arr(:n))
+   write(*,*)'SIZE=',size(arr(:n))
+end subroutine asub


Re: [PATCH], rs6000, PR/target 94622, Be more careful with plq for atomic_load

2020-04-21 Thread Segher Boessenkool
[ I never received the original mail?  Not the one sent to me directly,
  that is. ]

Subject: [PATCH], rs6000, PR/target 94622, Be more careful with plq for 
atomic_load

That is too long...  Also, PR should go at the end, etc., so smth like
Subject: [PATCH] rs6000: Be more careful with plq for atomic_load 
(PR94622)
but that is still too long...  write a more succinct subject?  Something
that actually says more than "Be more careful"...  just "Fix" is better
already ;-)

On Mon, Apr 20, 2020 at 04:56:42PM -0500, will schmidt wrote:
> On Mon, 2020-04-20 at 14:00 -0500, Aaron Sawdey via Gcc-patches wrote:
> > For future architecture with prefix instructions, always use plq
> > rather than lq for atomi load of quadword. Then we never have to
> 
> atomic :-)
> 
> > do the doubleword swap on little endian. Before this fix, -mno-pcrel
> > would generate lq with the doubleword swap (which was ok) and -mpcrel
> > would generate plq, also with the doubleword swap, which was wrong.

Was wrong on LE, not on BE.

> > 2020-04-20  Aaron Sawdey  
> > 
> > PR target/94622
> > * config/rs6000/sync.md (load_quadpti): Make this have attr
> > prefixed
> > if TARGET_PREFIXED.
> 
> I'd rearrange to be
> : Add attr "prefixed" if TARGET_PREFIXED.
> 
> but thats mostly cosmetic, so no big deal.  

It's easier to read and understand ;-)

> > (atomic_load): Do not swap doublewords if TARGET_PREFIXED
> > as
> > plq will be used and doesn't need it.
> 
> Ok.   

But it is used on BE as well?  Needs testing (I don't actually mind
either way, but it should be clear and explicit in the code, as well as
in the patch -- just add some words, it does look okay).

> > diff --git a/gcc/config/rs6000/sync.md b/gcc/config/rs6000/sync.md
> > index f27edc77b6a..64dfda6ef75 100644
> > --- a/gcc/config/rs6000/sync.md
> > +++ b/gcc/config/rs6000/sync.md
> > @@ -129,7 +129,10 @@ (define_insn "load_quadpti"
> >"TARGET_SYNC_TI
> > && !reg_mentioned_p (operands[0], operands[1])"
> >"lq %0,%1"
> > -  [(set_attr "type" "load")])
> > +  [(set_attr "type" "load")
> > +   (set_attr "prefixed" (if_then_else (match_test "TARGET_PREFIXED")
> > +  (const_string "yes")
> > +  (const_string "no")))])

This makes it use plq on BE as well.  This attribute is what *enables*
the "p" character to be output -- so please add a comment here, that we
also do plq on BE?

> >  (define_expand "atomic_load"
> >[(set (match_operand:AINT 0 "register_operand")  ;;
> > output
> > @@ -162,7 +165,7 @@ (define_expand "atomic_load"
> > 
> >emit_insn (gen_load_quadpti (pti_reg, op1));
> > 
> > -  if (WORDS_BIG_ENDIAN)
> > +  if (WORDS_BIG_ENDIAN || TARGET_PREFIXED)
> > emit_move_insn (op0, gen_lowpart (TImode, pti_reg));
> >else
> > {

And another comment here I suppose?

Looks fine otherwise :-)


Segher


[PATCH] aarch64:Add an error message in large code model for ilp32 [PR94577]

2020-04-21 Thread duanbo (C)

Hi

> -Original Message-
> From: Richard Sandiford [mailto:richard.sandif...@arm.com]
> Sent: Monday, April 20, 2020 10:42 PM
> To: duanbo (C) 
> Cc: GCC Patches 
> Subject: Re: [PATCH] aarch64:Add an error message in large code model for
> ilp32 [PR94577]
> 
> "duanbo (C)"  writes:
> > Hi
> >
> >> -Original Message-
> >> From: Richard Sandiford [mailto:richard.sandif...@arm.com]
> >> Sent: Friday, April 17, 2020 9:38 PM
> >> To: duanbo (C) 
> >> Cc: Wilco Dijkstra ; gcc-patches@gcc.gnu.org
> >> Subject: Re: [PATCH PR94577] [AArch64] :Add an error message in large
> >> code model for ilp32
> >>
> >> "duanbo (C)"  writes:
> >> > Thank you for your suggestions.
> >> > I have modified accordingly and a full test has been carried, no
> >> > new failure
> >> witnessed.
> >> > Attached please find the new patch which has been adjusted to be
> >> > suitable
> >> for git am.
> >> > Does the v2 patch look better ?
> >> >
> >> > Thanks,
> >> > Duan bo
> >> >
> >> > -Original Message-
> >> > From: Wilco Dijkstra [mailto:wilco.dijks...@arm.com]
> >> > Sent: Tuesday, April 14, 2020 4:40 AM
> >> > To: GCC Patches ; duanbo (C)
> >> > 
> >> > Subject: Re: [PATCH PR2] aarch64:Add an error message in large
> >> > code model for ilp32
> >> >
> >> > Hi Duanbo,
> >> >
> >> >> This is a simple fix for pr94577.
> >> >> The option -mabi=ilp32 should not be used in large code model.
> >> >> Like x86,
> >> using -mx32 and -mcmodel=large together will result in an error message.
> >> >> On aarch64, there is no error message for this option conflict.
> >> >> A solution to this problem can be found in the attached patch.
> >> >> Bootstrap and tested on aarch64 Linux platform. No new regression
> >> witnessed.
> >> >> Any suggestion?
> >> >
> >> > Thanks for your patch, more than 4GB doesn't make any sense with
> >> > ILP32
> >> indeed.
> >> > A few suggestions:
> >> >
> >> > It would be good to also update the documentation for
> >> > -mcmodel=large to
> >> state it is incompatible with -fpic, -fPIC and -mabi=ilp32.
> >> >
> >> > The patch adds a another switch statement on mcmodel that ignores
> >> > the
> >> previous processing done (which may changes the selected mcmodel). It
> >> would be safer and more concise to use one switch at the top level
> >> and in each case use an if statement to handle the special cases.
> >> >
> >> > A few minor nitpics:
> >> >
> >> > +   PR  target/94577
> >> > +   * gcc.target/aarch64/pr94577.c : New test
> >> >
> >> > Just like comments, there should be a '.' at the end of changelog 
> >> > entries.
> >> >
> >> > AFAICT the format isn't exactly specified, but the email header
> >> > should be
> >> like:
> >> >
> >> > [PATCH][AArch64] PR94577: Add an error message in large code model
> >> > for
> >> > ilp32
> >> >
> >> > Sometimes the PR number is also placed in brackets.
> >> >
> >> > Cheers,
> >> > Wilco
> >> >
> >> >
> >> > From feb16a5e5d35d4f632e1be10ce0ac4f4c3505d22 Mon Sep 17
> 00:00:00
> >> 2001
> >> > From: Duan bo 
> >> > Date: Wed, 15 Apr 2020 05:19:31 -0400
> >> > Subject: [PATCH] aarch64: Add an error message in large code model
> >> > for
> >> > ilp32  [PR94577]
> >> >
> >> > The option -mabi=ilp32 should not be used in large code model. An
> >> > error message is added for the option conflict.
> >> >
> >> > 2020-04-15  Duan bo  
> >> >
> >> >  PR target/94577
> >> >  * config/aarch64/aarch64.c: Add an error message for option conflict.
> >> >  * doc/invoke.texi (-mcmodel=large): Mention that -mcmodel=large
> >> is
> >> >  incompatible with -fpic, -fPIC and -mabi=ilp32.
> >> >
> >> > 2020-04-15  Duan bo  
> >> >
> >> >  PR target/94577
> >> >  * gcc.target/aarch64/pr94577.c: New test.
> >> > ---
> >> >  gcc/ChangeLog  |  7 
> >> >  gcc/config/aarch64/aarch64.c   | 41 --
> >> >  gcc/doc/invoke.texi|  4 ++-
> >> >  gcc/testsuite/ChangeLog|  5 +++
> >> >  gcc/testsuite/gcc.target/aarch64/pr94577.c | 10 ++
> >> >  5 files changed, 47 insertions(+), 20 deletions(-)  create mode
> >> > 100644 gcc/testsuite/gcc.target/aarch64/pr94577.c
> >> >
> >> > diff --git a/gcc/ChangeLog b/gcc/ChangeLog index
> >> > 3c6a45e8fe7..c2f1fcb7bff 100644
> >> > --- a/gcc/ChangeLog
> >> > +++ b/gcc/ChangeLog
> >> > @@ -1,3 +1,10 @@
> >> > +2020-04-15  Duan bo  
> >> > +
> >> > +PR target/94577
> >> > +* config/aarch64/aarch64.c: Add an error message for option 
> >> > conflict.
> >> > +* doc/invoke.texi (-mcmodel=large): Mention that -mcmodel=large
> >> is
> >> > +incompatible with -fpic, -fPIC and -mabi=ilp32.
> >> > +
> >> >  2020-04-14  Max Filippov  
> >> >
> >> >  PR target/94584
> >> > diff --git a/gcc/config/aarch64/aarch64.c
> >> > b/gcc/config/aarch64/aarch64.c index 4af562a81ea..f8a38bd899a
> >> > 100644
> >> > --- a/gcc/config/aarch64/aarch64.c
> >> > +++ b/gcc/config/aarch64/aarch64.c
> >> > @@ -14707,32 +14707,35 @

Re: [PATCH][libstd++][PR92156]

2020-04-21 Thread Ville Voutilainen via Gcc-patches
On Tue, 21 Apr 2020 at 11:29, kamlesh kumar  wrote:
>
> Added the fix for emplace.
>
> diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
> index 6b7e68f0e63..f35d90e548d 100644
> --- a/libstdc++-v3/include/std/any
> +++ b/libstdc++-v3/include/std/any
> @@ -178,30 +178,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>  /// Construct with a copy of @p __value as the contained object.
>  template ,

While we're at it, we should rename _ValueType to _Tp and the decayed
type to _VTp,
so that it matches the standard's naming as close as possible, and
thus removes the ongoing
maintenance confusion about which is which.

> +int main() {
> +auto a = std::any(std::in_place_type, 5);
> +auto b = std::any(std::in_place_type, {1});
> +std::any p = std::pair(1, 1);
> +(void)p;
> +std::any t = std::tuple(1);

I think this sort of tests should VERIFY that the constructed any
contains what we expect.
Iow, do an any_cast and check that, for instance, a and b contain an any.


[PATCH] forwprop: Fix ICE when building a VEC_PERM_EXPR [PR94683]

2020-04-21 Thread Richard Sandiford
The type compatibility handling in simplify_vector_constructor is
based on the number of elements and on element type compatibility,
but that's no longer enough to ensure that two vector types are
compatible.  This patch uses a VIEW_CONVERT_EXPR if the permutation
type and result type are distinct.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Richard


2020-04-21  Richard Sandiford  

gcc/
PR tree-optimization/94683
* tree-ssa-forwprop.c (simplify_vector_constructor): Use a
VIEW_CONVERT_EXPR to handle mixtures of similarly-structured
but distinct vector types.

gcc/testsuite/
PR tree-optimization/94683
* gcc.target/aarch64/sve/acle/general/pr94683.c: New test.
---
 .../aarch64/sve/acle/general/pr94683.c| 29 +++
 gcc/tree-ssa-forwprop.c   |  5 
 2 files changed, 34 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr94683.c

diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 3d8acf7eb03..1a50045b367 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -2598,6 +2598,11 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
res, TYPE_SIZE (type), bitsize_zero_node);
   if (conv_code != ERROR_MARK)
res = gimple_build (&stmts, conv_code, type, res);
+  else if (!useless_type_conversion_p (type, TREE_TYPE (res)))
+   {
+ gcc_assert (!targetm.compatible_vector_types_p (type, perm_type));
+ res = gimple_build (&stmts, VIEW_CONVERT_EXPR, type, res);
+   }
   /* Blend in the actual constant.  */
   if (converted_orig1)
res = gimple_build (&stmts, VEC_PERM_EXPR, type,
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr94683.c 
b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr94683.c
new file mode 100644
index 000..fb7c0e479cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr94683.c
@@ -0,0 +1,29 @@
+/* { dg-options "-O2 -msve-vector-bits=256" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include 
+
+typedef float v8sf __attribute__((vector_size(32)));
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** test:
+** faddz0\.s, p0/m, z0\.s, #1.0
+** trn1z0\.s, z0\.s, z0\.s
+** fdivz0\.s, p0/m, z0\.s, z1\.s
+** ret
+*/
+svfloat32_t
+test (svbool_t pg, svfloat32_t x, svfloat32_t y)
+{
+  v8sf a = svadd_x (pg, x, 1);
+  v8sf b = { a[0], a[0], a[2], a[2], a[4], a[4], a[6], a[6] };
+  return svdiv_x (pg, b, y);
+}
+
+#ifdef __cplusplus
+}
+#endif


Re: [og8] Report errors on missing OpenACC reduction clauses in nested reductions

2020-04-21 Thread Frederik Harwath
Thomas Schwinge  writes:

Hi Thomas,

> Via  "10 issues located by the PVS-studio
> static analyzer" (so please reference that one on any patch submission),
> on  in "Fragment N3,
> Assigning a variable to itself", we find this latter assignment qualified
> as "very strange to assign a variable to itself".
>
> Probably that should've been 'outer_ctx' instead of 'ctx'?

I agree that the original intention must have been to assign the
outer_ctx's "outer_reduction_clauses" to the corresponding field of the
inner "ctx". This would make sense, semantically. But this field is
meant to be used by the function "scan_omp_for" only and ...

> then does the current algorith still work despite this error?

... this function never requires the struct field to be intialized in
that way.  Before the field is used, it always copies the clauses from
the outer context's outer_reduction_clauses to ctx->outer_reduction_clauses:

>> +  if (ctx->outer_reduction_clauses == NULL && ctx->outer != NULL)
>> +ctx->outer_reduction_clauses
>> +  = chainon (unshare_expr (ctx->outer->local_reduction_clauses),
>> + ctx->outer->outer_reduction_clauses);

Hence I found it preferrable to remove the assignment to the
"outer_reduction_clauses" field and the "local_reduction_clauses" field
from "new_omp_context" completely. (The fields are still zero intialized
by the allocation of the struct which uses XCNEW.) That way the whole
logic regarding the fields is now contained in "scan_omp_for".

I have executed "make check" (on x86_64-linux-gnu) to verify that the
change causes no regressions. Ok to push the commit to master?

Best regards,
Frederik
-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter
>From 2d60b374a44b212ff97c8b1fd6f8c39e478dc70f Mon Sep 17 00:00:00 2001
From: Frederik Harwath 
Date: Tue, 21 Apr 2020 12:36:14 +0200
Subject: [PATCH] Remove fishy self-assignment in omp-low.c [PR94629]

The PR noticed that omp-low.c contains a self-assignment in the 
function new_omp_context:

if (outer_ctx) {
...
ctx->outer_reduction_clauses = ctx->outer_reduction_clauses;

This is obviously useless.  The original intention might have been
to copy the field from the outer_ctx to ctx.  Since this is done
(properly) in the only function where this field is actually used
(in function scan_omp_for) and the field is being initialized to zero
during the struct allocation, there is no need to attempt to do
anything to this field in new_omp_context. Thus this commit
removes any assignment to the field from new_omp_context.

2020-04-21  Frederik Harwath  

	PR other/94629
	* gcc/omp-low.c (new_omp_context): Remove assignments to
	ctx->outer_reduction_clauses and ctx->local_reduction_clauses.
---
 gcc/omp-low.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 67565d61400..88f23e60d34 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -128,10 +128,16 @@ struct omp_context
  corresponding tracking loop iteration variables.  */
   hash_map *lastprivate_conditional_map;
 
-  /* A tree_list of the reduction clauses in this context.  */
+  /* A tree_list of the reduction clauses in this context. This is
+only used for checking the consistency of OpenACC reduction
+clauses in scan_omp_for and is not guaranteed to contain a valid
+value outside of this function. */
   tree local_reduction_clauses;
 
-  /* A tree_list of the reduction clauses in outer contexts.  */
+  /* A tree_list of the reduction clauses in outer contexts. This is
+only used for checking the consistency of OpenACC reduction
+clauses in scan_omp_for and is not guaranteed to contain a valid
+value outside of this function. */
   tree outer_reduction_clauses;
 
   /* Nesting depth of this context.  Used to beautify error messages re
@@ -931,8 +937,6 @@ new_omp_context (gimple *stmt, omp_context *outer_ctx)
   ctx->outer = outer_ctx;
   ctx->cb = outer_ctx->cb;
   ctx->cb.block = NULL;
-  ctx->local_reduction_clauses = NULL;
-  ctx->outer_reduction_clauses = ctx->outer_reduction_clauses;
   ctx->depth = outer_ctx->depth + 1;
 }
   else
@@ -948,8 +952,6 @@ new_omp_context (gimple *stmt, omp_context *outer_ctx)
   ctx->cb.transform_call_graph_edges = CB_CGE_MOVE;
   ctx->cb.adjust_array_error_bounds = true;
   ctx->cb.dont_remap_vla_if_no_change = true;
-  ctx->local_reduction_clauses = NULL;
-  ctx->outer_reduction_clauses = NULL;
   ctx->depth = 1;
 }
 
-- 
2.17.1



[AMD GCN] Use 'radeon' for the environment variable 'ACC_DEVICE_TYPE' (was: [committed, amdgcn/openacc] Rename acc_device_gcn to acc_device_radeon)

2020-04-21 Thread Thomas Schwinge
Hi Andrew!

On 2020-01-17T18:18:41+, Andrew Stubbs  wrote:
> I've committed this patch, pre-approved by Thomas. It's basically just a
> search and replace.
>
> I had originally invented acc_device_gcn for the device number, but as
> Thomas pointed out the OpenACC documentation already uses
> acc_device_radeon for AMD devices. Presumably this is what any existing
> code will use, if anything, so we ought to be compatible.
>
> There's no official release using the "wrong" name, so I don't believe
> we need to retain that name for any reason.

ACK.

> Rename acc_device_gcn to acc_device_radeon

I wondered whether for symmetry, the GCC-internal 'GOMP_DEVICE_GCN',
'OFFLOAD_TARGET_TYPE_GCN' should also be renamed to '*_RADEON'?  Or,
going by example of '*_NVIDIA_PTX', name them '*_AMD_GCN'.  Or, in fact
then leave them as '*_GCN', given Julian's point in another thread that
"CPU architectures or core implementations [sometimes shift] company
allegiance".  Thank you for listening to me thinking aloud.  ;-)

But more importantly, what about the user-visible 'gcn' in the
'ACC_DEVICE_TYPE' environment variable?  As I'd quoted in
:

| Per OpenACC 3.0, A.1.2. "AMD
| GPU Targets", for example, there is 'acc_device_radeon'

... which you've addressed...

| (and "the
| case-insensitive name 'radeon' for the environment variable
| 'ACC_DEVICE_TYPE'").

..., but this not yet?

Please see the attached "[AMD GCN] Use 'radeon' for the environment
variable 'ACC_DEVICE_TYPE'", completely untested.  Will you please test
and review that?  If approving this patch, please respond with
"Reviewed-by: NAME " so that your effort will be recorded in the
commit log, see .


Grüße
 Thomas


-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter
>From d82df713bbb3401cc346bf07d61ad597d302d5a6 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge 
Date: Tue, 21 Apr 2020 14:16:24 +0200
Subject: [PATCH] [AMD GCN] Use 'radeon' for the environment variable
 'ACC_DEVICE_TYPE'

..., per OpenACC 3.0, A.1.2. "AMD GPU Targets".

This complements commit 6687d13a87c42dddc7d1c7adade38d31ba0d1401 "Rename
acc_device_gcn to acc_device_radeon".
---
 libgomp/oacc-init.c|  4 +++-
 libgomp/testsuite/lib/libgomp.exp  | 16 
 libgomp/testsuite/libgomp.oacc-c++/c++.exp | 18 +-
 .../libgomp.oacc-c++/firstprivate-mappings-1.C |  2 +-
 .../acc_get_property-gcn.c |  2 +-
 .../asyncwait-nop-1.c  |  2 +-
 .../firstprivate-mappings-1.c  |  2 +-
 .../function-not-offloaded.c   |  4 ++--
 .../libgomp.oacc-c-c++-common/loop-auto-1.c|  2 +-
 .../loop-dim-default.c |  2 +-
 .../libgomp.oacc-c-c++-common/routine-wv-2.c   |  2 +-
 .../libgomp.oacc-c-c++-common/tile-1.c |  2 +-
 libgomp/testsuite/libgomp.oacc-c/c.exp | 18 +-
 .../libgomp.oacc-fortran/error_stop-1.f|  2 +-
 .../libgomp.oacc-fortran/error_stop-2.f|  2 +-
 .../libgomp.oacc-fortran/error_stop-3.f|  2 +-
 .../testsuite/libgomp.oacc-fortran/fortran.exp | 14 +++---
 17 files changed, 49 insertions(+), 47 deletions(-)

diff --git a/libgomp/oacc-init.c b/libgomp/oacc-init.c
index ef12b4c16d0..5d786a5a2e7 100644
--- a/libgomp/oacc-init.c
+++ b/libgomp/oacc-init.c
@@ -99,7 +99,9 @@ unknown_device_type_error (acc_device_t invalid_type)
 static const char *
 get_openacc_name (const char *name)
 {
-  if (strcmp (name, "nvptx") == 0)
+  if (strcmp (name, "gcn") == 0)
+return "radeon";
+  else if (strcmp (name, "nvptx") == 0)
 return "nvidia";
   else
 return name;
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index e7ce784314d..ee5f0e57b19 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -319,7 +319,7 @@ proc libgomp_option_proc { option } {
 proc offload_target_to_openacc_device_type { offload_target } {
 switch -glob $offload_target {
 	amdgcn* {
-	return "gcn"
+	return "radeon"
 	}
 	disable {
 	return "host"
@@ -483,10 +483,10 @@ proc check_effective_target_hsa_offloading_selected {} {
 }]
 }
 
-# Return 1 if at least one AMD GCN board is present.
+# Return 1 if at least one AMD GPU is accessible.
 
-proc check_effective_target_openacc_amdgcn_accel_present { } {
-return [check_runtime openacc_amdgcn_accel_present {
+proc check_effective_target_openacc_radeon_accel_present { } {
+return [check_runtime openacc_radeon_accel_present {
 	#include 
 	int main () {
 	return !(acc_get_num_devices (acc_device_radeon) > 0);
@@ -494,11 +494,11 @@ proc check_effective_target_openacc_amdgcn_accel_present { } {
 } "" ]
 }
 
-# Return 1 if at least o

Re: [PATCH, libphobos] Fix compilation dependencies on s390x-linux-musl

2020-04-21 Thread Iain Buclaw via Gcc-patches
On 13/04/2020 15:36, Iain Buclaw via Gcc-patches wrote:
> On 08/04/2020 10:14, Iain Buclaw via Gcc-patches wrote:
>> On 28/01/2020 05:00, Mathias Lang wrote:
>>> diff -Nurp a/libphobos/configure.ac b/libphobos/configure.ac
>>> --- a/libphobos/configure.ac
>>> +++ b/libphobos/configure.ac
>>> @@ -140,6 +140,14 @@ case ${host} in
>>>  esac
>>>  AC_MSG_RESULT($LIBPHOBOS_SUPPORTED)
>>>
>>> +AC_MSG_CHECKING([if target needs to link in swapcontext])
>>> +AC_MSG_RESULT($LIBDRUNTIME_NEEDS_UCONTEXT)
>>> +AS_IF([test "x$LIBDRUNTIME_NEEDS_UCONTEXT" = xyes], [
>>> +   AC_SEARCH_LIBS([swapcontext], [c ucontext], [], [
>>> +   AC_MSG_ERROR([[can't find library providing swapcontext]])
>>> +  ])
>>> +])
>>> +
>>
>> Rather than adding LIBDRUNTIME_NEEDS_UCONTEXT, couldn't you just add a 
>> one-liner AC_SEARCH_LIBS to the WITH_LOCAL_DRUNTIME list?
>>
>> Testing as I suggest locally, there is no problems on x86 and x86_64.
>>
>> Iain.
>>
> 
> Hi Matthias,
> 
> Does the following change work well for you on s390x-musl?
> 
> 

Spoke off channel, and we're fine with the proposed patch.

Tested on x86_64-linux-gnu and s390x-linux-musl, committed to mainline.


Re: [PATCH] c++: make __is_constructible work with paren-init of aggrs [PR94149]

2020-04-21 Thread Jonathan Wakely via Gcc-patches

On 09/04/20 17:00 -0400, Marek Polacek wrote:

In C++20 this is well-formed:

 using T = int[2];
 T t(1, 2);

which means that std::is_constructible_v should be true.
But constructible_expr immediately returned the error_mark_node when it
saw a list with more than one element.  To give accurate results in
C++20, we have to try initializing the aggregate from a parenthesized list of
values.

To not repeat the same mistake as in c++/93790, if there's only one
element, I'm trying {} only when () didn't succeed.  is_constructible5.C
verifies this.

Jon, in paren-init24.C std::is_nothrow_constructible_v doesn't work,
I'm getting
error: invalid 'static_cast' from type 'int' to type 'int [1]'
and
error: functional cast to array type 'int [2]'

Are these the issues you had in mind when we spoke earlier today?


Here's the library change needed to uncomment the FIXMEs in
paren-init24.C

Bootstrapped and tested on powerpc64le-linux, I plan to commit this
to master today.


commit 474660c50d0983cf37a9da62fe7156b132076528
Author: Jonathan Wakely 
Date:   Tue Apr 21 12:47:17 2020 +0100

libstdc++: Support arrays in std::is_nothrow_constructible (PR 94149)

The front end now supports parenthesized initialization for arrays in
C++20, so extend std::is_nothrow_constructible to support them too.

gcc/testsuite:

PR c++/94149
* g++.dg/cpp2a/paren-init24.C: Fix FIXMEs.

libstdc++-v3:

PR c++/94149
* include/std/type_traits (__is_nt_constructible_impl): Add partial
specializations for bounded arrays with non-empty initializers.
* testsuite/20_util/is_nothrow_constructible/value_c++20.cc: New test.

diff --git a/gcc/testsuite/g++.dg/cpp2a/paren-init24.C b/gcc/testsuite/g++.dg/cpp2a/paren-init24.C
index a636a28ee6d..4e97bbc5b56 100644
--- a/gcc/testsuite/g++.dg/cpp2a/paren-init24.C
+++ b/gcc/testsuite/g++.dg/cpp2a/paren-init24.C
@@ -11,8 +11,7 @@ int main()
   static_assert(__is_constructible(T, int));
   static_assert(!__is_constructible(T, int, int));
   static_assert(std::is_constructible_v);
-  //FIXME: libstdc++ problem?
-  //static_assert(std::is_nothrow_constructible_v);
+  static_assert(std::is_nothrow_constructible_v);
 
   using T2 = int[2];
   T2 t2(1);
@@ -21,6 +20,5 @@ int main()
   static_assert(__is_constructible(T2, int));
   static_assert(__is_constructible(T2, int, int));
   static_assert(std::is_constructible_v);
-  // FIXME libstdc++ problem?
-  //static_assert(std::is_nothrow_constructible_v);
+  static_assert(std::is_nothrow_constructible_v);
 }
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 65b9902b56d..f96b5297b83 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -986,6 +986,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 : public __bool_constant::type())>
 { };
 
+#if __cpp_aggregate_paren_init
+  template
+struct __is_nt_constructible_impl
+: public __is_nt_constructible_impl
+{ };
+
+  template
+struct __is_nt_constructible_impl
+: public __and_<__is_nt_constructible_impl...>
+{ };
+#endif
+
   template
 using __is_nothrow_constructible_impl
   = __is_nt_constructible_impl<__is_constructible(_Tp, _Args...),
diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value_c++20.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value_c++20.cc
new file mode 100644
index 000..6bf0a513b14
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value_c++20.cc
@@ -0,0 +1,69 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+// Copyright (C) 2020 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 
+
+static_assert( std::is_nothrow_constructible_v );
+static_assert( std::is_nothrow_constructible_v );
+static_assert( std::is_nothrow_constructible_v );
+static_assert( std::is_nothrow_constructible_v );
+static_assert( ! std::is_nothrow_constructible_v );
+static_assert( ! std::is_nothrow_constructible_v );
+static_assert( ! std::is_nothrow_constructible_v );
+static_assert( ! std::is_nothrow_constructible_v );
+
+struct X
+{
+  X() = default;
+  X(int) noexcept { }
+  X(double) { }
+};
+
+static_asse

Re: set_rtx_cost used wrongly, should be set_src_cost

2020-04-21 Thread Richard Sandiford
Alan Modra via Gcc-patches  writes:
> I believe set_rtx_cost is meant to handle a SET, not a PLUS as is
> passed in these two locations.  Using the proper function for a PLUS
> doesn't make a huge difference: the only arg change to rtx_cost of any
> consequence is outer_code of SET rather than INSN.  A mode of
> word_mode rather than VOIDmode makes no difference at all since the
> mode is taken from the PLUS.  An opno of 1 rather than 4 also doesn't
> change anything since the only backend that does anything with opno
> (besides pass it back to a recursive rtx_cost call) is nios2, and
> there "opno == 0" is the only use of opno.
>
> Bootstrapped and regression tested powerpc64le-linux and x86_64-linux.
> OK for next stage1?

Yes, thanks.

Richard

>
>   * tree-ssa-reassoc.c (optimize_range_tests_to_bit_test): Replace
>   set_rtx_cost with set_src_cost.
>   * tree-switch-conversion.c (bit_test_cluster::emit): Likewise.
>
> diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
> index ec1c033a2cf..af8faf2e6ea 100644
> --- a/gcc/tree-ssa-reassoc.c
> +++ b/gcc/tree-ssa-reassoc.c
> @@ -3208,8 +3208,9 @@ optimize_range_tests_to_bit_test (enum tree_code 
> opcode, int first, int length,
> HOST_WIDE_INT m = tree_to_uhwi (lowi);
> rtx reg = gen_raw_REG (word_mode, 1);
> bool speed_p = optimize_bb_for_speed_p (gimple_bb (stmt));
> -   cost_diff = set_rtx_cost (gen_rtx_PLUS (word_mode, reg,
> -   GEN_INT (-m)), speed_p);
> +   cost_diff = set_src_cost (gen_rtx_PLUS (word_mode, reg,
> +   GEN_INT (-m)),
> + word_mode, speed_p);
> rtx r = immed_wide_int_const (mask, word_mode);
> cost_diff += set_src_cost (gen_rtx_AND (word_mode, reg, r),
>word_mode, speed_p);
> diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
> index bf910dd62b5..4b435941d12 100644
> --- a/gcc/tree-switch-conversion.c
> +++ b/gcc/tree-switch-conversion.c
> @@ -1541,8 +1541,9 @@ bit_test_cluster::emit (tree index_expr, tree 
> index_type,
>HOST_WIDE_INT m = tree_to_uhwi (minval);
>rtx reg = gen_raw_REG (word_mode, 1);
>bool speed_p = optimize_insn_for_speed_p ();
> -  cost_diff = set_rtx_cost (gen_rtx_PLUS (word_mode, reg,
> -   GEN_INT (-m)), speed_p);
> +  cost_diff = set_src_cost (gen_rtx_PLUS (word_mode, reg,
> +   GEN_INT (-m)),
> + word_mode, speed_p);
>for (i = 0; i < count; i++)
>   {
> rtx r = immed_wide_int_const (test[i].mask, word_mode);


Re: [og8] Report errors on missing OpenACC reduction clauses in nested reductions

2020-04-21 Thread Thomas Schwinge
Hi Frederik!

On 2020-04-21T14:13:33+0200, Frederik Harwath  wrote:
> Thomas Schwinge  writes:
>> Via  "10 issues located by the PVS-studio
>> static analyzer" (so please reference that one on any patch submission),
>> on  in "Fragment N3,
>> Assigning a variable to itself", we find this latter assignment qualified
>> as "very strange to assign a variable to itself".

> [...] the original intention must have been [...]

>> then does the current algorith still work despite this error?
>
> [...]

Thanks for this analysis!

> Hence I found it preferrable to remove the assignment to the
> "outer_reduction_clauses" field and the "local_reduction_clauses" field
> from "new_omp_context" completely. (The fields are still zero intialized
> by the allocation of the struct which uses XCNEW.) That way the whole
> logic regarding the fields is now contained in "scan_omp_for".
>
> I have executed "make check" (on x86_64-linux-gnu) to verify that the
> change causes no regressions. Ok to push the commit to master?

ACK, thanks!  To record the review effort, please include "Reviewed-by:
Thomas Schwinge " in the commit log, see
.


Grüße
 Thomas


> From 2d60b374a44b212ff97c8b1fd6f8c39e478dc70f Mon Sep 17 00:00:00 2001
> From: Frederik Harwath 
> Date: Tue, 21 Apr 2020 12:36:14 +0200
> Subject: [PATCH] Remove fishy self-assignment in omp-low.c [PR94629]
>
> The PR noticed that omp-low.c contains a self-assignment in the
> function new_omp_context:
>
> if (outer_ctx) {
> ...
> ctx->outer_reduction_clauses = ctx->outer_reduction_clauses;
>
> This is obviously useless.  The original intention might have been
> to copy the field from the outer_ctx to ctx.  Since this is done
> (properly) in the only function where this field is actually used
> (in function scan_omp_for) and the field is being initialized to zero
> during the struct allocation, there is no need to attempt to do
> anything to this field in new_omp_context. Thus this commit
> removes any assignment to the field from new_omp_context.
>
> 2020-04-21  Frederik Harwath  
>
>   PR other/94629
>   * gcc/omp-low.c (new_omp_context): Remove assignments to
>   ctx->outer_reduction_clauses and ctx->local_reduction_clauses.
> ---
>  gcc/omp-low.c | 14 --
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/omp-low.c b/gcc/omp-low.c
> index 67565d61400..88f23e60d34 100644
> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -128,10 +128,16 @@ struct omp_context
>   corresponding tracking loop iteration variables.  */
>hash_map *lastprivate_conditional_map;
>
> -  /* A tree_list of the reduction clauses in this context.  */
> +  /* A tree_list of the reduction clauses in this context. This is
> +only used for checking the consistency of OpenACC reduction
> +clauses in scan_omp_for and is not guaranteed to contain a valid
> +value outside of this function. */
>tree local_reduction_clauses;
>
> -  /* A tree_list of the reduction clauses in outer contexts.  */
> +  /* A tree_list of the reduction clauses in outer contexts. This is
> +only used for checking the consistency of OpenACC reduction
> +clauses in scan_omp_for and is not guaranteed to contain a valid
> +value outside of this function. */
>tree outer_reduction_clauses;
>
>/* Nesting depth of this context.  Used to beautify error messages re
> @@ -931,8 +937,6 @@ new_omp_context (gimple *stmt, omp_context *outer_ctx)
>ctx->outer = outer_ctx;
>ctx->cb = outer_ctx->cb;
>ctx->cb.block = NULL;
> -  ctx->local_reduction_clauses = NULL;
> -  ctx->outer_reduction_clauses = ctx->outer_reduction_clauses;
>ctx->depth = outer_ctx->depth + 1;
>  }
>else
> @@ -948,8 +952,6 @@ new_omp_context (gimple *stmt, omp_context *outer_ctx)
>ctx->cb.transform_call_graph_edges = CB_CGE_MOVE;
>ctx->cb.adjust_array_error_bounds = true;
>ctx->cb.dont_remap_vla_if_no_change = true;
> -  ctx->local_reduction_clauses = NULL;
> -  ctx->outer_reduction_clauses = NULL;
>ctx->depth = 1;
>  }
>
-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter


Re: [PATCH] coroutines: Pass class reference to promise param preview [PR94682]

2020-04-21 Thread Nathan Sidwell

On 4/21/20 6:42 AM, Iain Sandoe wrote:

Hi

As reported in the PR, per [dcl.fct.def.coroutine]/4 we should
be passing a reference to the object to the promise parameter
preview, and we are currently passing a pointer (this).



gcc/cp/ChangeLog:

2020-04-21  Iain Sandoe  

* coroutines.cc (struct param_info): Add a field to
note that the param is 'this'.
(morph_fn_to_coro): Convert this to a reference before
using it in the promise parameter preview.


ok, one nit


diff --git a/gcc/testsuite/g++.dg/coroutines/promise-parm-preview-this.C 
b/gcc/testsuite/g++.dg/coroutines/promise-parm-preview-this.C



+  future foo(int param) { co_return 0; }
+};
\ No newline at end of file


^ needs a new line

nathan

--
Nathan Sidwell


[AArch64] (PR94383) Avoid C++17 empty base field checking for HVA/HFA

2020-04-21 Thread Matthew Malcomson
In C++17, an empty class deriving from an empty base is not an
aggregate, while in C++14 it is.  In order to implement this, GCC adds
an artificial field to such classes.

This artificial field has no mapping to Fundamental Data Types in the
AArch64 PCS ABI and hence should not count towards determining whether an
object can be passed using the vector registers as per section
"6.4.2 Parameter Passing Rules" in the AArch64 PCS.
https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#the-base-procedure-call-standard

This patch avoids counting this artificial field in
aapcs_vfp_sub_candidate, and hence calculates whether such objects
should be passed in vector registers in the same manner as C++14 (where
the artificial field does not exist).

Before this change, the test below would pass the arguments to `f` in
general registers.  After this change, the test passes the arguments to
`f` using the vector registers.

The new behaviour matches the behaviour of `armclang`, and also matches
the behaviour when run with `-std=gnu++14`.

> gcc -std=gnu++17 test.cpp

``` test.cpp
struct base {};

struct pair : base
{
  float first;
  float second;
  pair (float f, float s) : first(f), second(s) {}
};

void f (pair);
int main()
{
  f({3.14, 666});
  return 1;
}
```

We add a `-Wpsabi` warning to catch cases where this fix has changed the ABI for
some functions.  Unfortunately this warning is currently emitted multiple times
for each problem, but I feel this is not much of a problem and can be fixed
later if needs be.


Testing:
Bootstrapped on aarch64-linux.
Jakub has provided a testsuite change that catches the original problem.
https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544204.html
This patch makes that testcase pass.

gcc/ChangeLog:

2020-04-21  Matthew Malcomson  
Jakub Jelinek  

PR target/94383
* config/aarch64/aarch64.c (enum cpp17empty_state): New.
(aapcs_vfp_sub_candidate): Account for C++17 empty base class
artificial fields.
(aarch64_vfp_is_call_or_return_candidate): Warn when ABI PCS decision is
different after this fix.



### Attachment also inlined for ease of reply###


diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 
c90de65de127992cc0bd9603a32684ebb5bd4fdf..f9f40d52c846afae0d8d2cd9ed4737cdc4b88896
 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -15909,13 +15909,30 @@ aarch64_conditional_register_usage (void)
 }
 }
 
+enum cpp17empty_state {
+DONT_AVOID = 0,
+AVOID = 1,
+AVOID_DONE = 3
+};
+
 /* Walk down the type tree of TYPE counting consecutive base elements.
If *MODEP is VOIDmode, then set it to the first valid floating point
type.  If a non-floating point type is found, or if a floating point
type that doesn't match a non-VOIDmode *MODEP is found, then return -1,
-   otherwise return the count in the sub-tree.  */
+   otherwise return the count in the sub-tree.
+
+   The AVOID_C17EMPTY_FIELD argument is to allow the caller to check whether
+   this function has changed its behaviour after the fix for PR94384 -- this
+   fix is to avoid artificial fields in empty base classes.
+   When called pointing at a value of DONT_AVOID then this function does not
+   avoid the artificial fields -- this is useful to check whether the function
+   returns something different after the fix.
+   When called pointing at a value which has the AVOID bit set, this function
+   avoids such artificial fields and sets the value to AVOID_DONE when one of
+   these fields has been set.  */
 static int
-aapcs_vfp_sub_candidate (const_tree type, machine_mode *modep)
+aapcs_vfp_sub_candidate (const_tree type, machine_mode *modep,
+enum cpp17empty_state *avoid_c17empty_field)
 {
   machine_mode mode;
   HOST_WIDE_INT size;
@@ -15992,7 +16009,8 @@ aapcs_vfp_sub_candidate (const_tree type, machine_mode 
*modep)
|| TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  return -1;
 
-   count = aapcs_vfp_sub_candidate (TREE_TYPE (type), modep);
+   count = aapcs_vfp_sub_candidate (TREE_TYPE (type), modep,
+avoid_c17empty_field);
if (count == -1
|| !index
|| !TYPE_MAX_VALUE (index)
@@ -16030,7 +16048,22 @@ aapcs_vfp_sub_candidate (const_tree type, machine_mode 
*modep)
if (TREE_CODE (field) != FIELD_DECL)
  continue;
 
-   sub_count = aapcs_vfp_sub_candidate (TREE_TYPE (field), modep);
+   /* Ignore C++17 empty base fields, while their type indicates
+  they do contain padding, they have zero size and thus don't
+  contain any padding.  */
+   if (DECL_ARTIFICIAL (field)
+   && DECL_NAME (field) == NULL_TREE
+   && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
+   && DECL_SIZE (field)
+  

C++: ICE tsubsting ptr_plus

2020-04-21 Thread Nathan Sidwell
A colleague hit an ICE when build_pointer_plus exploded. tsubsting the 
pointer operand produced error_mark_node, and b_p_p is unprepared for that.


pushed to trunk

nathan
--
Nathan Sidwell
2020-04-21  Nathan Sidwell  

	* pt.c (tsubst_copy_and_build) [POINTER_PLUS_EXPR]: Check for
	error_mark_node.

diff --git i/gcc/cp/pt.c w/gcc/cp/pt.c
index cd6392aca22..6f74c278c23 100644
--- i/gcc/cp/pt.c
+++ w/gcc/cp/pt.c
@@ -19409,7 +19409,11 @@ tsubst_copy_and_build (tree t,
 case POINTER_PLUS_EXPR:
   {
 	tree op0 = RECUR (TREE_OPERAND (t, 0));
+	if (op0 == error_mark_node)
+	  RETURN (error_mark_node);
 	tree op1 = RECUR (TREE_OPERAND (t, 1));
+	if (op1 == error_mark_node)
+	  RETURN (error_mark_node);
 	RETURN (fold_build_pointer_plus (op0, op1));
   }
 


[PATCH] c++: Dependent conversion operator in concept [PR94597]

2020-04-21 Thread Patrick Palka via Gcc-patches
When building the parameter mapping for an atomic constraint,
find_template_parameters does not spot the template parameter within the
conversion-type-id of a dependent conversion operator, which later leads to an
ICE during substitution when looking up the missing template argument for this
unnoticed template parameter.

(The below testcase is a modification of the reduced testcase in the PR, adding
parens to the requirement 'e.operator c;' as a workaround for PR94645.)

Boostrapped and regtested on x86_64-pc-linux-gnu, does this look OK to commit?

gcc/cp/ChangeLog:

PR c++/94597
* pt.c (any_template_parm_r) : New case.  If this
is a conversion operator, visit its TREE_TYPE.

gcc/testsuite/ChangeLog:

PR c++/94597
* g++.dg/cpp2a/concepts-conv2.C: New test.
---
 gcc/cp/pt.c |  6 ++
 gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C | 19 +++
 2 files changed, 25 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index cd6392aca22..2111f031d9e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10529,6 +10529,12 @@ any_template_parm_r (tree t, void *data)
   }
   break;
 
+case IDENTIFIER_NODE:
+  if (IDENTIFIER_CONV_OP_P (t))
+   /* The conversion-type-id of a conversion operator may be dependent.  */
+   WALK_SUBTREE (TREE_TYPE (t));
+  break;
+
 default:
   break;
 }
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C
new file mode 100644
index 000..abe68187cce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C
@@ -0,0 +1,19 @@
+// PR c++/94597
+// { dg-do compile { target c++2a } }
+
+template  concept d = requires(b e) { e.operator c(); 
};
+
+template  requires(d) bool equal(f, g);
+
+template  struct i {
+  i(h);
+  operator h();
+};
+
+static_assert(d, float>);
+static_assert(!d, int>);
+
+bool fun() {
+  i a(2.0f);
+  return equal(a, 3.0f);
+}
-- 
2.26.2.108.g048abe1751



Re: [PATCH 1/5] testsuite: [arm] Add arm_softfp_ok and arm_hard_ok effective targets.

2020-04-21 Thread Christophe Lyon via Gcc-patches
On Tue, 14 Apr 2020 at 10:38, Andre Vieira (lists)
 wrote:
>
> On 10/04/2020 14:55, Christophe Lyon via Gcc-patches wrote:
> > For arm-linux-gnueabi* targets, a toolchain cannot support the
> > float-abi opposite to the one it has been configured for: since glibc
> > does not support such multilibs, we end up lacking gnu/stubs-*.h when
> > including stdint.h for instance.
> >
> > This patch introduces two new effective targets to detect whether we
> > can compile tests with -mfloat-abi=softfp or -mfloat-abi=hard.
> >
> > This enables to make such tests unsupported rather than fail.
> Hi Christophe,
>
> LGTM, but you need to wait for maintainer approval.
>

Thanks, but I forgot to add the doc fragment in sourcebuild.texi.

Here is an updated version.

Christophe

> Cheers,
> Andre
> > 2020-04-10  Christophe Lyon  
> >
> >   gcc/testsuite/
> >   * lib/target-supports.exp (arm_softfp_ok): New effective target.
> >   (arm_hard_ok): Likewise.
> > ---
> >   gcc/testsuite/lib/target-supports.exp | 20 
> >   1 file changed, 20 insertions(+)
> >
> > diff --git a/gcc/testsuite/lib/target-supports.exp 
> > b/gcc/testsuite/lib/target-supports.exp
> > index 3758bb3..6c8dd01 100644
> > --- a/gcc/testsuite/lib/target-supports.exp
> > +++ b/gcc/testsuite/lib/target-supports.exp
> > @@ -4739,6 +4739,26 @@ proc 
> > check_effective_target_default_branch_protection { } {
> >   return [check_configured_with "enable-standard-branch-protection"]
> >   }
> >
> > +# Return 1 if this is an ARM target supporting -mfloat-abi=softfp.
> > +
> > +proc check_effective_target_arm_softfp_ok { } {
> > +return [check_no_compiler_messages arm_softfp_ok object {
> > + #include 
> > + int dummy;
> > + int main (void) { return 0; }
> > + } "-mfloat-abi=softfp"]
> > +}
> > +
> > +# Return 1 if this is an ARM target supporting -mfloat-abi=hard.
> > +
> > +proc check_effective_target_arm_hard_ok { } {
> > +return [check_no_compiler_messages arm_hard_ok object {
> > + #include 
> > + int dummy;
> > + int main (void) { return 0; }
> > + } "-mfloat-abi=hard"]
> > +}
> > +
> >   # Return 1 if the target supports ARMv8.1-M MVE with floating point
> >   # instructions, 0 otherwise.  The test is valid for ARM.
> >   # Record the command line options needed.
From 99970e0bf614449104090d5160067e1a05df9f36 Mon Sep 17 00:00:00 2001
From: Christophe Lyon 
Date: Thu, 9 Apr 2020 20:01:36 +
Subject: [PATCH 01/14] testsuite: [arm] Add arm_softfp_ok and arm_hard_ok
 effective targets.

For arm-linux-gnueabi* targets, a toolchain cannot support the
float-abi opposite to the one it has been configured for: since glibc
does not support such multilibs, we end up lacking gnu/stubs-*.h when
including stdint.h for instance.

This patch introduces two new effective targets to detect whether we
can compile tests with -mfloat-abi=softfp or -mfloat-abi=hard.

This enables to make such tests unsupported rather than fail.

2020-04-10  Christophe Lyon  

	gcc/testsuite/
	* lib/target-supports.exp (arm_softfp_ok): New effective target.
	(arm_hard_ok): Likewise.

	gcc/
	* doc/sourcebuild.texi (arm_softfp_ok, arm_hard_ok): Document.
---
 gcc/doc/sourcebuild.texi  |  8 
 gcc/testsuite/lib/target-supports.exp | 20 
 2 files changed, 28 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index de28227..8802d11 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1971,6 +1971,14 @@ ARM Target supports options suitable for accessing the Q-bit manipulation
 intrinsics from @code{arm_acle.h}.
 Some multilibs may be incompatible with these options.
 
+@item arm_softfp_ok
+@anchor{arm_softfp_ok}
+ARM target supports the @code{-mfloat-abi=softfp} option.
+
+@item arm_hard_ok
+@anchor{arm_hard_ok}
+ARM target supports the @code{-mfloat-abi=hard} option.
+
 @end table
 
 @subsubsection AArch64-specific attributes
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 3758bb3..6c8dd01 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -4739,6 +4739,26 @@ proc check_effective_target_default_branch_protection { } {
 return [check_configured_with "enable-standard-branch-protection"]
 }
 
+# Return 1 if this is an ARM target supporting -mfloat-abi=softfp.
+
+proc check_effective_target_arm_softfp_ok { } {
+return [check_no_compiler_messages arm_softfp_ok object {
+	#include 
+	int dummy;
+	int main (void) { return 0; }
+	} "-mfloat-abi=softfp"]
+}
+
+# Return 1 if this is an ARM target supporting -mfloat-abi=hard.
+
+proc check_effective_target_arm_hard_ok { } {
+return [check_no_compiler_messages arm_hard_ok object {
+	#include 
+	int dummy;
+	int main (void) { return 0; }
+	} "-mfloat-abi=hard"]
+}
+
 # Return 1 if the target supports ARMv8.1-M MVE with floating point
 # instructions, 0 otherwise.  The test is valid for ARM.
 # Reco

Re: PING [PATCH][gcc][PR94230]provide an option to change the size limitation for -Wmisleading-indent

2020-04-21 Thread Richard Sandiford
Qing Zhao via Gcc-patches  writes:
> Hi,
>
> Please take a look at the attached patch and let me know your comments.
>
> Thanks.
>
> Qing

Acting as a reviewer of last resort since this isn't really my area,
but FWIW, I agree losing column tracking at the current limit is a
genuine regression and should be fixed for GCC 10.

> gcc/ChangeLog:
>
> 2020-04-03  qing zhao  
>

Please add:

PR c/94230

>   * common.opt: Add -flocation-ranges.
>   * doc/invoke.texi: Document it.
>   * toplev.c (process_options): set line_table->default_range_bits
>   to 0 when flag_location_ranges is false. 

I think it would be worth adding a hint to use the new option to
get_visual_column, when warning about column tracking being disabled.
This should probably be a second inform(), immediately after the
current one.

> @@ -14151,6 +14151,13 @@ This option may be useful in conjunction with the 
> @option{-B} or
>  perform additional processing of the program source between
>  normal preprocessing and compilation.
> 
> +@item -flocation-ranges
> +@opindex flocation-ranges

Normally the documented option should be the non-default one,
so -fno-... in this case.

> +Enable range tracking when recording source locations.
> +By default, GCC enables range tracking when recording source locations.
> +If disable range tracking by -fno-location-ranges, more location space
> +will be saved for column tracking.

My understanding is that the patch doesn't actually disable location-range
tracking, but simply uses a less efficient form for *all* ranges, rather
than only using the less efficient form for ranges that aren't "caret at
start, length < 64 chars".

I know you're simply following the suggestion in the PR, sorry,
but I wonder if the option should instead be:

-flarge-source-files

since that seems like a more user-facing concept.  The option would
tell GCC that the source files are likely to be very large and that
GCC should adapt accordingly.  In particular, the option makes GCC
cope with more source lines at the expense of slowing down compilation
and using more memory.

Thanks,
Richard


Re: [PATCH] aarch64:Add an error message in large code model for ilp32 [PR94577]

2020-04-21 Thread Richard Sandiford
"duanbo (C)"  writes:
> Hi
>
>> -Original Message-
>> From: Richard Sandiford [mailto:richard.sandif...@arm.com]
>> Sent: Monday, April 20, 2020 10:42 PM
>> To: duanbo (C) 
>> Cc: GCC Patches 
>> Subject: Re: [PATCH] aarch64:Add an error message in large code model for
>> ilp32 [PR94577]
>> 
>> "duanbo (C)"  writes:
>> > Hi
>> >
>> >> -Original Message-
>> >> From: Richard Sandiford [mailto:richard.sandif...@arm.com]
>> >> Sent: Friday, April 17, 2020 9:38 PM
>> >> To: duanbo (C) 
>> >> Cc: Wilco Dijkstra ; gcc-patches@gcc.gnu.org
>> >> Subject: Re: [PATCH PR94577] [AArch64] :Add an error message in large
>> >> code model for ilp32
>> >>
>> >> "duanbo (C)"  writes:
>> >> > Thank you for your suggestions.
>> >> > I have modified accordingly and a full test has been carried, no
>> >> > new failure
>> >> witnessed.
>> >> > Attached please find the new patch which has been adjusted to be
>> >> > suitable
>> >> for git am.
>> >> > Does the v2 patch look better ?
>> >> >
>> >> > Thanks,
>> >> > Duan bo
>> >> >
>> >> > -Original Message-
>> >> > From: Wilco Dijkstra [mailto:wilco.dijks...@arm.com]
>> >> > Sent: Tuesday, April 14, 2020 4:40 AM
>> >> > To: GCC Patches ; duanbo (C)
>> >> > 
>> >> > Subject: Re: [PATCH PR2] aarch64:Add an error message in large
>> >> > code model for ilp32
>> >> >
>> >> > Hi Duanbo,
>> >> >
>> >> >> This is a simple fix for pr94577.
>> >> >> The option -mabi=ilp32 should not be used in large code model.
>> >> >> Like x86,
>> >> using -mx32 and -mcmodel=large together will result in an error message.
>> >> >> On aarch64, there is no error message for this option conflict.
>> >> >> A solution to this problem can be found in the attached patch.
>> >> >> Bootstrap and tested on aarch64 Linux platform. No new regression
>> >> witnessed.
>> >> >> Any suggestion?
>> >> >
>> >> > Thanks for your patch, more than 4GB doesn't make any sense with
>> >> > ILP32
>> >> indeed.
>> >> > A few suggestions:
>> >> >
>> >> > It would be good to also update the documentation for
>> >> > -mcmodel=large to
>> >> state it is incompatible with -fpic, -fPIC and -mabi=ilp32.
>> >> >
>> >> > The patch adds a another switch statement on mcmodel that ignores
>> >> > the
>> >> previous processing done (which may changes the selected mcmodel). It
>> >> would be safer and more concise to use one switch at the top level
>> >> and in each case use an if statement to handle the special cases.
>> >> >
>> >> > A few minor nitpics:
>> >> >
>> >> > +   PR  target/94577
>> >> > +   * gcc.target/aarch64/pr94577.c : New test
>> >> >
>> >> > Just like comments, there should be a '.' at the end of changelog 
>> >> > entries.
>> >> >
>> >> > AFAICT the format isn't exactly specified, but the email header
>> >> > should be
>> >> like:
>> >> >
>> >> > [PATCH][AArch64] PR94577: Add an error message in large code model
>> >> > for
>> >> > ilp32
>> >> >
>> >> > Sometimes the PR number is also placed in brackets.
>> >> >
>> >> > Cheers,
>> >> > Wilco
>> >> >
>> >> >
>> >> > From feb16a5e5d35d4f632e1be10ce0ac4f4c3505d22 Mon Sep 17
>> 00:00:00
>> >> 2001
>> >> > From: Duan bo 
>> >> > Date: Wed, 15 Apr 2020 05:19:31 -0400
>> >> > Subject: [PATCH] aarch64: Add an error message in large code model
>> >> > for
>> >> > ilp32  [PR94577]
>> >> >
>> >> > The option -mabi=ilp32 should not be used in large code model. An
>> >> > error message is added for the option conflict.
>> >> >
>> >> > 2020-04-15  Duan bo  
>> >> >
>> >> > PR target/94577
>> >> > * config/aarch64/aarch64.c: Add an error message for option 
>> >> > conflict.
>> >> > * doc/invoke.texi (-mcmodel=large): Mention that -mcmodel=large
>> >> is
>> >> > incompatible with -fpic, -fPIC and -mabi=ilp32.
>> >> >
>> >> > 2020-04-15  Duan bo  
>> >> >
>> >> > PR target/94577
>> >> > * gcc.target/aarch64/pr94577.c: New test.
>> >> > ---
>> >> >  gcc/ChangeLog  |  7 
>> >> >  gcc/config/aarch64/aarch64.c   | 41 --
>> >> >  gcc/doc/invoke.texi|  4 ++-
>> >> >  gcc/testsuite/ChangeLog|  5 +++
>> >> >  gcc/testsuite/gcc.target/aarch64/pr94577.c | 10 ++
>> >> >  5 files changed, 47 insertions(+), 20 deletions(-)  create mode
>> >> > 100644 gcc/testsuite/gcc.target/aarch64/pr94577.c
>> >> >
>> >> > diff --git a/gcc/ChangeLog b/gcc/ChangeLog index
>> >> > 3c6a45e8fe7..c2f1fcb7bff 100644
>> >> > --- a/gcc/ChangeLog
>> >> > +++ b/gcc/ChangeLog
>> >> > @@ -1,3 +1,10 @@
>> >> > +2020-04-15  Duan bo  
>> >> > +
>> >> > +   PR target/94577
>> >> > +   * config/aarch64/aarch64.c: Add an error message for option 
>> >> > conflict.
>> >> > +   * doc/invoke.texi (-mcmodel=large): Mention that -mcmodel=large
>> >> is
>> >> > +   incompatible with -fpic, -fPIC and -mabi=ilp32.
>> >> > +
>> >> >  2020-04-14  Max Filippov  
>> >> >
>> >> > PR target/94584
>> >> > diff --git a/gcc/config/aarch6

Re: [PATCH] aarch64: Fix .cfi_window_save with pac-ret [PR94515]

2020-04-21 Thread Szabolcs Nagy
The 04/17/2020 15:26, Jason Merrill wrote:
> On 4/17/20 1:55 PM, Szabolcs Nagy wrote:
> > The 04/17/2020 12:50, Jason Merrill wrote:
> > > On 4/17/20 6:08 AM, Kyrylo Tkachov wrote:
> > > > Hi Szabolcs,
> > > > 
> > > > > -Original Message-
> > > > > From: Szabolcs Nagy 
> > > > > Sent: 09 April 2020 15:20
> > > > > To: gcc-patches@gcc.gnu.org
> > > > > Cc: Richard Earnshaw ; Richard Sandiford
> > > > > ; Kyrylo Tkachov 
> > > > > Subject: [PATCH] aarch64: Fix .cfi_window_save with pac-ret [PR94515]
> > > > > 
> > > > > On aarch64 -mbranch-protection=pac-ret reuses the dwarf
> > > > > opcode for window_save to mean "toggle the return address
> > > > > mangle state", but in the dwarf2cfi internal logic the
> > > > > state was not properly recorded so the remember/restore
> > > > > logic was broken.
> > > > > 
> > > > > This can cause the unwinder not to authenticate return
> > > > > addresses that were signed (or vice versa) which means
> > > > > a runtime crash on a pauth enabled system.
> > > > > 
> > > > > Currently only aarch64 pac-ret uses REG_CFA_TOGGLE_RA_MANGLE.
> > > > 
> > > > I think this is ok, but this code is in the midend so I've CC'ed Jason 
> > > > who, from what I gather from MAINTAINERS, is maintainer for this file.
> > > > Thanks,
> > > > Kyrill
> > > > 
> > > > > 
> > > > > gcc/ChangeLog:
> > > > > 
> > > > > 2020-04-XX  Szabolcs Nagy  
> > > > > 
> > > > >   PR target/94515
> > > > >   * dwarf2cfi.c (dwarf2out_frame_debug): Record RA
> > > > >   mangle state in cur_row->window_save.
> > > > > 
> > > > > gcc/testsuite/ChangeLog:
> > > > > 
> > > > > 2020-04-XX  Szabolcs Nagy  
> > > > > 
> > > > >   PR target/94515
> > > > >   * g++.target/aarch64/pr94515.C: New test.
> > > > > ---
> > > > >gcc/dwarf2cfi.c|  3 ++
> > > > >gcc/testsuite/g++.target/aarch64/pr94515.C | 43 
> > > > > ++
> > > > >2 files changed, 46 insertions(+)
> > > > >create mode 100644 gcc/testsuite/g++.target/aarch64/pr94515.C
> > > > > 
> > > > > diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
> > > > > index 229fbfacc30..22989a6c2fb 100644
> > > > > --- a/gcc/dwarf2cfi.c
> > > > > +++ b/gcc/dwarf2cfi.c
> > > > > @@ -2145,6 +2145,9 @@ dwarf2out_frame_debug (rtx_insn *insn)
> > > > >  case REG_CFA_TOGGLE_RA_MANGLE:
> > > > >   /* This uses the same DWARF opcode as the next operation.  */
> > > > >   dwarf2out_frame_debug_cfa_window_save (true);
> > > > > + /* Keep track of RA mangle state by toggling the window_save 
> > > > > bit.
> > > > > +This is needed so .cfi_window_save is emitted correctly.  */
> > > > > + cur_row->window_save = !cur_row->window_save;
> > > 
> > > It looks like passing 'true' to dwarf2out_frame_debug_cfa_window_save
> > > prevents that function from messing with the window_safe flag.  Does
> > > changing the argument to 'false' get the behavior you want?
> > 
> > we want the state = !state toggling.
> > it might make more sense to do that in
> > dwarf2out_frame_debug_cfa_window_save(true)
> > or to inline that entire logic into the two
> > places where it is used (instead of
> > dispatching with a bool argument).
> 
> I think that inlining and dropping the parameter would be cleaner.
> 
> > for the bug fix i'd like a minimal change
> > (so it can be backported), doing the fix in
> > dwarf2out_frame_debug_cfa_window_save
> > is fine with me, would you prefer that?
> 
> No, thanks.  If you want to commit your patch as is for backporting and then
> do the inlining in a separate commit, that works  for me.

i spoted failing execution tests that expected to pass,
it turns out change_cfi_row() needs something like

-  if (!old_row->window_save && new_row->window_save)
+  if (old_row->window_save != new_row->window_save)

to generate .cfi_window_save that correctly tracks the
toggled state on aarch64, but i assume sparc wants
something else, i added Eric to CC he might know what's
right for the old&&!new case on sparc, any help is
welcome, the logic was added in

commit dfe1fe91dbc7f068bb3efcee40237caacc0c53ae

i can imagine adding a new bool flag in dw_cfi_row
for aarch64 or making the logic target specific
(depending on if the target uses REG_CFA_WINDOW_SAVE
or REG_CFA_TOGGLE_RA_MANGLE for cfi_window_save)

i added a test to the bug report that fails with
my original patch, but works if change_cfi_row is
updated.


Re: [PATCH] forwprop: Fix ICE when building a VEC_PERM_EXPR [PR94683]

2020-04-21 Thread Richard Biener via Gcc-patches
On Tue, Apr 21, 2020 at 2:13 PM Richard Sandiford
 wrote:
>
> The type compatibility handling in simplify_vector_constructor is
> based on the number of elements and on element type compatibility,
> but that's no longer enough to ensure that two vector types are
> compatible.  This patch uses a VIEW_CONVERT_EXPR if the permutation
> type and result type are distinct.
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

OK.

> Richard
>
>
> 2020-04-21  Richard Sandiford  
>
> gcc/
> PR tree-optimization/94683
> * tree-ssa-forwprop.c (simplify_vector_constructor): Use a
> VIEW_CONVERT_EXPR to handle mixtures of similarly-structured
> but distinct vector types.
>
> gcc/testsuite/
> PR tree-optimization/94683
> * gcc.target/aarch64/sve/acle/general/pr94683.c: New test.
> ---
>  .../aarch64/sve/acle/general/pr94683.c| 29 +++
>  gcc/tree-ssa-forwprop.c   |  5 
>  2 files changed, 34 insertions(+)
>  create mode 100644 
> gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr94683.c
>
> diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
> index 3d8acf7eb03..1a50045b367 100644
> --- a/gcc/tree-ssa-forwprop.c
> +++ b/gcc/tree-ssa-forwprop.c
> @@ -2598,6 +2598,11 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
> res, TYPE_SIZE (type), bitsize_zero_node);
>if (conv_code != ERROR_MARK)
> res = gimple_build (&stmts, conv_code, type, res);
> +  else if (!useless_type_conversion_p (type, TREE_TYPE (res)))
> +   {
> + gcc_assert (!targetm.compatible_vector_types_p (type, perm_type));
> + res = gimple_build (&stmts, VIEW_CONVERT_EXPR, type, res);
> +   }
>/* Blend in the actual constant.  */
>if (converted_orig1)
> res = gimple_build (&stmts, VEC_PERM_EXPR, type,
> diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr94683.c 
> b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr94683.c
> new file mode 100644
> index 000..fb7c0e479cf
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr94683.c
> @@ -0,0 +1,29 @@
> +/* { dg-options "-O2 -msve-vector-bits=256" } */
> +/* { dg-final { check-function-bodies "**" "" } } */
> +
> +#include 
> +
> +typedef float v8sf __attribute__((vector_size(32)));
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/*
> +** test:
> +** faddz0\.s, p0/m, z0\.s, #1.0
> +** trn1z0\.s, z0\.s, z0\.s
> +** fdivz0\.s, p0/m, z0\.s, z1\.s
> +** ret
> +*/
> +svfloat32_t
> +test (svbool_t pg, svfloat32_t x, svfloat32_t y)
> +{
> +  v8sf a = svadd_x (pg, x, 1);
> +  v8sf b = { a[0], a[0], a[2], a[2], a[4], a[4], a[6], a[6] };
> +  return svdiv_x (pg, b, y);
> +}
> +
> +#ifdef __cplusplus
> +}
> +#endif


Re: [PATCH] c++: Dependent conversion operator in concept [PR94597]

2020-04-21 Thread Jason Merrill via Gcc-patches

On 4/21/20 9:55 AM, Patrick Palka wrote:

When building the parameter mapping for an atomic constraint,
find_template_parameters does not spot the template parameter within the
conversion-type-id of a dependent conversion operator, which later leads to an
ICE during substitution when looking up the missing template argument for this
unnoticed template parameter.

(The below testcase is a modification of the reduced testcase in the PR, adding
parens to the requirement 'e.operator c;' as a workaround for PR94645.)

Boostrapped and regtested on x86_64-pc-linux-gnu, does this look OK to commit?


OK.


gcc/cp/ChangeLog:

PR c++/94597
* pt.c (any_template_parm_r) : New case.  If this
is a conversion operator, visit its TREE_TYPE.

gcc/testsuite/ChangeLog:

PR c++/94597
* g++.dg/cpp2a/concepts-conv2.C: New test.
---
  gcc/cp/pt.c |  6 ++
  gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C | 19 +++
  2 files changed, 25 insertions(+)
  create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index cd6392aca22..2111f031d9e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10529,6 +10529,12 @@ any_template_parm_r (tree t, void *data)
}
break;
  
+case IDENTIFIER_NODE:

+  if (IDENTIFIER_CONV_OP_P (t))
+   /* The conversion-type-id of a conversion operator may be dependent.  */
+   WALK_SUBTREE (TREE_TYPE (t));
+  break;
+
  default:
break;
  }
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C
new file mode 100644
index 000..abe68187cce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C
@@ -0,0 +1,19 @@
+// PR c++/94597
+// { dg-do compile { target c++2a } }
+
+template  concept d = requires(b e) { e.operator c(); 
};
+
+template  requires(d) bool equal(f, g);
+
+template  struct i {
+  i(h);
+  operator h();
+};
+
+static_assert(d, float>);
+static_assert(!d, int>);
+
+bool fun() {
+  i a(2.0f);
+  return equal(a, 3.0f);
+}





Re: [PATCH] testsuite: Extend C++ struct-layout-1.exp testing to test C++14 vs. C++17 interoperability of structs with empty bases [PR94383]

2020-04-21 Thread Jason Merrill via Gcc-patches

On 4/21/20 5:57 AM, Jakub Jelinek wrote:

Hi!

Jonathan reported an ABI incompatibility between C++14 and C++17 in
passing some aggregates with empty bases on aarch64 (and apparently on arm
too).

The following patch adds 3000 (by default) tests for such interoperability,
using the struct-layout-1* framework.  The current 3000 tests are generated
as is (so unchanged from previous ones), and afterwards there is another set
of 3000 ones, where always one of the tNNN_x.C and tNNN_y.C tests get added
-std=c++14 -DCXX14_VS_CXX17 and another one -std=c++17 -DCXX14_VS_CXX17
options (which one which is chosen pseudo-randomly), which causes the
structs to have an empty base.

I haven't added (yet) checks if the alternate compiler does support these
options (I think that can be done incrementally), so for now this testing is
done only if the alternate compiler is not used.

I had to fix a bug in the flexible array handling, because while we were
lucky in the 3000 generated tests not to have toplevel fields after field
with flexible array members, in the next 3000 we aren't lucky anymore.
But even with that change, diff -upr between old and new
testsuite/g++/g++.dg/g++.dg-struct-layout-1/ doesn't show any differences
except for the ^Only in... messages for the new tests in there.

Bootstrapped/regtested on x86_64-linux and i686-linux and additionally
tested on aarch64-linux, where
FAIL: tmpdir-g++.dg-struct-layout-1/t032 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute
FAIL: tmpdir-g++.dg-struct-layout-1/t056 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute
FAIL: tmpdir-g++.dg-struct-layout-1/t057 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute
FAIL: tmpdir-g++.dg-struct-layout-1/t058 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute
FAIL: tmpdir-g++.dg-struct-layout-1/t059 cp_compat_x_tst.o-cp_compat_y_tst.o 
execute
because of the backend bug, and with that bug fixed it succeeds.
Matthew has kindly tested it also on aarch64-linux and arm*-*.

The primary goal of the patch is catch if some targets other than aarch64 or
arm aren't affected too.

Ok for trunk?


OK.


2020-04-21  Jakub Jelinek  

PR c++/94383
* g++.dg/compat/struct-layout-1.exp: If !$use_alt, add -c to generator
args.
* g++.dg/compat/struct-layout-1_generate.c (dg_options): Add another
%s to the start of dg-options arg.
(cxx14_vs_cxx17, do_cxx14_vs_cxx17): New variables.
(switchfiles): If cxx14_vs_cxx17, prepend -std=c++14 -DCXX14_VS_CXX17
or -std=c++17 -DCXX17_VS_CXX14 - randomly - to dg-options.
(output): Don't append further fields once one with flexible array
member is added.
(generate_random_tests): Don't use toplevel unions if cxx14_vs_cxx17.
(main): If -c, emit second set of tests for -std=c++14 vs. -std=c++17
testing.
* g++.dg/compat/struct-layout-1_x1.h (empty_base): New type.
(EMPTY_BASE): Define.
(TX): Use EMPTY_BASE.
* g++.dg/compat/struct-layout-1_y1.h (empty_base): New type.
(EMPTY_BASE): Define.
(TX): Use EMPTY_BASE.

--- gcc/testsuite/g++.dg/compat/struct-layout-1.exp.jj  2020-01-12 
11:54:37.044403889 +0100
+++ gcc/testsuite/g++.dg/compat/struct-layout-1.exp 2020-04-20 
19:00:54.956968103 +0200
@@ -142,6 +142,9 @@ if { $status == 0 } then {
  file delete -force $tstobjdir
  file mkdir $tstobjdir
  set generator_args "-s $srcdir/$subdir -d $tstobjdir"
+if { $use_alt == 0 } then {
+   set generator_args "$generator_args -c"
+}
  if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
set generator_args "$generator_args -n 15000"
  }
--- gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c.jj   2020-01-12 
11:54:37.045403874 +0100
+++ gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c  2020-04-20 
20:00:35.428544841 +0200
@@ -1,5 +1,5 @@
  /* Structure layout test generator.
-   Copyright (C) 2004-2014
+   Copyright (C) 2004-2020
 Free Software Foundation, Inc.
 Contributed by Jakub Jelinek .
  
@@ -44,12 +44,12 @@ along with GCC; see the file COPYING3.

  #endif
  
  const char *dg_options[] = {

-"/* { dg-options \"%s-I%s -Wno-abi\" } */\n",
-"/* { dg-options \"%s-I%s -mno-mmx -Wno-abi\" { target i?86-*-* x86_64-*-* } } 
*/\n",
-"/* { dg-options \"%s-I%s -fno-common\" { target hppa*-*-hpux* powerpc*-*-darwin* 
*-*-mingw32* *-*-cygwin* } } */\n",
-"/* { dg-options \"%s-I%s -mno-mmx -fno-common -Wno-abi\" { target i?86-*-darwin* 
x86_64-*-darwin* i?86-*-mingw32* x86_64-*-mingw32* i?86-*-cygwin* } } */\n",
-"/* { dg-options \"%s-I%s -mno-base-addresses\" { target mmix-*-* } } */\n",
-"/* { dg-options \"%s-I%s -mlongcalls -mtext-section-literals\" { target 
xtensa*-*-* } } */\n"
+"/* { dg-options \"%s%s-I%s -Wno-abi\" } */\n",
+"/* { dg-options \"%s%s-I%s -mno-mmx -Wno-abi\" { target i?86-*-* x86_64-*-* } } 
*/\n",
+"/* { dg-options \"%s%s-I%s -fno-common\" { target hppa*-*-hpux* powerpc*-*-darwin* 
*-*-mingw32* *-*-cygwin* } } */\n",
+"/* { dg-opti

Re: [AArch64] (PR94383) Avoid C++17 empty base field checking for HVA/HFA

2020-04-21 Thread Jakub Jelinek via Gcc-patches
On Tue, Apr 21, 2020 at 02:39:12PM +0100, Matthew Malcomson wrote:
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -15909,13 +15909,30 @@ aarch64_conditional_register_usage (void)
>  }
>  }
>  
> +enum cpp17empty_state {
> +DONT_AVOID = 0,
> +AVOID = 1,
> +AVOID_DONE = 3
> +};

Just an option to having a pointer to this enum, I wonder if you couldn't
pass just bool *has_cxx17_empty_base argument, where:
+ if (DECL_ARTIFICIAL (field)
+ && DECL_NAME (field) == NULL_TREE
+ && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
+ && DECL_SIZE (field)
+ && integer_zerop (DECL_SIZE (field))
+ && has_cxx17_empty_base)
+   {
+ *has_cxx17_empty_base = true;
+ continue;
+   }
, pass it around like your argument and in the caller do:
+  bool has_cxx17_empty_base = false;
+  int ag_count = aapcs_vfp_sub_candidate (type, &new_mode,
+ &has_cxx17_empty_base);
...
+   if (warn_psabi
+   && has_cxx17_empty_base
+   && ((alt = aapcs_vfp_sub_candidate (type, &new_mode,
+   NULL))
+   != ag_count)
i.e. just pass NULL for the case when empty bases shouldn't be ignored.

+   "std=c++17 in GCC 10", type);   
   
Shouldn't that be %<-std=c++17%> ?

Jakub



Re: [AArch64] (PR94383) Avoid C++17 empty base field checking for HVA/HFA

2020-04-21 Thread Richard Sandiford
Thanks for doing this.

Matthew Malcomson  writes:
> In C++17, an empty class deriving from an empty base is not an
> aggregate, while in C++14 it is.  In order to implement this, GCC adds
> an artificial field to such classes.
>
> This artificial field has no mapping to Fundamental Data Types in the
> AArch64 PCS ABI and hence should not count towards determining whether an
> object can be passed using the vector registers as per section
> "6.4.2 Parameter Passing Rules" in the AArch64 PCS.
> https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#the-base-procedure-call-standard
>
> This patch avoids counting this artificial field in
> aapcs_vfp_sub_candidate, and hence calculates whether such objects
> should be passed in vector registers in the same manner as C++14 (where
> the artificial field does not exist).
>
> Before this change, the test below would pass the arguments to `f` in
> general registers.  After this change, the test passes the arguments to
> `f` using the vector registers.
>
> The new behaviour matches the behaviour of `armclang`, and also matches
> the behaviour when run with `-std=gnu++14`.
>
>> gcc -std=gnu++17 test.cpp
>
> ``` test.cpp
> struct base {};
>
> struct pair : base
> {
>   float first;
>   float second;
>   pair (float f, float s) : first(f), second(s) {}
> };
>
> void f (pair);
> int main()
> {
>   f({3.14, 666});
>   return 1;
> }
> ```
>
> We add a `-Wpsabi` warning to catch cases where this fix has changed the ABI 
> for
> some functions.  Unfortunately this warning is currently emitted multiple 
> times
> for each problem, but I feel this is not much of a problem and can be fixed
> later if needs be.

Agreed.  We need a better way of handling this in general (for all targets).

> Testing:
> Bootstrapped on aarch64-linux.
> Jakub has provided a testsuite change that catches the original problem.
> https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544204.html
> This patch makes that testcase pass.
>
> gcc/ChangeLog:
>
> 2020-04-21  Matthew Malcomson  
>   Jakub Jelinek  
>
>   PR target/94383
>   * config/aarch64/aarch64.c (enum cpp17empty_state): New.
>   (aapcs_vfp_sub_candidate): Account for C++17 empty base class
>   artificial fields.
>   (aarch64_vfp_is_call_or_return_candidate): Warn when ABI PCS decision is
>   different after this fix.
>
>
>
> ### Attachment also inlined for ease of reply
> ###
>
>
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index 
> c90de65de127992cc0bd9603a32684ebb5bd4fdf..f9f40d52c846afae0d8d2cd9ed4737cdc4b88896
>  100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -15909,13 +15909,30 @@ aarch64_conditional_register_usage (void)
>  }
>  }
>  
> +enum cpp17empty_state {
> +DONT_AVOID = 0,
> +AVOID = 1,
> +AVOID_DONE = 3

Should only be two spaces of indentation.

Some kind of prefix might be nice, since the names are very generic.
But maybe we can leave this as-is for now and make it a scoped enum
once we switch to C++11.

> +};
> +
>  /* Walk down the type tree of TYPE counting consecutive base elements.
> If *MODEP is VOIDmode, then set it to the first valid floating point
> type.  If a non-floating point type is found, or if a floating point
> type that doesn't match a non-VOIDmode *MODEP is found, then return -1,
> -   otherwise return the count in the sub-tree.  */
> +   otherwise return the count in the sub-tree.
> +
> +   The AVOID_C17EMPTY_FIELD argument is to allow the caller to check whether
> +   this function has changed its behaviour after the fix for PR94384 -- this

behavior (alas)

> +   fix is to avoid artificial fields in empty base classes.
> +   When called pointing at a value of DONT_AVOID then this function does not
> +   avoid the artificial fields -- this is useful to check whether the 
> function
> +   returns something different after the fix.
> +   When called pointing at a value which has the AVOID bit set, this function
> +   avoids such artificial fields and sets the value to AVOID_DONE when one of
> +   these fields has been set.  */
>  static int
> -aapcs_vfp_sub_candidate (const_tree type, machine_mode *modep)
> +aapcs_vfp_sub_candidate (const_tree type, machine_mode *modep,
> +  enum cpp17empty_state *avoid_c17empty_field)
>  {
>machine_mode mode;
>HOST_WIDE_INT size;
> @@ -15992,7 +16009,8 @@ aapcs_vfp_sub_candidate (const_tree type, 
> machine_mode *modep)
>   || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
> return -1;
>  
> - count = aapcs_vfp_sub_candidate (TREE_TYPE (type), modep);
> + count = aapcs_vfp_sub_candidate (TREE_TYPE (type), modep,
> +  avoid_c17empty_field);
>   if (count == -1
>   || !index
>   || !TYPE_MAX_VALUE (index)
> @@ -16030,7 +16048,22 @@ aapcs_vfp_sub_candidate (const_tree type, 
> 

Re: introduce target tmpnam and require it in tests relying on it

2020-04-21 Thread Martin Sebor via Gcc-patches

On 4/21/20 3:50 AM, Bernhard Reutner-Fischer wrote:

On 17 April 2020 21:21:41 CEST, Martin Sebor via Gcc-patches 
 wrote:

On 4/17/20 11:48 AM, Alexandre Oliva wrote:

On Apr  9, 2020, Alexandre Oliva  wrote:


Some target C libraries that aren't recognized as freestanding don't
have filesystem support, so calling tmpnam, fopen/open and
remove/unlink fails to link.



This patch introduces a tmpnam effective target to the testsuite,

and

requires it in the tests that call tmpnam.



Tested on x86_64-linux-gnu, and with a cross to arm-eabi.
Ok to install?




for  gcc/testsuite/ChangeLog



* lib/target-supports.exp (check_effective_target_tmpnam): New.
* gcc.c-torture/execute/fprintf-2.c: Require it.
* gcc.c-torture/execute/printf-2.c: Likewise.
* gcc.c-torture/execute/user-printf.c: Likewise.


Ping?

https://gcc.gnu.org/pipermail/gcc-patches/2020-April/543672.html


I'm okay with the changes to the tests.

The target-supports.exp changes look reasonable to me as well but
I can't approve them.  Since you said it's for targets that don't
have file I/O functions I wonder if the name would better reflect
that if it were called, say, check_effective_target_fileio?


Since tmpnam is obsolescent in SUSv4 and hence a libc is fine to omit it, I'd 
rather fix the tests to use functions that are known to stay.


I would be okay with replacing tmpnam with something else, although
I don't think it's necessary.  tmpnam is a standard C function that
conforming C (and so POSIX) implementation are required to provide.

Martin



If you want a fileio predicate then please do not keys it off obsolescent 
functions.

TIA,


I don't expect it's necessary to worry about handling errors in
the .exp test.

Martin






Re: PING [PATCH][gcc][PR94230]provide an option to change the size limitation for -Wmisleading-indent

2020-04-21 Thread David Malcolm via Gcc-patches
On Tue, 2020-04-21 at 15:04 +0100, Richard Sandiford wrote:
> Qing Zhao via Gcc-patches  writes:
> > Hi,
> > 
> > Please take a look at the attached patch and let me know your
> > comments.
> > 
> > Thanks.
> > 
> > Qing
> 
> Acting as a reviewer of last resort since this isn't really my area,

Sorry; life has been crazy lately.

> but FWIW, I agree losing column tracking at the current limit is a
> genuine regression and should be fixed for GCC 10.

Is this a regression in GCC 10 though?  I think this has been the case
since GCC 6 onwards.

> > gcc/ChangeLog:
> > 
> > 2020-04-03  qing zhao  
> > 
> 
> Please add:
> 
>   PR c/94230
> 
> > * common.opt: Add -flocation-ranges.
> > * doc/invoke.texi: Document it.
> > * toplev.c (process_options): set line_table-
> > >default_range_bits
> > to 0 when flag_location_ranges is false. 
> 
> I think it would be worth adding a hint to use the new option to
> get_visual_column, when warning about column tracking being disabled.
> This should probably be a second inform(), immediately after the
> current one.
> 
> > @@ -14151,6 +14151,13 @@ This option may be useful in conjunction
> > with the @option{-B} or
> >  perform additional processing of the program source between
> >  normal preprocessing and compilation.
> > 
> > +@item -flocation-ranges
> > +@opindex flocation-ranges
> 
> Normally the documented option should be the non-default one,
> so -fno-... in this case.
> 
> > +Enable range tracking when recording source locations.
> > +By default, GCC enables range tracking when recording source
> > locations.
> > +If disable range tracking by -fno-location-ranges, more location
> > space
> > +will be saved for column tracking.
> 
> My understanding is that the patch doesn't actually disable location-
> range
> tracking, but simply uses a less efficient form for *all* ranges,
> rather
> than only using the less efficient form for ranges that aren't "caret
> at
> start, length < 64 chars".

Indeed.

> I know you're simply following the suggestion in the PR, sorry,

Sorry.  I did put a caveat on the suggestion FWIW.

> but I wonder if the option should instead be:
> 
> -flarge-source-files
> 
> since that seems like a more user-facing concept.  The option would
> tell GCC that the source files are likely to be very large and that
> GCC should adapt accordingly.  In particular, the option makes GCC
> cope with more source lines at the expense of slowing down
> compilation
> and using more memory.

Another approach would be to go lower-level and introduce a param for
this; something like "--param location-range-bits" defaulting to 5; the
user can set it to 0 to disable the range-bit optimization to deal with
bigger files, and it allows for experimentation without rebuilding the
compiler.

Again, I don't know if this is a good idea; I'm thinking aloud; I'm not
sure what the best direction here is.

Sorry again about the belated response on this patch.
Dave



Re: [PATCH][libstd++][PR92156]

2020-04-21 Thread kamlesh kumar via Gcc-patches
added VERIFY in test and changed the template parameter naming.

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 6b7e68f0e63..d350d0b2575 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -176,36 +176,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   typename __any_constructible::type;

 /// Construct with a copy of @p __value as the contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  __any_constructible_t<_Tp, _ValueType&&> = true,
-  enable_if_t::value, bool> = true>
-  any(_ValueType&& __value)
+template ,
+  typename _Mgr = _Manager<_VTp>,
+  enable_if_t::value &&
+  !__is_in_place_type<_VTp>::value, bool> = true>
+  any(_Tp&& __value)
   : _M_manager(&_Mgr::_S_manage)
   {
-_Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
-  }
-
-/// Construct with a copy of @p __value as the contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  enable_if_t<__and_v,
-  __not_>,
-  __not_<__is_in_place_type<_Tp>>>,
-  bool> = false>
-  any(_ValueType&& __value)
-  : _M_manager(&_Mgr::_S_manage)
-  {
-_Mgr::_S_create(_M_storage, __value);
+_Mgr::_S_create(_M_storage, std::forward<_Tp>(__value));
   }

 /// Construct with an object created from @p __args as the
contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  __any_constructible_t<_Tp, _Args&&...> = false>
+template ,
+  typename _Mgr = _Manager<_VTp>,
+  __any_constructible_t<_VTp, _Args&&...> = false>
   explicit
-  any(in_place_type_t<_ValueType>, _Args&&... __args)
+  any(in_place_type_t<_Tp>, _Args&&... __args)
   : _M_manager(&_Mgr::_S_manage)
   {
 _Mgr::_S_create(_M_storage, std::forward<_Args>(__args)...);
@@ -213,13 +200,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

 /// Construct with an object created from @p __il and @p __args as
 /// the contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  __any_constructible_t<_Tp, initializer_list<_Up>,
+template ,
+  typename _Mgr = _Manager<_VTp>,
+  __any_constructible_t<_VTp, initializer_list<_Up>,
 _Args&&...> = false>
   explicit
-  any(in_place_type_t<_ValueType>,
+  any(in_place_type_t<_Tp>,
   initializer_list<_Up> __il, _Args&&... __args)
   : _M_manager(&_Mgr::_S_manage)
   {
@@ -258,40 +245,43 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }

 /// Store a copy of @p __rhs as the contained object.
-template
-  enable_if_t>::value, any&>
-  operator=(_ValueType&& __rhs)
+template
+  enable_if_t>::value, any&>
+  operator=(_Tp&& __rhs)
   {
- *this = any(std::forward<_ValueType>(__rhs));
+ *this = any(std::forward<_Tp>(__rhs));
  return *this;
   }

 /// Emplace with an object created from @p __args as the contained object.
-template 
-  typename __any_constructible<_Decay<_ValueType>&,
-   _Decay<_ValueType>, _Args&&...>::type
+template >
+  typename __any_constructible<_VTp&,
+   _VTp, _Args&&...>::type
   emplace(_Args&&... __args)
   {
- __do_emplace<_Decay<_ValueType>>(std::forward<_Args>(__args)...);
+ __do_emplace<_VTp>(std::forward<_Args>(__args)...);
  any::_Arg __arg;
  this->_M_manager(any::_Op_access, this, &__arg);
- return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
+ return *static_cast<_VTp*>(__arg._M_obj);
   }

 /// Emplace with an object created from @p __il and @p __args as
 /// the contained object.
-template 
-  typename __any_constructible<_Decay<_ValueType>&,
-   _Decay<_ValueType>,
+template >
+  typename __any_constructible<_VTp&,
+   _VTp,
initializer_list<_Up>,
_Args&&...>::type
   emplace(initializer_list<_Up> __il, _Args&&... __args)
   {
- __do_emplace<_Decay<_ValueType>, _Up>(__il,
+ __do_emplace<_VTp, _Up>(__il,
   std::forward<_Args>(__args)...);
  any::_Arg __arg;
  this->_M_manager(any::_Op_access, this, &__arg);
- return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
+ return *static_cast<_VTp*>(__arg._M_obj);
   }

 // modifiers
diff --git a/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
new file mode 100644
index 000..df6c9deff1b
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
@@ -0,0 +1,39 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2014-2020 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

[committed][hppa] Fix weakening of external objects

2020-04-21 Thread John David Anglin
In looking at issues with libgfortran, I noticed the include definitions in 
libquadmath.h resulted
in declarations for functions in libquadmath being of type DATA.  As a result, 
the HP linker ended
up looking for data symbols instead of code symbols.  This occurred for 
functions declared with the
attribute .weakref.

On further investigation, I found that this was caused by using the generic 
.weakref assembler mnemonic
which doesn't work on the SOM target because of the code/data typing for 
symbols.  When configure finds
assembler .weakref support, this results in ASM_OUTPUT_WEAKREF being defined in 
defaults.h.  When it
is not defined the code in varasm.c will use either ASM_WEAKEN_DECL or 
ASM_WEAKEN_LABEL to handle weak
references.

After disabling ASM_WEAKEN_LABEL, it turned out that ASM_WEAKEN_LABEL can't 
handle external symbols.
It has no way to distinguish between local and external symbols.  External 
symbols need to be imported.

This patch replaces ASM_WEAKEN_LABEL with ASM_WEAKEN_DECL, and it disables the 
use of ASM_OUTPUT_WEAKREF.
It correctly handles the weakening of both local and external symbols.  The 
SDEF bit and the code/data type
are both correctly set in the symbol table.

I tried to fix the symbol type with ASM_OUTPUT_WEAKREF but this didn't work.  
The SDEF bit didn't get set.
I may go back and try to fix ASM_OUTPUT_WEAKREF in the future.

Tested on hppa2.0w-hp-hpux11.11 with no observed regressions.

Committed to trunk.

Dave

2020-04-21  John David Anglin  

* config/pa/som.h (ASM_WEAKEN_LABEL): Delete.
(ASM_WEAKEN_DECL): New define.
(HAVE_GAS_WEAKREF): Undefine.

diff --git a/gcc/config/pa/som.h b/gcc/config/pa/som.h
index 505fdd65d79..81aee862aa0 100644
--- a/gcc/config/pa/som.h
+++ b/gcc/config/pa/som.h
@@ -277,7 +277,7 @@ do {\
 /* If GAS supports weak, we can support weak when we have working linker
support for secondary definitions and are generating code for GAS.
This is primarily for one-only support as SOM doesn't allow undefined
-   weak symbols.  */
+   weak symbols or weak aliases.  */
 #ifdef HAVE_GAS_WEAK
 #define TARGET_SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
 #else
@@ -328,12 +328,43 @@ do {  \
be used to remove dead procedures.  Thus, support for named sections
is not needed and in previous testing caused problems with various
HP tools.  */
-#define ASM_WEAKEN_LABEL(FILE,NAME) \
-  do { fputs ("\t.weak\t", FILE);  \
-   assemble_name (FILE, NAME); \
-   fputc ('\n', FILE); \
-   targetm.asm_out.globalize_label (FILE, NAME);   \
-  } while (0)
+#if defined HAVE_GAS_WEAK
+#define ASM_WEAKEN_DECL(FILE,DECL,NAME,VALUE) \
+  do   \
+{  \
+  if ((VALUE) != NULL) \
+   error_at (DECL_SOURCE_LOCATION (DECL),  \
+ "weak aliases are not supported");\
+  fputs ("\t.weak\t", FILE);   \
+  assemble_name (FILE, NAME);  \
+  fputc ('\n', FILE);  \
+   \
+  /* Import external objects.  */  \
+  if (DECL_EXTERNAL (DECL))
\
+   {   \
+ fputs ("\t.IMPORT ", FILE);   \
+ assemble_name (FILE, NAME);   \
+ if (TREE_CODE (DECL) == FUNCTION_DECL)\
+   fputs (",CODE\n", FILE);\
+ else  \
+   fputs (",DATA\n", FILE);\
+   }   \
+  /* Functions are globalized by ASM_DECLARE_FUNCTION_NAME.  */\
+  else if (TREE_CODE (DECL) != FUNCTION_DECL)  \
+   {   \
+ fputs ("\t.EXPORT ", FILE);   \
+ assemble_name (FILE, NAME);   \
+ fputs (",DATA\n", FILE);  \
+   }   \
+}  \
+  while (0)
+#endif
+
+/* Although gas accepts .weakref, it doesn't provide the correct symbol
+   type for function referenc

Re: [PATCH] aarch64: Fix .cfi_window_save with pac-ret [PR94515]

2020-04-21 Thread Eric Botcazou
> i spoted failing execution tests that expected to pass,
> it turns out change_cfi_row() needs something like
> 
> -  if (!old_row->window_save && new_row->window_save)
> +  if (old_row->window_save != new_row->window_save)
> 
> to generate .cfi_window_save that correctly tracks the
> toggled state on aarch64, but i assume sparc wants
> something else, i added Eric to CC he might know what's
> right for the old&&!new case on sparc, any help is
> welcome, the logic was added in
> 
> commit dfe1fe91dbc7f068bb3efcee40237caacc0c53ae

Yes, you cannot really "toggle" a register window on SPARC.

> i can imagine adding a new bool flag in dw_cfi_row
> for aarch64 or making the logic target specific
> (depending on if the target uses REG_CFA_WINDOW_SAVE
> or REG_CFA_TOGGLE_RA_MANGLE for cfi_window_save)

Yes, please do not hijack again the SPARC logic here.

-- 
Eric Botcazou


Re: [Patch v2, fortran] PR fortran/90350 - ubound ICE on assumed size array even though explicit bound is specified

2020-04-21 Thread Thomas Koenig via Gcc-patches

Hi Jose,

Proposed patch to Bug 90350 - ubound ICE on assumed size array even 
though explicit bound is specified


Patch tested only on x86_64-pc-linux-gnu.

Best regards,
José Rui


Looks good.

Do you have commit privileges? It not, I can commit it for you.

Regards

Thomas



Re: [PATCH] aarch64, libgcc: Fix unwinding from pac-ret to normal frames [PR94514]

2020-04-21 Thread Szabolcs Nagy
The 04/17/2020 11:05, Kyrylo Tkachov wrote:
> Hi Szabolcs,
> 
> > -Original Message-
> > From: Szabolcs Nagy 
> > Sent: 09 April 2020 15:20
> > To: gcc-patches@gcc.gnu.org
> > Cc: Richard Earnshaw ; Richard Sandiford
> > ; Kyrylo Tkachov 
> > Subject: [PATCH] aarch64, libgcc: Fix unwinding from pac-ret to normal
> > frames [PR94514]
> >
> > With -mbranch-protection=pac-ret the debug info toggles the
> > signedness state of the return address so the unwinder knows when
> > the return address needs pointer authentication.
> >
> > The unwind context flags were not updated according to the dwarf
> > frame info.
> >
> > This causes unwinding across frames that were built without pac-ret
> > to incorrectly authenticate the return address wich corrupts the
> > return address on a system where PAuth is enabled.
> >
> > Note: This even affects systems where all code use pac-ret because
> > unwinding across a signal frame the return address is not signed.
> >
> 
> Ok, I'm guessing this needs backporting?

committed now,

yes i think it has to go back to gcc-9 and gcc-8,
i will do that later. thanks.


Re: [patch, committed] Add numerous symbol attributes to -fdump-fortran-original

2020-04-21 Thread Fritz Reese via Gcc-patches
On Mon, Apr 20, 2020 at 1:25 PM Thomas Koenig via Fortran
 wrote:
>
> Hello world,
>
> after finding myself debug a PR where showing all the attributes
> of a symbol would have helped enormously (which I realized only
> afterwards), I went ahead and added most of the flags to show_attr,
> in the hope that this will help all of us debugging some murky corners
> of the compiler where attributes are not what they should be.
>
> If you see anything that is still missing, please freel free
> to add.
>
> Committed as obvious (no user impact) after testing that
> the compiler still compiles :-)
>
> Regards
>
> Thomas
>
> 2020-04-20  Thomas Koenig  
>
> * dump-parse-tree.c (show_attr): Add numerous flags, some cleanup.

Thanks!! I've always thought these should be handled.

---
Fritz Reese


Re: [PATCH, V4] PowerPC Turn on -mpcrel by default for -mcpu=future

2020-04-21 Thread Michael Meissner via Gcc-patches
On Tue, Apr 07, 2020 at 05:58:01PM -0500, Segher Boessenkool wrote:
> > +  /* Enable -mprefixed by default on 64-bit 'future' systems.  */
> > +  if (TARGET_FUTURE && TARGET_POWERPC64
> > +  && (rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) == 0)
> > +rs6000_isa_flags |= OPTION_MASK_PREFIXED;
> 
> I don't understand why only for 64 bit?

I have doubts whether PC-relative really works with 32-bit.  I suspect that you
may see some hidden wrap around issues if an address crosses the 32-bit
boundary.  Given the simulator I have access to only runs Linux 64-bit, I have
no way of testing it.  I would prefer to not put in code that I can't test.

But if the only way to get the patch in is to remove the test, I can remove it.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797


[PATCH] c++: Diagnose invalid use of member function in requires

2020-04-21 Thread Patrick Palka via Gcc-patches
This updates diagnose_valid_expression to mirror the convert_to_void check added
to tsubst_valid_expression_requirement by r10-7554.

Passes 'make check-c++', does this look OK to commit after a full
bootstrap/regtest?

gcc/cp/ChangeLog:

PR c++/67825
* constraint.cc (diagnose_valid_expression): Check convert_to_void here
as well as in tsubst_valid_expression_requirement.

gcc/testsuite/ChangeLog:

PR c++/67825
* g++.dg/concepts/diagnostic10.C: New test.
* g++.dg/cpp2a/concepts-pr67178.C: Adjust dg-note.
---
 gcc/cp/constraint.cc  |  8 ++--
 gcc/testsuite/g++.dg/concepts/diagnostic10.C  | 18 ++
 gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C |  2 +-
 3 files changed, 25 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/concepts/diagnostic10.C

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index d56ec101cd9..c05fafe5da1 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -3242,7 +3242,8 @@ static tree
 diagnose_valid_expression (tree expr, tree args, tree in_decl)
 {
   tree result = tsubst_expr (expr, args, tf_none, in_decl, false);
-  if (result != error_mark_node)
+  if (result != error_mark_node
+  && convert_to_void (result, ICV_STATEMENT, tf_none) != error_mark_node)
 return result;
 
   location_t loc = cp_expr_loc_or_input_loc (expr);
@@ -3250,7 +3251,10 @@ diagnose_valid_expression (tree expr, tree args, tree 
in_decl)
 {
   /* Replay the substitution error.  */
   inform (loc, "the required expression %qE is invalid, because", expr);
-  tsubst_expr (expr, args, tf_error, in_decl, false);
+  if (result == error_mark_node)
+   tsubst_expr (expr, args, tf_error, in_decl, false);
+  else
+   convert_to_void (result, ICV_STATEMENT, tf_error);
 }
   else
 inform (loc, "the required expression %qE is invalid", expr);
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic10.C 
b/gcc/testsuite/g++.dg/concepts/diagnostic10.C
new file mode 100644
index 000..fcc6043ca93
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/diagnostic10.C
@@ -0,0 +1,18 @@
+// PR c++/67825
+// { dg-do compile { target concepts } }
+// { dg-additional-options "-fconcepts-diagnostics-depth=2" }
+
+template
+  requires requires (T t) { t.f; } // { dg-error "invalid use of non-static 
member function" }
+void foo() { }
+
+struct S
+{
+  int f();
+};
+
+void
+bar()
+{
+  foo(); // { dg-error "unsatisfied constraints" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C
index ff84711a7af..7154fc2b7fe 100644
--- a/gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C
@@ -12,7 +12,7 @@ concept C0 = requires (auto x) { // { dg-error "placeholder 
type" }
 template
 concept C1 = requires (C1 auto x) { // { dg-error "not been 
declared|placeholder|two or more|in requirements" }
   x; // { dg-error "not declared" }
-  { x } -> c; // { dg-message "not declared|does not satisfy" }
+  { x } -> c; // { dg-message "is invalid" }
 };
 
 template
-- 
2.26.2.108.g048abe1751



We’ve Got An Early Gift Just For You .......!

2020-04-21 Thread Steve Kelfer via Gcc-patches
ANH Digitizing

(Embroidery, Custom Patches, Screen Printing, Graphics Art Work and All you
need)

We are providing special offers to our new customers and we have highly
skilled team that’s why we provide 100% quality and shortest turnaround
time.



Digitzing Logo:

   - Each Cap And Left Chest   $10
   - Each Middle Complex$25
   - Each Jacket Back upto$35
   - Each Super Complex   upto$50



Vector Art Logo:

   - Each Simple   $10
   - Each Middle Complexupto$25
   - Each Super Complex  upto$35
   - Super Duper Complexupto$50



Custom Patches:

   1. Embroidered  Patches
   2. Chenille  Patches
   3. Leather  Patches
   4. Iron  Patches
   5. Bullion  Patches
   6. Name  Patches
   7. Printed Patches
   8. Woven  Patches
   9. PVC Patches

And all you need…



*Simply Just Reply back to us with the same email Address And we will get
back to you Shortly ASAP ...!*


*Best Regards*

*Steve Kelfer*

*i...@anhdigitizing.com *

*www.anhdigitizing.com *


Re: PING [PATCH][gcc][PR94230]provide an option to change the size limitation for -Wmisleading-indent

2020-04-21 Thread Richard Sandiford
David Malcolm  writes:
> On Tue, 2020-04-21 at 15:04 +0100, Richard Sandiford wrote:
>> Qing Zhao via Gcc-patches  writes:
>> > Hi,
>> > 
>> > Please take a look at the attached patch and let me know your
>> > comments.
>> > 
>> > Thanks.
>> > 
>> > Qing
>> 
>> Acting as a reviewer of last resort since this isn't really my area,
>
> Sorry; life has been crazy lately.

NP, just thought I'd better justify treading in this area. :-)

>> but FWIW, I agree losing column tracking at the current limit is a
>> genuine regression and should be fixed for GCC 10.
>
> Is this a regression in GCC 10 though?  I think this has been the case
> since GCC 6 onwards.

Agree it's not a regression in GCC 10, but it still seems fair game
as a regression in general.

>> > gcc/ChangeLog:
>> > 
>> > 2020-04-03  qing zhao  
>> > 
>> 
>> Please add:
>> 
>>  PR c/94230
>> 
>> >* common.opt: Add -flocation-ranges.
>> >* doc/invoke.texi: Document it.
>> >* toplev.c (process_options): set line_table-
>> > >default_range_bits
>> >to 0 when flag_location_ranges is false. 
>> 
>> I think it would be worth adding a hint to use the new option to
>> get_visual_column, when warning about column tracking being disabled.
>> This should probably be a second inform(), immediately after the
>> current one.
>> 
>> > @@ -14151,6 +14151,13 @@ This option may be useful in conjunction
>> > with the @option{-B} or
>> >  perform additional processing of the program source between
>> >  normal preprocessing and compilation.
>> > 
>> > +@item -flocation-ranges
>> > +@opindex flocation-ranges
>> 
>> Normally the documented option should be the non-default one,
>> so -fno-... in this case.
>> 
>> > +Enable range tracking when recording source locations.
>> > +By default, GCC enables range tracking when recording source
>> > locations.
>> > +If disable range tracking by -fno-location-ranges, more location
>> > space
>> > +will be saved for column tracking.
>> 
>> My understanding is that the patch doesn't actually disable location-
>> range
>> tracking, but simply uses a less efficient form for *all* ranges,
>> rather
>> than only using the less efficient form for ranges that aren't "caret
>> at
>> start, length < 64 chars".
>
> Indeed.
>
>> I know you're simply following the suggestion in the PR, sorry,
>
> Sorry.  I did put a caveat on the suggestion FWIW.
>
>> but I wonder if the option should instead be:
>> 
>> -flarge-source-files
>> 
>> since that seems like a more user-facing concept.  The option would
>> tell GCC that the source files are likely to be very large and that
>> GCC should adapt accordingly.  In particular, the option makes GCC
>> cope with more source lines at the expense of slowing down
>> compilation
>> and using more memory.
>
> Another approach would be to go lower-level and introduce a param for
> this; something like "--param location-range-bits" defaulting to 5; the
> user can set it to 0 to disable the range-bit optimization to deal with
> bigger files, and it allows for experimentation without rebuilding the
> compiler.
>
> Again, I don't know if this is a good idea; I'm thinking aloud; I'm not
> sure what the best direction here is.

The reason I like the -flarge-source-files (suggestion for better
names welcome) is that the user is giving user-level information and
letting the compiler decide how to deal with that.  What the option
actually does can change with the implementation as necessary.

Potentially any user could hit the -Wmisleading-indent note, or could
hit the limit at which columns get dropped from diagnostics.  So while
this option isn't going to be used all that often, it also doesn't feel
like an option designed specifically for “power users” who like to
experiment with compiler internals.

Thanks,
Richard


Re: [PATCH, V4] PowerPC Turn on -mpcrel by default for -mcpu=future

2020-04-21 Thread Segher Boessenkool
On Tue, Apr 21, 2020 at 02:03:34PM -0400, Michael Meissner wrote:
> On Tue, Apr 07, 2020 at 05:58:01PM -0500, Segher Boessenkool wrote:
> > > +  /* Enable -mprefixed by default on 64-bit 'future' systems.  */
> > > +  if (TARGET_FUTURE && TARGET_POWERPC64
> > > +  && (rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) == 0)
> > > +rs6000_isa_flags |= OPTION_MASK_PREFIXED;
> > 
> > I don't understand why only for 64 bit?
> 
> I have doubts whether PC-relative really works with 32-bit.  I suspect that 
> you
> may see some hidden wrap around issues if an address crosses the 32-bit
> boundary.

Which is undefined behaviour *anyway*?  In C, etc.

The Power ISA makes it very clear how this behaves, though:

5.7.1 32-Bit Mode
The computation of the 64-bit effective address is inde-
pendent of whether the thread is in 32-bit mode or
64-bit mode. In 32-bit mode (MSR[SF]=0), the high-order
32 bits of the 64-bit effective address are treated as
zeros for the purpose of addressing storage. This
applies to both data accesses and instruction fetches. It
applies independent of whether address translation is
enabled or disabled. This truncation of the effective
address is the only respect in which storage accesses
in 32-bit mode differ from those in 64-bit mode.

> Given the simulator I have access to only runs Linux 64-bit, I have
> no way of testing it.  I would prefer to not put in code that I can't test.

Think of it as "this cannot happen", if that makes you feel better?  :-)

> But if the only way to get the patch in is to remove the test, I can remove 
> it.


Segher


[wwwdocs] Update list of new C++20 features in libstdc++

2020-04-21 Thread Jonathan Wakely via Gcc-patches
Committed to wwwdocs.

commit ba9d172720e36f93daf9c1b4569d4babe34e307e
Author: Jonathan Wakely 
Date:   Tue Apr 21 20:28:48 2020 +0100

Update list of new C++20 features in libstdc++

diff --git a/htdocs/gcc-10/changes.html b/htdocs/gcc-10/changes.html
index fc8f16e7..06a4267a 100644
--- a/htdocs/gcc-10/changes.html
+++ b/htdocs/gcc-10/changes.html
@@ -383,7 +383,24 @@ a work-in-progress.
 
   Improved experimental C++2a support, including:
 
+  
+Library concepts in  and
+.
+  
+  
+Constrained algorithms in ,
+, and
+ (thanks to Patrick Palka).
+  
+  
+New algorithms shift_left and shift_right
+(thanks to Patrick Palka).
+  
std::span (thanks to JeanHeyd Meneide). 
+  
+Three-way comparisons in 
+and throughout the library.
+  
   
 Constexpr support in  and elsewhere
 (thanks to Edward Smith-Rowland).
@@ -396,16 +413,11 @@ a work-in-progress.
 std::atomic_ref and
 std::atomic.
   
-   std::ssize, std::to_array. 
   
-Library concepts in  and
-.
+Integral comparison functions
+(cmp_equal, cmp_less etc.).
   
-  
-Constrained algorithms in  and
- (thanks to Patrick Palka).
-  
-   Three-way comparisons in . 
+   std::ssize, std::to_array. 
   
 std::construct_at, std::destroy,
 constexpr std::allocator.


[PATCH] add missing -Wno-stack-usage etc. options [PR90983]

2020-04-21 Thread Martin Sebor via Gcc-patches

In addition to accepting argument values in excess of INT_MAX in
options like -Walloca-larger-than=byte-size, GCC 9 has changed
the behavior of such options with byte-size of zero.  While in prior
versions zero disables the warning for any size, in GCC 9 it enables
it for all non-zero sizes.  Since all these byte-size options are
enabled by default for sizes in excess of PTRDIFF_MAX, users who
want to disable them need to use the newly added -Wno-xxx options
(such as -Wno-alloca-larger-than).

However, although I documented all of the new options, I only
remembered to add the negative options for the C/C++ family and
forgot about all the common ones, including -Wframe-larger-than=,
-Wlarger-than=, and -Wstack-usage=.  As a result, users who want
to disable the default, say -Wstack-usage, cannot use
the -Wno-stack-usage as the manual leads them to do but have to
use the less than intuitive workaround of specifying a very large
argument to the positive option, e.g., something like
-Wstack-usage=999EiB (denoting 999 etabytes).

To avoid this hassle the attached patch provides the three missing
negative options.

Tested on x86_64-linux.

Martin
PR driver/90983 - manual documents `-Wno-stack-usage` flag but it is unrecognized
gcc/ChangeLog:

	PR driver/90983
	* common.opt (-Wno-frame-larger-than): New option.
	(-Wno-larger-than, -Wno-stack-usage): Same.


gcc/testsuite/ChangeLog:

	PR driver/90983
	* gcc.dg/Wframe-larger-than-3.c: New test.
	* gcc.dg/Wlarger-than4.c: New test.
	* gcc.dg/Wstack-usage.c: New test.

diff --git a/gcc/common.opt b/gcc/common.opt
index 1e604ba9bb6..d33383b523c 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -601,6 +601,10 @@ Wframe-larger-than=
 Common RejectNegative Joined Host_Wide_Int ByteSize Warning Var(warn_frame_larger_than_size) Init(HOST_WIDE_INT_MAX)
 -Wframe-larger-than=	Warn if a function's stack frame requires in excess of .
 
+Wno-frame-larger-than
+Common Alias(Wframe-larger-than=,18446744073709551615EiB,none) Warning
+Disable -Wframe-larger-than= warning.  Equivalent to -Wframe-larger-than= or larger.
+
 Wfree-nonheap-object
 Common Var(warn_free_nonheap_object) Init(1) Warning
 Warn when attempting to free a non-heap object.
@@ -631,6 +635,10 @@ Wlarger-than=
 Common RejectNegative Joined Host_Wide_Int ByteSize Warning Var(warn_larger_than_size) Init(HOST_WIDE_INT_MAX)
 -Wlarger-than=	Warn if an object's size exceeds .
 
+Wno-larger-than
+Common Alias(Wlarger-than=,18446744073709551615EiB,none) Warning
+Disable -Wlarger-than= warning.  Equivalent to -Wlarger-than= or larger.
+
 Wnonnull-compare
 Var(warn_nonnull_compare) Warning
 Warn if comparing pointer parameter with nonnull attribute with NULL.
@@ -704,6 +712,10 @@ Wstack-usage=
 Common Joined RejectNegative Host_Wide_Int ByteSize Var(warn_stack_usage) Warning Init(HOST_WIDE_INT_MAX)
 -Wstack-usage=	Warn if stack usage might exceed .
 
+Wno-stack-usage
+Common Alias(Wstack-usage=,18446744073709551615EiB,none) Warning
+Disable Wstack-usage= warning.  Equivalent to Wstack-usage= or larger.
+
 Wstrict-aliasing
 Common Warning
 Warn about code which might break strict aliasing rules.
diff --git a/gcc/testsuite/gcc.dg/Wframe-larger-than-3.c b/gcc/testsuite/gcc.dg/Wframe-larger-than-3.c
new file mode 100644
index 000..ae5b2f497c7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wframe-larger-than-3.c
@@ -0,0 +1,11 @@
+/* PR 90983/manual documents `-Wno-stack-usage` flag, but it is unrecognized
+   { dg-do compile }
+   { dg-options "-Wall -Wframe-larger-than=123 -Wno-frame-larger-than" } */
+
+void f (void*);
+
+void g (void)
+{
+  char a [1234];
+  f (a);
+}
diff --git a/gcc/testsuite/gcc.dg/Wlarger-than4.c b/gcc/testsuite/gcc.dg/Wlarger-than4.c
new file mode 100644
index 000..dd936c671cd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wlarger-than4.c
@@ -0,0 +1,5 @@
+/* PR 90983/manual documents `-Wno-stack-usage` flag, but it is unrecognized
+   { dg-do compile }
+   { dg-options "-Wall -Wlarger-than=123 -Wno-larger-than" } */
+
+char a [1234];
diff --git a/gcc/testsuite/gcc.dg/Wstack-usage.c b/gcc/testsuite/gcc.dg/Wstack-usage.c
new file mode 100644
index 000..4738b69478b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstack-usage.c
@@ -0,0 +1,14 @@
+/* PR 90983/manual documents `-Wno-stack-usage` flag, but it is unrecognized
+   { dg-do compile }
+   { dg-options "-Wall -Wstack-usage=123 -Wno-stack-usage" } */
+
+void f (void*);
+
+void g (int n)
+{
+  if (n < 1234)
+n = 1234;
+
+  char a [n];
+  f (a);
+}


Re: [PATCH] c++: Diagnose invalid use of member function in requires

2020-04-21 Thread Jason Merrill via Gcc-patches

On 4/21/20 2:03 PM, Patrick Palka wrote:

This updates diagnose_valid_expression to mirror the convert_to_void check added
to tsubst_valid_expression_requirement by r10-7554.

Passes 'make check-c++', does this look OK to commit after a full
bootstrap/regtest?


OK, thanks.


gcc/cp/ChangeLog:

PR c++/67825
* constraint.cc (diagnose_valid_expression): Check convert_to_void here
as well as in tsubst_valid_expression_requirement.

gcc/testsuite/ChangeLog:

PR c++/67825
* g++.dg/concepts/diagnostic10.C: New test.
* g++.dg/cpp2a/concepts-pr67178.C: Adjust dg-note.
---
  gcc/cp/constraint.cc  |  8 ++--
  gcc/testsuite/g++.dg/concepts/diagnostic10.C  | 18 ++
  gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C |  2 +-
  3 files changed, 25 insertions(+), 3 deletions(-)
  create mode 100644 gcc/testsuite/g++.dg/concepts/diagnostic10.C

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index d56ec101cd9..c05fafe5da1 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -3242,7 +3242,8 @@ static tree
  diagnose_valid_expression (tree expr, tree args, tree in_decl)
  {
tree result = tsubst_expr (expr, args, tf_none, in_decl, false);
-  if (result != error_mark_node)
+  if (result != error_mark_node
+  && convert_to_void (result, ICV_STATEMENT, tf_none) != error_mark_node)
  return result;
  
location_t loc = cp_expr_loc_or_input_loc (expr);

@@ -3250,7 +3251,10 @@ diagnose_valid_expression (tree expr, tree args, tree 
in_decl)
  {
/* Replay the substitution error.  */
inform (loc, "the required expression %qE is invalid, because", expr);
-  tsubst_expr (expr, args, tf_error, in_decl, false);
+  if (result == error_mark_node)
+   tsubst_expr (expr, args, tf_error, in_decl, false);
+  else
+   convert_to_void (result, ICV_STATEMENT, tf_error);
  }
else
  inform (loc, "the required expression %qE is invalid", expr);
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic10.C 
b/gcc/testsuite/g++.dg/concepts/diagnostic10.C
new file mode 100644
index 000..fcc6043ca93
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/diagnostic10.C
@@ -0,0 +1,18 @@
+// PR c++/67825
+// { dg-do compile { target concepts } }
+// { dg-additional-options "-fconcepts-diagnostics-depth=2" }
+
+template
+  requires requires (T t) { t.f; } // { dg-error "invalid use of non-static member 
function" }
+void foo() { }
+
+struct S
+{
+  int f();
+};
+
+void
+bar()
+{
+  foo(); // { dg-error "unsatisfied constraints" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C
index ff84711a7af..7154fc2b7fe 100644
--- a/gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-pr67178.C
@@ -12,7 +12,7 @@ concept C0 = requires (auto x) { // { dg-error "placeholder 
type" }
  template
  concept C1 = requires (C1 auto x) { // { dg-error "not been 
declared|placeholder|two or more|in requirements" }
x; // { dg-error "not declared" }
-  { x } -> c; // { dg-message "not declared|does not satisfy" }
+  { x } -> c; // { dg-message "is invalid" }
  };
  
  template






[PATCH] coroutines: Fix for uses of structured binding [PR94701]

2020-04-21 Thread Iain Sandoe
Hi,

As reported by Michał Dominiak, we are generating incorrect code
for structured binding of local vars.  Somewhere in the machinations
associated with lambda captures, I messed up the code handling
DECL_VALUE_EXPRs. 

tested so far on x86_64-darwin16,
OK for master if it passes regstrap on x86-64-Linux?
thanks
Iain



Structured binding makes use of the DECL_VALUE_EXPR fields
in local variables.  We need to recognise these and only amend
the expression values, retaining the 'alias' value intact.

gcc/cp/ChangeLog:

2020-04-21  Iain Sandoe  

PR c++/94701
* coroutines.cc (struct local_var_info): Add fields for static
variables and those with DECL_VALUE_EXPR redirection.
(transform_local_var_uses):  Skip past typedefs and static vars
and then account for redirected variables.
(register_local_var_uses): Likewise.

gcc/testsuite/ChangeLog:

2020-04-21  Iain Sandoe  

PR c++/94701
* g++.dg/coroutines/torture/local-var-06-structured-binding.C: New test.
---
 gcc/cp/coroutines.cc  | 40 ++
 .../torture/local-var-06-structured-binding.C | 55 +++
 2 files changed, 84 insertions(+), 11 deletions(-)
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/local-var-06-structured-binding.C

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 30676eba6c2..5580247edfc 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -1776,6 +1776,8 @@ struct local_var_info
   tree field_idx;
   tree frame_type;
   bool is_lambda_capture;
+  bool is_static;
+  bool has_value_expr_p;
   location_t def_loc;
 };
 
@@ -1821,7 +1823,7 @@ transform_local_var_uses (tree *stmt, int *do_subtree, 
void *d)
NULL);
 
/* For capture proxies, this could include the decl value expr.  */
-   if (local_var.is_lambda_capture)
+   if (local_var.is_lambda_capture || local_var.has_value_expr_p)
  {
tree ve = DECL_VALUE_EXPR (lvar);
cp_walk_tree (&ve, transform_local_var_uses, d, NULL);
@@ -1854,15 +1856,12 @@ transform_local_var_uses (tree *stmt, int *do_subtree, 
void *d)
 
  /* Leave lambda closure captures alone, we replace the *this
 pointer with the frame version and let the normal process
-deal with the rest.  */
- if (local_var.is_lambda_capture)
-   {
- pvar = &DECL_CHAIN (*pvar);
- continue;
-   }
-
- /* It's not used, but we can let the optimizer deal with that.  */
- if (local_var.field_id == NULL_TREE)
+deal with the rest.
+Likewise, variables with their value found elsewhere.
+Skip past unused ones too.  */
+ if (local_var.is_lambda_capture
+|| local_var.has_value_expr_p
+|| local_var.field_id == NULL_TREE)
{
  pvar = &DECL_CHAIN (*pvar);
  continue;
@@ -1896,10 +1895,13 @@ transform_local_var_uses (tree *stmt, int *do_subtree, 
void *d)
  for the promise and coroutine handle(s), to global vars or to compiler
  temporaries.  Skip past these, we will handle them later.  */
   local_var_info *local_var_i = lvd->local_var_uses->get (var_decl);
+
   if (local_var_i == NULL)
 return NULL_TREE;
 
-  if (local_var_i->is_lambda_capture)
+  if (local_var_i->is_lambda_capture
+  || local_var_i->is_static
+  || local_var_i->has_value_expr_p)
 return NULL_TREE;
 
   /* This is our revised 'local' i.e. a frame slot.  */
@@ -3021,6 +3023,16 @@ register_local_var_uses (tree *stmt, int *do_subtree, 
void *d)
  tree lvtype = TREE_TYPE (lvar);
  local_var.frame_type = lvtype;
  local_var.field_idx = local_var.field_id = NULL_TREE;
+
+ /* Make sure that we only present vars to the tests below.  */
+ if (TREE_CODE (lvar) == TYPE_DECL)
+   continue;
+
+ /* We don't move static vars into the frame. */
+ local_var.is_static = TREE_STATIC (lvar);
+ if (local_var.is_static)
+   continue;
+
  lvd->local_var_seen = true;
  /* If this var is a lambda capture proxy, we want to leave it alone,
 and later rewrite the DECL_VALUE_EXPR to indirect through the
@@ -3029,6 +3041,12 @@ register_local_var_uses (tree *stmt, int *do_subtree, 
void *d)
  if (local_var.is_lambda_capture)
continue;
 
+ /* If a variable has a value expression, then that's what needs
+to be processed.  */
+ local_var.has_value_expr_p = DECL_HAS_VALUE_EXPR_P (lvar);
+ if (local_var.has_value_expr_p)
+   continue;
+
  /* Make names depth+index unique, so that we can support nested
 scopes with identically named locals.  */
  tree lvname = DECL_NAME (lvar);
diff --git 
a/gcc/testsuite/g++.dg/coroutines/torture/local-var-06-structured-binding.C 
b/gcc/testsuite/g++.dg/corout

Re: [PATCH] reject scalar array initialization with nullptr [PR94510]

2020-04-21 Thread Jason Merrill via Gcc-patches

On 4/17/20 5:18 PM, Martin Sebor wrote:

On 4/17/20 12:19 AM, Jason Merrill wrote:

On 4/15/20 1:30 PM, Martin Sebor wrote:

On 4/13/20 8:43 PM, Jason Merrill wrote:

On 4/12/20 5:49 PM, Martin Sebor wrote:

On 4/10/20 8:52 AM, Jason Merrill wrote:

On 4/9/20 4:23 PM, Martin Sebor wrote:

On 4/9/20 1:32 PM, Jason Merrill wrote:

On 4/9/20 3:24 PM, Martin Sebor wrote:

On 4/9/20 1:03 PM, Jason Merrill wrote:

On 4/8/20 1:23 PM, Martin Sebor wrote:

On 4/7/20 3:36 PM, Marek Polacek wrote:

On Tue, Apr 07, 2020 at 02:46:52PM -0600, Martin Sebor wrote:

On 4/7/20 1:50 PM, Marek Polacek wrote:
On Tue, Apr 07, 2020 at 12:50:48PM -0600, Martin Sebor via 
Gcc-patches wrote:
Among the numerous regressions introduced by the change 
committed
to GCC 9 to allow string literals as template arguments 
is a failure
to recognize the C++ nullptr and GCC's __null constants 
as pointers.
For one, I didn't realize that nullptr, being a null 
pointer constant,
doesn't have a pointer type, and two, I didn't think of 
__null (which
is a special integer constant that NULL sometimes expands 
to).


The attached patch adjusts the special handling of 
trailing zero
initializers in reshape_init_array_1 to recognize both 
kinds of
constants and avoid treating them as zeros of the array 
integer
element type.  This restores the expected diagnostics 
when either

constant is used in the initializer list.

Martin


PR c++/94510 - nullptr_t implicitly cast to zero twice in 
std::array


gcc/cp/ChangeLog:

PR c++/94510
* decl.c (reshape_init_array_1): Exclude mismatches 
with all kinds

of pointers.

gcc/testsuite/ChangeLog:

PR c++/94510
* g++.dg/init/array57.C: New test.
* g++.dg/init/array58.C: New test.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a127734af69..692c8ed73f4 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6041,9 +6041,14 @@ reshape_init_array_1 (tree 
elt_type, tree max_index, reshape_iter *d,

   TREE_CONSTANT (new_init) = false;
 /* Pointers initialized to strings must be 
treated as non-zero

- even if the string is empty.  */
+ even if the string is empty.  Handle all kinds of 
pointers,
+ including std::nullptr and GCC's __nullptr, neither 
of which

+ has a pointer type.  */
 tree init_type = TREE_TYPE (elt_init);
-  if (POINTER_TYPE_P (elt_type) != POINTER_TYPE_P 
(init_type)

+  bool init_is_ptr = (POINTER_TYPE_P (init_type)
+  || NULLPTR_TYPE_P (init_type)
+  || null_node_p (elt_init));
+  if (POINTER_TYPE_P (elt_type) != init_is_ptr
 || !type_initializer_zero_p (elt_type, elt_init))
   last_nonzero = index;


It looks like this still won't handle e.g. pointers to 
member functions,

e.g.

struct S { };
int arr[3] = { (void (S::*) ()) 0, 0, 0 };

would still be accepted.  You could use 
TYPE_PTR_OR_PTRMEM_P instead of

POINTER_TYPE_P to catch this case.


Good catch!  That doesn't fail because unlike null data 
member pointers
which are represented as -1, member function pointers are 
represented

as a zero.

I had looked for an API that would answer the question: "is 
this
expression a pointer?" without having to think of all the 
different
kinds of them but all I could find was null_node_p().  Is 
this a rare,
isolated case that having an API like that wouldn't be 
worth having

or should I add one like in the attached update?

Martin


PR c++/94510 - nullptr_t implicitly cast to zero twice in 
std::array


gcc/cp/ChangeLog:

PR c++/94510
* decl.c (reshape_init_array_1): Exclude mismatches 
with all kinds

of pointers.
* gcc/cp/cp-tree.h (null_pointer_constant_p): New 
function.


(Drop the gcc/cp/.)

+/* Returns true if EXPR is a null pointer constant of any 
type.  */

+
+inline bool
+null_pointer_constant_p (tree expr)
+{
+  STRIP_ANY_LOCATION_WRAPPER (expr);
+  if (expr == null_node)
+    return true;
+  tree type = TREE_TYPE (expr);
+  if (NULLPTR_TYPE_P (type))
+    return true;
+  if (POINTER_TYPE_P (type))
+    return integer_zerop (expr);
+  return null_member_pointer_value_p (expr);
+}
+


We already have a null_ptr_cst_p so it would be sort of 
confusing to have
this as well.  But are you really interested in whether it's 
a null pointer,

not just a pointer?


The goal of the code is to detect a mismatch in "pointerness" 
between
an initializer expression and the type of the initialized 
element, so
it needs to know if the expression is a pointer (non-nulls 
pointers
are detected in type_initializer_zero_p).  That means testing 
a number

of IMO unintuitive conditions:

   TYPE_PTR_OR_PTRMEM_P (TREE_TYPE (expr))
   || NULLPTR_TYPE_P (TREE_TYPE (expr))
   || null_node_p (expr)

I don't know if this type of a query is common in the C++ FE 
but unless
this is an isolated use case then besides fixing the bug I 
thought it
would be nice to make it easier to get the test above right, 
or at least

come close to it.

Since null_pointer_constant_p already exists (but isn't 
su

Re: [PATCH 1/1] testsuite: Handle --save-temps in schedule-cleanups

2020-04-21 Thread Jeff Law via Gcc-patches
On Mon, 2020-04-20 at 11:43 +, Christophe Lyon via Gcc-patches wrote:
> Some tests use --save-temps, but schedule-cleanups strictly matches
> -save-temps, so we leave many temporary files after validation.
> Instead of fixing every offending testcase, it's simpler and
> future-proof to make schedule-cleanups handle both --save-temps and
> -save-temps.
> 
> 2020-04-20  Christophe Lyon  
> 
>   gcc/testsuite/
>   * lib/gcc-dg.exp (schedule-cleanups): Accept --save-temps.
OK
Jeff
> 



Re: [PATCH] Fix use of singleton in optinfo framework

2020-04-21 Thread Gustavo Romero via Gcc-patches

Hi Hans,

On 4/14/20 12:33 AM, Hans-Peter Nilsson wrote:

Sadly this patch doesn't fix PR bootstrap/87252; I just checked
against f8e72b8d9f2:f81653ba8c1:2dd4ceacd8b (truncated from
LAST_UPDATED; I don't remember which field is the actual
commit).


So, would you mind to tell me precisely how to reproduce nowadays
that bug? Which gcc version and from which distro/OS/32 or 64-bit
you're using to reproduce it? Given the stacktrace you share on
PR87252 I'm not really surprise my patch didn't help.

If I can reproduce it easily I can try to drill it further.


Thanks,
Gustavo


[committed] libphobos: Remove GDCFLAGSX variable from configure scripts.

2020-04-21 Thread Iain Buclaw via Gcc-patches
Hi,

This patch changes the testsuite to compile all tests with the same
GDCFLAGS as used to build the library.  Notably, this would now be using
"-O2", whereas before the testsuite was compiling all tests with "-O0".

That we are now compiling with "-O2", there is a  possibility of
previously hidden bugs getting exposed.  Likewise, the time it takes to
run the libphobos testsuite has increased by some  considerable measure,
especially the template-heavy libphobos.phobos and
libphobos.phobos_shared unittests.

If it is a noticeable problem, then can consider overriding these two
test programs with "-O0" if run_expensive_tests is disabled.

Bootstrapped and regression tested on x86_64-linux-gnu with
--target_board configurations -m64,-m32,-mx32.

Testsuite summaries:

=== gdc tests ===
Running target unix/-m32
=== gdc Summary for unix/-m32 ===
# of expected passes30546

Running target unix/-m64
=== gdc Summary for unix/-m64 ===
# of expected passes30546

Running target unix/-mx32
=== gdc Summary for unix/-mx32 ===
# of expected passes30546

=== gdc Summary ===
# of expected passes91638

=== libphobos tests ===
Running target unix/-m32
=== libphobos Summary for unix/-m32 ===
# of expected passes752
# of unsupported tests  2

Running target unix/-m64
=== libphobos Summary for unix/-m64 ===
# of expected passes756

Running target unix/-mx32
FAIL: 
libphobos.phobos/std/experimental/allocator/building_blocks/kernighan_ritchie.d 
execution test
FAIL: 
libphobos.phobos_shared/std/experimental/allocator/building_blocks/kernighan_ritchie.d
 execution test
=== libphobos Summary for unix/-mx32 ===
# of expected passes750
# of unexpected failures2
# of unsupported tests  2

=== libphobos Summary ===
# of expected passes2258
# of unexpected failures2
# of unsupported tests  4


The new failure on X32 is caused by glibc bug in syscall interface:
https://sourceware.org/bugzilla/show_bug.cgi?id=25810

Committed to mainline.

Regards
Iain.

---
libphobos/ChangeLog:

* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Remove GDCFLAGSX.
* libdruntime/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* testsuite/testsuite_flags.in: Use GDCFLAGS in --gdcflags.
* testsuite/libphobos.thread/fiber_guard_page.d: Test using -O0.
---
 libphobos/Makefile.in  |  1 -
 libphobos/configure| 10 ++
 libphobos/configure.ac |  5 -
 libphobos/libdruntime/Makefile.in  |  1 -
 libphobos/src/Makefile.in  |  1 -
 libphobos/testsuite/Makefile.in|  1 -
 .../testsuite/libphobos.thread/fiber_guard_page.d  |  1 +
 libphobos/testsuite/testsuite_flags.in |  2 +-
 8 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/libphobos/Makefile.in b/libphobos/Makefile.in
index b464d605232..e51c2158b20 100644
--- a/libphobos/Makefile.in
+++ b/libphobos/Makefile.in
@@ -230,7 +230,6 @@ EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GDC = @GDC@
 GDCFLAGS = @GDCFLAGS@
-GDCFLAGSX = @GDCFLAGSX@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
diff --git a/libphobos/configure b/libphobos/configure
index 2658cc1728a..c2b49132fda 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -634,7 +634,6 @@ am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
 WARN_DFLAGS
-GDCFLAGSX
 libtool_VERSION
 SPEC_PHOBOS_DEPS
 CHECKING_DFLAGS
@@ -11650,7 +11649,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11653 "configure"
+#line 11652 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11756,7 +11755,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11759 "configure"
+#line 11758 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15433,11 +15432,6 @@ if test -z "$GDCFLAGS"; then
 fi
 
 
-if test -z "$GDCFLAGSX"; then
-GDCFLAGSX="-g"
-fi
-
-
 WARN_DFLAGS="-Wall $WERROR_FLAG"
 
 
diff --git a/libphobos/configure.ac b/libphobos/configure.ac
index 9de36c84be7..c21da5908d0 100644
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -256,11 +256,6 @@ if test -z "$GDCFLAGS"; then
 fi
 AC_SUBST(GDCFLAGS)
 
-if test -z "$GDCFLAGSX"; then
-GDCFLAGSX="-g"
-fi
-AC_SUBST(GDCFLAGSX)
-
 WARN_DFLAGS="-Wall $WERROR_FLAG"
 AC_SUBST(WARN_DFLAGS)
 
diff --git a/libphobos/libdruntime/Makefile.in 
b/libphobos/libdruntime/Makefile.in
index 3bb023ffc97..4130e96d7be 100644
--- a/libphobos/li

[committed] libstdc++: Improve C++14 and C++17 status docs

2020-04-21 Thread Jonathan Wakely via Gcc-patches
This adds a full table of contents for the C++14 and C++17 standards,
with status for each part.

For C++14 the list of proposals is removed, as it adds little value now
that everything is supported. For C++17 the table of proposals is
retained, because it documents he feature test macros for the features.

* doc/Makefile.am (xml_sources_manual): Add missing XML files.
* doc/Makefile.in: Regenerate.
* doc/xml/manual/status_cxx1998.xml: Refer to "this section" instead
of "this page".
* doc/xml/manual/status_cxx2011.xml: Formatting and other corrections
to the C++11 status table.
* doc/xml/manual/status_cxx2014.xml: Replace list of C++14 feature
proposals with table matching contents of the C++14 standard.
* doc/xml/manual/status_cxx2017.xml: Add table matching contents of
the C++17 standard.
* doc/html/*: Regenerate.

Committed to master.

I'm in the process of updating the C++20 status docs, but the patch
isn't ready yet.

commit 57ede05c6a0b443943e312bf205cb79233c9396f
Author: Jonathan Wakely 
Date:   Tue Apr 21 22:18:51 2020 +0100

libstdc++: Improve C++14 and C++17 status docs

This adds a full table of contents for the C++14 and C++17 standards,
with status for each part.

For C++14 the list of proposals is removed, as it adds little value now
that everything is supported. For C++17 the table of proposals is
retained, because it documents he feature test macros for the features.

* doc/Makefile.am (xml_sources_manual): Add missing XML files.
* doc/Makefile.in: Regenerate.
* doc/xml/manual/status_cxx1998.xml: Refer to "this section" instead
of "this page".
* doc/xml/manual/status_cxx2011.xml: Formatting and other 
corrections
to the C++11 status table.
* doc/xml/manual/status_cxx2014.xml: Replace list of C++14 feature
proposals with table matching contents of the C++14 standard.
* doc/xml/manual/status_cxx2017.xml: Add table matching contents of
the C++17 standard.
* doc/html/*: Regenerate.

diff --git a/libstdc++-v3/doc/Makefile.am b/libstdc++-v3/doc/Makefile.am
index 32417d8ee2d..33386db52af 100644
--- a/libstdc++-v3/doc/Makefile.am
+++ b/libstdc++-v3/doc/Makefile.am
@@ -341,6 +341,8 @@ xml_sources_manual = \
${xml_dir}/manual/status_cxx1998.xml \
${xml_dir}/manual/status_cxx2011.xml \
${xml_dir}/manual/status_cxx2014.xml \
+   ${xml_dir}/manual/status_cxx2017.xml \
+   ${xml_dir}/manual/status_cxx2020.xml \
${xml_dir}/manual/status_cxxtr1.xml \
${xml_dir}/manual/status_cxxtr24733.xml \
${xml_dir}/manual/strings.xml \
diff --git a/libstdc++-v3/doc/xml/manual/status_cxx1998.xml 
b/libstdc++-v3/doc/xml/manual/status_cxx1998.xml
index cf5722377a6..792272bcf26 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx1998.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx1998.xml
@@ -1,4 +1,4 @@
-http://docbook.org/ns/docbook"; version="5.0" 
+http://docbook.org/ns/docbook"; version="5.0"
 xml:id="status.iso.1998" xreflabel="ISO C++ 1998">
 
 
@@ -11,14 +11,14 @@
 
 
 
-Implementation Status  
+Implementation Status
 
 
 This status table is based on the table of contents of ISO/IEC 14882:2003.
 
 
 
-This page describes the C++ support in mainline GCC, not in any
+This section describes the C++ support in mainline GCC, not in any
 particular release.
 
 
@@ -1030,7 +1030,7 @@ particular release.
 
 
 Implementation Specific Behavior
-  
+
 

  The ISO standard defines the following phrase:
diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2011.xml 
b/libstdc++-v3/doc/xml/manual/status_cxx2011.xml
index 9d2de532f3d..e8f8784c1e9 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2011.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2011.xml
@@ -1,4 +1,4 @@
-http://docbook.org/ns/docbook"; version="5.0" 
+http://docbook.org/ns/docbook"; version="5.0"
 xml:id="status.iso.2011" xreflabel="Status C++ 2011">
 
 
@@ -27,7 +27,11 @@ presence of the required flag.
 
 
 
-This page describes the C++11 support in mainline GCC, not in any
+This status table is based on the table of contents of ISO/IEC 14882:2011.
+
+
+
+This section describes the C++11 support in mainline GCC, not in any
 particular release.
 
 
@@ -71,7 +75,7 @@ particular release.
 
   18.1
   General
-  Y
+  
   
 
 
@@ -265,7 +269,7 @@ particular release.
 
   19.1
   General
-  Y
+  
   
 
 
@@ -350,13 +354,13 @@ particular release.
 
 
   20.2.2
-  Swap
+  swap
   Y
   
 
 
   20.2.3
-  forward and move helpers
+  forward/move helpers
   Y
   
 
@@ -627,7 +631,7 @@ particular release.
 
   20.7.2
   Shared-ownership pointers
-  Y
+  
   
 
 
@@ -653,7 +657,7 @@ particula

Re: [PATCH] c++: Constrained inherited constructor template [PR94549]

2020-04-21 Thread Jason Merrill via Gcc-patches

On 4/20/20 4:38 PM, Patrick Palka wrote:

A comment in satisfy_declaration constraints says

   /* For inherited constructors, consider the original declaration;
  it has the correct template information attached. */
   d = strip_inheriting_ctors (d);

But this comment seems to be false when the inherited constructor points to an
instantiation of a constructor template.  In this case, DECL_TEMPLATE_INFO is
correct and DECL_INHERITED_CTOR points to the constructor template of the base
class rather than to the particular instantiation of the constructor template
(and so the DECL_TI_ARGS of the DECL_INHERITED_CTOR are in their dependent
form).

So doing strip_inheriting_ctors in this case then eventually leads to
satisfy_associated_constraints returning true regardless of the constraints
themselves, due to the passed in 'args' being dependent.

Since DECL_TEMPLATE_INFO seems to be non-NULL for an inherited constructor only
when the inherited constructor points to an instantiation of a constructor
template, this patch fixes this issue by avoiding to call strip_inheriting_ctors
when DECL_TEMPLATE_INFO is already non-NULL.

There is another unguarded call to strip_inheriting_ctors in
get_normalized_constraints_from_decl, but this one seems to be safe to do
unconditionally because the rest of that function doesn't need/look at the
DECL_TI_ARGS of the decl.

Passes 'make check-c++', does this look OK to commit after bootstrap/regtesting?


OK.


gcc/cp/ChangeLog:

PR c++/94549
* constraint.cc (satisfy_declaration_constraints): Don't strip the
inherited constructor if it already has template information.

gcc/testsuite/ChangeLog:

PR c++/94549
* g++.dg/concepts/inherit-ctor3.C: Adjust expected diagnostics.
* g++.dg/cpp2a/concepts-inherit-ctor4.C: Adjust expected diagnostics.
* g++.dg/cpp2a/concepts-inherit-ctor8.C: New test.
---
  gcc/cp/constraint.cc  |  7 ---
  gcc/testsuite/g++.dg/concepts/inherit-ctor3.C |  4 ++--
  .../g++.dg/cpp2a/concepts-inherit-ctor4.C |  4 ++--
  .../g++.dg/cpp2a/concepts-inherit-ctor8.C | 20 +++
  4 files changed, 28 insertions(+), 7 deletions(-)
  create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor8.C

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 320792195d6..b76402c2f85 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -2737,9 +2737,10 @@ satisfy_declaration_constraints (tree t, subst_info info)
  {
gcc_assert (DECL_P (t));
  
-  /* For inherited constructors, consider the original declaration;

- it has the correct template information attached. */
-  if (flag_new_inheriting_ctors)
+  if (!DECL_TEMPLATE_INFO (t))
+/* For inherited constructors without template information, consider
+   the original declaration; it has the correct template information
+   attached.  */
  t = strip_inheriting_ctors (t);
  
/* Update the declaration for diagnostics.  */

diff --git a/gcc/testsuite/g++.dg/concepts/inherit-ctor3.C 
b/gcc/testsuite/g++.dg/concepts/inherit-ctor3.C
index abfe96e8240..6b7a7a43910 100644
--- a/gcc/testsuite/g++.dg/concepts/inherit-ctor3.C
+++ b/gcc/testsuite/g++.dg/concepts/inherit-ctor3.C
@@ -12,12 +12,12 @@ template
  
  template

struct S2 : S1 { // { dg-error "no matching function" }
-using S1::S1; // { dg-error "no matching function" }
+using S1::S1;
};
  
  struct X { } x;
  
  int main() {

-  S2 s1(0); // { dg-error "use of deleted function" }
+  S2 s1(0); // { dg-error "no matching function" }
S2 s2; // { dg-error "use of deleted function" }
  }
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor4.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor4.C
index 75190eb3413..34eaf22c26c 100644
--- a/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor4.C
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor4.C
@@ -10,9 +10,9 @@ template
  
  template

struct S2 : S1 {
-using S1::S1; // { dg-error "no matching function" }
+using S1::S1;
};
  
  int main() {

-  S2 s(0); // { dg-error "use of deleted function" }
+  S2 s(0); // { dg-error "no matching function" }
  }
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor8.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor8.C
new file mode 100644
index 000..5b571e32318
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor8.C
@@ -0,0 +1,20 @@
+// PR c++/94549
+// { dg-do compile { target concepts } }
+
+struct base {
+  template 
+requires false
+  base(type);
+
+  template 
+requires true
+  base(type);
+};
+
+struct derived : base {
+  using base::base;
+};
+
+void foo() {
+  derived{'G'};
+}





Re: [PATCH] reject scalar array initialization with nullptr [PR94510]

2020-04-21 Thread Martin Sebor via Gcc-patches

On 4/21/20 2:33 PM, Jason Merrill wrote:

On 4/17/20 5:18 PM, Martin Sebor wrote:

On 4/17/20 12:19 AM, Jason Merrill wrote:

On 4/15/20 1:30 PM, Martin Sebor wrote:

On 4/13/20 8:43 PM, Jason Merrill wrote:

On 4/12/20 5:49 PM, Martin Sebor wrote:

On 4/10/20 8:52 AM, Jason Merrill wrote:

On 4/9/20 4:23 PM, Martin Sebor wrote:

On 4/9/20 1:32 PM, Jason Merrill wrote:

On 4/9/20 3:24 PM, Martin Sebor wrote:

On 4/9/20 1:03 PM, Jason Merrill wrote:

On 4/8/20 1:23 PM, Martin Sebor wrote:

On 4/7/20 3:36 PM, Marek Polacek wrote:

On Tue, Apr 07, 2020 at 02:46:52PM -0600, Martin Sebor wrote:

On 4/7/20 1:50 PM, Marek Polacek wrote:
On Tue, Apr 07, 2020 at 12:50:48PM -0600, Martin Sebor 
via Gcc-patches wrote:
Among the numerous regressions introduced by the change 
committed
to GCC 9 to allow string literals as template arguments 
is a failure
to recognize the C++ nullptr and GCC's __null constants 
as pointers.
For one, I didn't realize that nullptr, being a null 
pointer constant,
doesn't have a pointer type, and two, I didn't think of 
__null (which
is a special integer constant that NULL sometimes 
expands to).


The attached patch adjusts the special handling of 
trailing zero
initializers in reshape_init_array_1 to recognize both 
kinds of
constants and avoid treating them as zeros of the array 
integer
element type.  This restores the expected diagnostics 
when either

constant is used in the initializer list.

Martin


PR c++/94510 - nullptr_t implicitly cast to zero twice 
in std::array


gcc/cp/ChangeLog:

PR c++/94510
* decl.c (reshape_init_array_1): Exclude mismatches 
with all kinds

of pointers.

gcc/testsuite/ChangeLog:

PR c++/94510
* g++.dg/init/array57.C: New test.
* g++.dg/init/array58.C: New test.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a127734af69..692c8ed73f4 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6041,9 +6041,14 @@ reshape_init_array_1 (tree 
elt_type, tree max_index, reshape_iter *d,

   TREE_CONSTANT (new_init) = false;
 /* Pointers initialized to strings must be 
treated as non-zero

- even if the string is empty.  */
+ even if the string is empty.  Handle all kinds of 
pointers,
+ including std::nullptr and GCC's __nullptr, 
neither of which

+ has a pointer type.  */
 tree init_type = TREE_TYPE (elt_init);
-  if (POINTER_TYPE_P (elt_type) != POINTER_TYPE_P 
(init_type)

+  bool init_is_ptr = (POINTER_TYPE_P (init_type)
+  || NULLPTR_TYPE_P (init_type)
+  || null_node_p (elt_init));
+  if (POINTER_TYPE_P (elt_type) != init_is_ptr
 || !type_initializer_zero_p (elt_type, elt_init))
   last_nonzero = index;


It looks like this still won't handle e.g. pointers to 
member functions,

e.g.

struct S { };
int arr[3] = { (void (S::*) ()) 0, 0, 0 };

would still be accepted.  You could use 
TYPE_PTR_OR_PTRMEM_P instead of

POINTER_TYPE_P to catch this case.


Good catch!  That doesn't fail because unlike null data 
member pointers
which are represented as -1, member function pointers are 
represented

as a zero.

I had looked for an API that would answer the question: 
"is this
expression a pointer?" without having to think of all the 
different
kinds of them but all I could find was null_node_p().  Is 
this a rare,
isolated case that having an API like that wouldn't be 
worth having

or should I add one like in the attached update?

Martin


PR c++/94510 - nullptr_t implicitly cast to zero twice in 
std::array


gcc/cp/ChangeLog:

PR c++/94510
* decl.c (reshape_init_array_1): Exclude mismatches 
with all kinds

of pointers.
* gcc/cp/cp-tree.h (null_pointer_constant_p): New 
function.


(Drop the gcc/cp/.)

+/* Returns true if EXPR is a null pointer constant of any 
type.  */

+
+inline bool
+null_pointer_constant_p (tree expr)
+{
+  STRIP_ANY_LOCATION_WRAPPER (expr);
+  if (expr == null_node)
+    return true;
+  tree type = TREE_TYPE (expr);
+  if (NULLPTR_TYPE_P (type))
+    return true;
+  if (POINTER_TYPE_P (type))
+    return integer_zerop (expr);
+  return null_member_pointer_value_p (expr);
+}
+


We already have a null_ptr_cst_p so it would be sort of 
confusing to have
this as well.  But are you really interested in whether 
it's a null pointer,

not just a pointer?


The goal of the code is to detect a mismatch in 
"pointerness" between
an initializer expression and the type of the initialized 
element, so
it needs to know if the expression is a pointer (non-nulls 
pointers
are detected in type_initializer_zero_p).  That means 
testing a number

of IMO unintuitive conditions:

   TYPE_PTR_OR_PTRMEM_P (TREE_TYPE (expr))
   || NULLPTR_TYPE_P (TREE_TYPE (expr))
   || null_node_p (expr)

I don't know if this type of a query is common in the C++ FE 
but unless
this is an isolated use case then besides fixing the bug I 
thought it
would be nice to make it easier to get the test above right, 
or at least

come close to it.

Since null_pointe

[PATCH][v3], rs6000: Use plq/pstq for atomic_{load, store} (PR94622)

2020-04-21 Thread Aaron Sawdey via Gcc-patches
For future architecture with prefix instructions, always use plq/pstq
rather than lq/stq for atomic load of quadword. Then we never have to
do the doubleword swap on little endian. Before this fix, -mno-pcrel
would generate lq with the doubleword swap (which was ok) and -mpcrel
would generate plq, also with the doubleword swap, which was wrong.

While adding comments I realized we have exactly the same problem with
pstq/stq so I have added fixes for that as well. Assuming that regstrap
passes, OK for trunk?

Thanks,
   Aaron

2020-04-20  Aaron Sawdey  

PR target/94622
* config/rs6000/sync.md (load_quadpti): Add attr "prefixed"
if TARGET_PREFIXED.
(store_quadpti): Ditto.
(atomic_load): Do not swap doublewords if TARGET_PREFIXED as
plq will be used and doesn't need it.
(atomic_store): Ditto, for pstq.
---
 gcc/config/rs6000/sync.md | 27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/gcc/config/rs6000/sync.md b/gcc/config/rs6000/sync.md
index f27edc77b6a..bf529fc8268 100644
--- a/gcc/config/rs6000/sync.md
+++ b/gcc/config/rs6000/sync.md
@@ -122,6 +122,7 @@ (define_insn "loadsync_"
   [(set_attr "type" "isync")
(set_attr "length" "12")])
 
+;; If TARGET_PREFIXED, always use plq rather than lq.
 (define_insn "load_quadpti"
   [(set (match_operand:PTI 0 "quad_int_reg_operand" "=&r")
(unspec:PTI
@@ -129,8 +130,18 @@ (define_insn "load_quadpti"
   "TARGET_SYNC_TI
&& !reg_mentioned_p (operands[0], operands[1])"
   "lq %0,%1"
-  [(set_attr "type" "load")])
-
+  [(set_attr "type" "load")
+   (set (attr "prefixed") (if_then_else (match_test "TARGET_PREFIXED")
+(const_string "yes")
+(const_string "no")))])
+
+;; Pattern load_quadpti will always use plq for atomic TImode if
+;; TARGET_PREFIXED.  It has the correct doubleword ordering on either LE
+;; or BE, so we can just move the result into the output register and
+;; do not need to do the doubleword swap for LE. Also this avoids any
+;; confusion about whether the lq vs plq might be used based on whether
+;; op1 has PC-relative addressing. We could potentially allow BE to
+;; use lq because it doesn't have the doubleword ordering problem.
 (define_expand "atomic_load"
   [(set (match_operand:AINT 0 "register_operand")  ;; output
(match_operand:AINT 1 "memory_operand"));; memory
@@ -162,7 +173,7 @@ (define_expand "atomic_load"
 
   emit_insn (gen_load_quadpti (pti_reg, op1));
 
-  if (WORDS_BIG_ENDIAN)
+  if (WORDS_BIG_ENDIAN || TARGET_PREFIXED)
emit_move_insn (op0, gen_lowpart (TImode, pti_reg));
   else
{
@@ -186,14 +197,20 @@ (define_expand "atomic_load"
   DONE;
 })
 
+;; If TARGET_PREFIXED, always use pstq rather than stq.
 (define_insn "store_quadpti"
   [(set (match_operand:PTI 0 "quad_memory_operand" "=wQ")
(unspec:PTI
 [(match_operand:PTI 1 "quad_int_reg_operand" "r")] UNSPEC_LSQ))]
   "TARGET_SYNC_TI"
   "stq %1,%0"
-  [(set_attr "type" "store")])
+  [(set_attr "type" "store")
+   (set (attr "prefixed") (if_then_else (match_test "TARGET_PREFIXED")
+(const_string "yes")
+(const_string "no")))])
 
+;; Pattern store_quadpti will always use pstq if TARGET_PREFIXED,
+;; so the doubleword swap is never needed in that case.
 (define_expand "atomic_store"
   [(set (match_operand:AINT 0 "memory_operand");; memory
(match_operand:AINT 1 "register_operand"))  ;; input
@@ -232,7 +249,7 @@ (define_expand "atomic_store"
  operands[0] = op0 = replace_equiv_address (op0, new_addr);
}
 
-  if (WORDS_BIG_ENDIAN)
+  if (WORDS_BIG_ENDIAN || TARGET_PREFIXED)
emit_move_insn (pti_reg, gen_lowpart (PTImode, op1));
   else
{
-- 
2.17.1



Re: [PATCH] Fix use of singleton in optinfo framework

2020-04-21 Thread Hans-Peter Nilsson
On Tue, 21 Apr 2020, Gustavo Romero wrote:

> Hi Hans,

Hi Gus,

> On 4/14/20 12:33 AM, Hans-Peter Nilsson wrote:
> > Sadly this patch doesn't fix PR bootstrap/87252; I just checked
> > against f8e72b8d9f2:f81653ba8c1:2dd4ceacd8b (truncated from
> > LAST_UPDATED; I don't remember which field is the actual
> > commit).
>
> So, would you mind to tell me precisely how to reproduce nowadays
> that bug? Which gcc version and from which distro/OS/32 or 64-bit
> you're using to reproduce it? Given the stacktrace you share on
> PR87252 I'm not really surprise my patch didn't help.

I just added that detail; "Fedora 12", to the ticket.
Thanks for looking into it.

brgds, H-P


[patch, fortran] Fix PR 93956, wrong pointer when returned via function

2020-04-21 Thread Thomas Koenig via Gcc-patches

Hello world,

this one took a bit of detective work.  When array pointers point
to components of derived types, we currently set the span field
and then create an array temporary when we pass the array
pointer to a procedure as a non-pointer or non-target argument.
(This is inefficient, but that's for another release).

Now, the compiler detected this case when there was a direct assignment
like p => a%b, but not when p was returned either as a function result
or via an argument.  This patch fixes that.

Regression-tested. OK for trunk, gcc 9 and gcc8 (all are affected)?

Regards

Thomas

2020-04-21  Thomas Koenig  

PR fortran/93956
* expr.c (gfc_check_pointer_assign): Also set subref_array_pointer
when a function returns a pointer.
* interface.c (gfc_set_subref_array_pointer_arg): New function.
(gfc_procedure_use): Call it.

2020-04-21  Thomas Koenig  

PR fortran/93956
* gfortran.dg/pointer_assign_13.f90: New test.
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index a9fa03ad153..618c98a592d 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4242,8 +4242,11 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr 
*rvalue,
   if (rvalue->expr_type == EXPR_NULL)
 return true;
 
-  if (rvalue->expr_type == EXPR_VARIABLE && is_subref_array (rvalue))
-lvalue->symtree->n.sym->attr.subref_array_pointer = 1;
+  /* A function may also return subref arrray pointer.  */
+
+  if ((rvalue->expr_type == EXPR_VARIABLE && is_subref_array (rvalue))
+  || rvalue->expr_type == EXPR_FUNCTION)
+  lvalue->symtree->n.sym->attr.subref_array_pointer = 1;
 
   attr = gfc_expr_attr (rvalue);
 
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index ba1c8bc322e..58b7abf31e9 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -3788,6 +3788,36 @@ check_intents (gfc_formal_arglist *f, gfc_actual_arglist 
*a)
   return true;
 }
 
+/* Go through the argument list of a procedure and look for
+   pointers which may be set, possibly introducing a span.  */
+
+static void
+gfc_set_subref_array_pointer_arg (gfc_formal_arglist *dummy_args,
+ gfc_actual_arglist *actual_args)
+{
+  gfc_formal_arglist *f;
+  gfc_actual_arglist *a;
+  gfc_symbol *a_sym;
+  for (f = dummy_args, a = actual_args; f && a ; f = f->next, a = a->next)
+{
+
+  if (f->sym == NULL)
+   continue;
+
+  if (!f->sym->attr.pointer || f->sym->attr.intent == INTENT_IN)
+   continue;
+
+  if (a->expr == NULL || a->expr->expr_type != EXPR_VARIABLE)
+   continue;
+  a_sym = a->expr->symtree->n.sym;
+
+  if (!a_sym->attr.pointer)
+   continue;
+
+  a_sym->attr.subref_array_pointer = 1;
+}
+  return;
+}
 
 /* Check how a procedure is used against its interface.  If all goes
well, the actual argument list will also end up being properly
@@ -3968,6 +3998,10 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist 
**ap, locus *where)
   if (warn_aliasing)
 check_some_aliasing (dummy_args, *ap);
 
+  /* Set the subref_array_pointer_arg if needed.  */
+  if (dummy_args)
+gfc_set_subref_array_pointer_arg (dummy_args, *ap);
+
   return true;
 }
 


[PATCH] c++: Add test for c++/93807

2020-04-21 Thread Marek Polacek via Gcc-patches
This PR was initially accepts-invalid, but I think it's actually valid
C++20 code.  My reasoning is that in C++20 we no longer require the
declaration of operator== (#if-defed in the test), because C++20's
[temp.names]/2 says "A name is also considered to refer to a template
if it is an unqualified-id followed by a < and name lookup either finds
one or more functions or finds nothing." so when we're parsing

  constexpr friend bool operator==(T lhs, const Foo& rhs);

we treat "operator==" as a template name, because name lookup of
"operator==" found nothing and we have an operator-function-id, which is
an unqualified-id, and it's followed by a <.  So the declaration isn't
needed to treat "operator==" as a template-id.

Tested x86_64-pc-linux-gnu, ok for trunk?

PR c++/93807
* g++.dg/cpp2a/fn-template20.C: New test.
---
 gcc/testsuite/g++.dg/cpp2a/fn-template20.C | 34 ++
 1 file changed, 34 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/fn-template20.C

diff --git a/gcc/testsuite/g++.dg/cpp2a/fn-template20.C 
b/gcc/testsuite/g++.dg/cpp2a/fn-template20.C
new file mode 100644
index 000..c558ad1f2b6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/fn-template20.C
@@ -0,0 +1,34 @@
+// PR c++/93807
+// { dg-do compile { target c++11 } }
+
+// In C++17, we need the following declaration to treat operator== as
+// a template name.  In C++20, this is handled by [temp.names]/2.
+#if __cplusplus <= 201703L
+template 
+class Foo;
+template 
+constexpr bool operator==(T lhs, const Foo& rhs);
+#endif
+
+template 
+class Foo {
+public:
+  constexpr Foo(T k) : mK(k) {}
+
+  constexpr friend bool operator==(T lhs, const Foo& rhs);
+private:
+  T mK;
+};
+
+template 
+constexpr bool
+operator==(T lhs, const Foo& rhs)
+{
+  return lhs == rhs.mK;
+}
+
+int
+main ()
+{
+  return 1 == Foo(1) ? 0 : 1;
+}

base-commit: e76100ced607218a3bf26344fd57d7384a7c18b5
-- 
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA



[committed] libstdc++: Fix __normal_iterator comparisons for C++20

2020-04-21 Thread Jonathan Wakely via Gcc-patches
This fixes a regression introduced when I replaced __normal_iterator's
relational operators with operator<=>. If the wrapped iterator type
doesn't define operator<=> then __normal_iterator doesdn't either, which
breaks any use of fancy pointers that don't define <=>. The regression
was found when trying to build cmcstl2.

The solution is to use synth-three-way to define __normal_iterator's
spaceship operator, so that it is still defined even if the wrapped type
only supports operator<.

* include/bits/stl_iterator.h (__normal_iterator): Use synth-three-way
to define operator<=>.
* testsuite/24_iterators/normal_iterator/cmp_c++20.cc: New test.

Tested powerpc64le-linux, committed to master.


commit 87841658d4fa5174d1797ee0abc73b3b3f11cad4
Author: Jonathan Wakely 
Date:   Tue Apr 21 23:43:27 2020 +0100

libstdc++: Fix __normal_iterator comparisons for C++20

This fixes a regression introduced when I replaced __normal_iterator's
relational operators with operator<=>. If the wrapped iterator type
doesn't define operator<=> then __normal_iterator doesdn't either, which
breaks any use of fancy pointers that don't define <=>. The regression
was found when trying to build cmcstl2.

The solution is to use synth-three-way to define __normal_iterator's
spaceship operator, so that it is still defined even if the wrapped type
only supports operator<.

* include/bits/stl_iterator.h (__normal_iterator): Use 
synth-three-way
to define operator<=>.
* testsuite/24_iterators/normal_iterator/cmp_c++20.cc: New test.

diff --git a/libstdc++-v3/include/bits/stl_iterator.h 
b/libstdc++-v3/include/bits/stl_iterator.h
index 5bfdce6af2d..652f51c6e7f 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1048,12 +1048,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 { return __lhs.base() == __rhs.base(); }
 
   template
-constexpr auto
+constexpr std::__detail::__synth3way_t<_IteratorR, _IteratorL>
 operator<=>(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
-noexcept(noexcept(__lhs.base() <=> __rhs.base()))
--> decltype(__lhs.base() <=> __rhs.base())
-{ return __lhs.base() <=> __rhs.base(); }
+noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base(
+{ return std::__detail::__synth3way(__lhs.base(), __rhs.base()); }
 #else
// Forward iterator requirements
   template
diff --git a/libstdc++-v3/testsuite/24_iterators/normal_iterator/cmp_c++20.cc 
b/libstdc++-v3/testsuite/24_iterators/normal_iterator/cmp_c++20.cc
new file mode 100644
index 000..a5014e8ae99
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/normal_iterator/cmp_c++20.cc
@@ -0,0 +1,95 @@
+// Copyright (C) 2020 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
+// .
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include 
+#include 
+#include 
+
+void
+test01()
+{
+  using V = std::vector;
+  static_assert( std::totally_ordered );
+  static_assert( std::three_way_comparable );
+  using C = std::compare_three_way_result_t;
+  static_assert( std::same_as );
+
+  static_assert( std::random_access_iterator );
+  static_assert( std::random_access_iterator );
+}
+
+// User-defined pointer type that supports operator< but not operator<=>
+template
+struct Pointer : __gnu_test::PointerBase, T>
+{
+  using __gnu_test::PointerBase, T>::PointerBase;
+
+  friend bool operator<(const Pointer& lhs, const Pointer& rhs) noexcept
+  { return lhs.value < rhs.value; }
+
+  std::partial_ordering operator<=>(const Pointer&) const = delete;
+};
+
+// Minimal allocator using Pointer
+template
+struct Alloc
+{
+  typedef T value_type;
+  typedef Pointer pointer;
+
+  Alloc() = default;
+  template
+Alloc(const Alloc&) { }
+
+  pointer allocate(std::size_t n)
+  { return pointer(std::allocator().allocate(n)); }
+
+  void deallocate(pointer p, std::size_t n)
+  { std::allocator().deallocate(p.operator->(), n); }
+};
+
+void
+test02()
+{
+  using V = std::vector>;
+  static_assert( std::totally_ordered );
+  static_assert( std::three_way_comparable );
+  using C = std::compare_three_way_r

[PATCH] free() was missing from a part of the documentation

2020-04-21 Thread Zackery Spytz via Gcc-patches
Hello,

The free() function was missing from a part of the documentation!

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 81bb7a47de2..c17b1040bde 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -12315,6 +12315,7 @@ is called and the @var{flag} argument passed to it.
 @findex fprintf_unlocked
 @findex fputs
 @findex fputs_unlocked
+@findex free
 @findex frexp
 @findex frexpf
 @findex frexpl


Zackery


[PATCH v2] aarch64: Add TX3 machine model

2020-04-21 Thread Joel Jones via Gcc-patches
I just joined the gcc-patches list, so I hope the mail software can parse this 
out with an "In-Reply-To" header.

I work for Marvell, and Anton's work is approved for submittal. I wrote the 
first version of the .md file. I'm certain we have a copyright assignment.in 
place, as we've had employees in the past six months submit changes, for 
example Steve Ellcey.

Joel Jones

>Hi Anton,
>
>> -Original Message-
>> From: Gcc-patches  On Behalf Of Anton
>> Youdkevitch
>> Sent: 20 April 2020 19:29
>> To: gcc-patches@gcc.gnu.org
>> Cc: jo...@marvell.com
>> Subject: [PATCH v2] aarch64: Add TX3 machine model
>>
>> Here is the patch introducing thunderxt311 maching model
>> for the scheduler. A name for the new chip was added to the
>> list of the names to be recognized as a valid parameter for mcpu
>> and mtune flags. The TX2 cost model was reused for TX3.
>>
>> The previously used "cryptic" name for the command line
>> parameter is replaced with the same "thunderxt311" name.
>>
>> Bootstrapped on AArch64.
>
>Thanks for the patch. I had meant to ask, do you have a copyright assignment 
>in place?
>We'd need one to accept a contribution of this size.
>Thanks,
>Kyrill
>
>>
>> 2020-04-20 Anton Youdkevitch 
>>
>> * config/aarch64/aarch64-cores.def: Add the chip name.
>> * config/aarch64/aarch64-tune.md: Regenerated.
>> * gcc/config/aarch64/aarch64.c: Add the cost tables for the chip.
>> * gcc/config/aarch64/thunderx3t11.md: New file: add the new
>> machine model for the scheduler
>> * gcc/config/aarch64/aarch64.md: Include the new model.
>>
>> ---
>>  gcc/config/aarch64/aarch64-cores.def |   3 +
>>  gcc/config/aarch64/aarch64-tune.md   |   2 +-
>>  gcc/config/aarch64/aarch64.c |  27 +
>>  gcc/config/aarch64/aarch64.md|   1 +
>>  gcc/config/aarch64/thunderx3t11.md   | 686 +++
>>  5 files changed, 718 insertions(+), 1 deletion(-)



[PATCH, V5] PowerPC Turn on -mpcrel by default for -mcpu=future

2020-04-21 Thread Michael Meissner via Gcc-patches
Turn on -mpcrel by default for -mcpu=future

I reworked the patches based on your comments:

1) I removed the check for 64-bit;
2) I now set the prefixed and PC-relative bits on by default;
3) I removed the #if around the test, and provided a definition earlier;
5) I removed the #undef in linux64.h for PCREL_SUPPORTED_BY_OS.

I have also simplified the check for prefixed and PC-relative, so that the
prefix check only checks for prefixed, and the PC-relative check is separate.

I have checked against the trunk, doing bootstrap builds and make check, and
there were no regressions.  Can I check this patch into the master branch?

2020-04-21  Michael Meissner  

* config/rs6000/linux64.h (PCREL_SUPPORTED_BY_OS): Define to
enable PC-relative addressing for -mcpu=future.
* config/rs6000/rs6000-cpus.def (ISA_FUTURE_MASKS_SERVER): Move
after OTHER_FUTURE_MASKS.  Use OTHER_FUTURE_MASKS.
* config/rs6000/rs6000.c (PCREL_SUPPORTED_BY_OS): If not defined,
suppress PC-relative addressing.
(rs6000_option_override_internal): Split up error messages
checking for -mprefixed and -mpcrel.  Enable -mpcrel if the target
system supports it.

--- /tmp/ud7l8s_linux64.h   2020-04-21 16:09:26.761209165 -0400
+++ gcc/config/rs6000/linux64.h 2020-04-21 16:04:59.432652447 -0400
@@ -640,3 +640,10 @@ extern int dot_symbols;
enabling the __float128 keyword.  */
 #undef TARGET_FLOAT128_ENABLE_TYPE
 #define TARGET_FLOAT128_ENABLE_TYPE 1
+
+/* Enable using prefixed PC-relative addressing on the 'future' machine if the
+   ABI supports it.  The ELF v2 ABI only supports PC-relative relocations for
+   the medium code model.  */
+#define PCREL_SUPPORTED_BY_OS  (TARGET_FUTURE && TARGET_PREFIXED   \
+&& ELFv2_ABI_CHECK \
+&& (TARGET_CMODEL == CMODEL_MEDIUM))
--- /tmp/g2yeWR_rs6000-cpus.def 2020-04-21 16:09:26.772209188 -0400
+++ gcc/config/rs6000/rs6000-cpus.def   2020-04-21 16:04:59.433652450 -0400
@@ -75,16 +75,15 @@
 | OPTION_MASK_P8_VECTOR\
 | OPTION_MASK_P9_VECTOR)
 
-/* Support for a future processor's features.  Do not enable -mpcrel until it
-   is fully functional.  */
-#define ISA_FUTURE_MASKS_SERVER(ISA_3_0_MASKS_SERVER   
\
-| OPTION_MASK_FUTURE   \
-| OPTION_MASK_PREFIXED)
-
 /* Flags that need to be turned off if -mno-future.  */
 #define OTHER_FUTURE_MASKS (OPTION_MASK_PCREL  \
 | OPTION_MASK_PREFIXED)
 
+/* Support for a future processor's features.  */
+#define ISA_FUTURE_MASKS_SERVER(ISA_3_0_MASKS_SERVER   
\
+| OPTION_MASK_FUTURE   \
+| OTHER_FUTURE_MASKS)
+
 /* Flags that need to be turned off if -mno-power9-vector.  */
 #define OTHER_P9_VECTOR_MASKS  (OPTION_MASK_FLOAT128_HW\
 | OPTION_MASK_P9_MINMAX)
--- /tmp/KhNyMg_rs6000.c2020-04-21 16:09:26.785209215 -0400
+++ gcc/config/rs6000/rs6000.c  2020-04-21 16:09:20.579196291 -0400
@@ -98,6 +98,11 @@
 #endif
 #endif
 
+/* Don't enable PC-relative addressing if the target does not support it.  */
+#ifndef PCREL_SUPPORTED_BY_OS
+#define PCREL_SUPPORTED_BY_OS  0
+#endif
+
 /* Support targetm.vectorize.builtin_mask_for_load.  */
 tree altivec_builtin_mask_for_load;
 
@@ -4024,15 +4029,17 @@ rs6000_option_override_internal (bool gl
   rs6000_isa_flags &= ~OPTION_MASK_FLOAT128_HW;
 }
 
-  /* -mprefixed (and hence -mpcrel) requires -mcpu=future.  */
-  if (TARGET_PREFIXED && !TARGET_FUTURE)
+  /* Enable -mprefixed by default on 'future' systems.  */
+  if (TARGET_FUTURE && (rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) == 0)
+rs6000_isa_flags |= OPTION_MASK_PREFIXED;
+
+  /* -mprefixed requires -mcpu=future.  */
+  else if (TARGET_PREFIXED && !TARGET_FUTURE)
 {
-  if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0)
-   error ("%qs requires %qs", "-mpcrel", "-mcpu=future");
-  else if ((rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) != 0)
+  if ((rs6000_isa_flags_explicit & OPTION_MASK_PREFIXED) != 0)
error ("%qs requires %qs", "-mprefixed", "-mcpu=future");
 
-  rs6000_isa_flags &= ~(OPTION_MASK_PCREL | OPTION_MASK_PREFIXED);
+  rs6000_isa_flags &= ~OPTION_MASK_PREFIXED;
 }
 
   /* -mpcrel requires prefixed load/store addressing.  */
@@ -4175,9 +4182,16 @@ rs6000_option_override_internal (bool gl
   SUB3TARGET_OVERRIDE_OPTIONS;
 #endif
 
+  /* If the ABI has support for PC-relative relocations, enable it by default.
+ This test depends on the sub-target tests above setting the code model to
+ medium for ELF v2 systems.  */
+  if (PCREL_SUPPORTED_BY_OS
+  

[pushed] c++: generic lambda forwarding function [PR94546]

2020-04-21 Thread Jason Merrill via Gcc-patches
While instantiating test(Plot) we partially instantiate the generic lambda.
We look at forward(rest)... and see that it's just replacing parameter
packs with new parameter packs and tries to do a direct substitution.  But
because register_parameter_specializations had built up a
NONTYPE_ARGUMENT_PACK around the new parameter pack, the substitution
failed.  So let's not wrap it that way.

Tested x86_64-pc-linux-gnu, applying to trunk.

gcc/cp/ChangeLog
2020-04-22  Jason Merrill  

PR c++/94546
* pt.c (register_parameter_specializations): If the instantiation is
still a parameter pack, don't wrap it in a NONTYPE_ARGUMENT_PACK.
(tsubst_pack_expansion, tsubst_expr): Adjust.
---
 gcc/cp/pt.c   | 28 +++
 .../g++.dg/cpp2a/lambda-generic-variadic20.C  | 23 +++
 2 files changed, 33 insertions(+), 18 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/lambda-generic-variadic20.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6f74c278c23..a11423c7900 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12720,7 +12720,6 @@ tsubst_pack_expansion (tree t, tree args, 
tsubst_flags_t complain,
   tree pattern;
   tree pack, packs = NULL_TREE;
   bool unsubstituted_packs = false;
-  bool unsubstituted_fn_pack = false;
   int i, len = -1;
   tree result;
   bool need_local_specializations = false;
@@ -12800,19 +12799,15 @@ tsubst_pack_expansion (tree t, tree args, 
tsubst_flags_t complain,
  else
arg_pack = make_fnparm_pack (arg_pack);
}
- else if (argument_pack_element_is_expansion_p (arg_pack, 0))
-   /* This argument pack isn't fully instantiated yet.  We set this
-  flag rather than clear arg_pack because we do want to do the
-  optimization below, and we don't want to substitute directly
-  into the pattern (as that would expose a NONTYPE_ARGUMENT_PACK
-  where it isn't expected).  */
-   unsubstituted_fn_pack = true;
+ else if (DECL_PACK_P (arg_pack))
+   /* This argument pack isn't fully instantiated yet.  */
+   arg_pack = NULL_TREE;
}
   else if (is_capture_proxy (parm_pack))
{
  arg_pack = retrieve_local_specialization (parm_pack);
- if (argument_pack_element_is_expansion_p (arg_pack, 0))
-   unsubstituted_fn_pack = true;
+ if (DECL_PACK_P (arg_pack))
+   arg_pack = NULL_TREE;
}
   else
 {
@@ -12847,8 +12842,7 @@ tsubst_pack_expansion (tree t, tree args, 
tsubst_flags_t complain,
 
   if (len < 0)
len = my_len;
-  else if (len != my_len
-  && !unsubstituted_fn_pack)
+ else if (len != my_len)
 {
  if (!(complain & tf_error))
/* Fail quietly.  */;
@@ -12871,10 +12865,6 @@ tsubst_pack_expansion (tree t, tree args, 
tsubst_flags_t complain,
  /* We can't substitute for this parameter pack.  We use a flag as
 well as the missing_level counter because function parameter
 packs don't have a level.  */
-  if (!(processing_template_decl || is_auto (parm_pack)))
-   {
- gcc_unreachable ();
-   }
  gcc_assert (processing_template_decl || is_auto (parm_pack));
  unsubstituted_packs = true;
}
@@ -17864,7 +17854,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t 
complain, tree in_decl,
  {
inst = (retrieve_local_specialization
(DECL_CAPTURED_VARIABLE (decl)));
-   gcc_assert (TREE_CODE (inst) == NONTYPE_ARGUMENT_PACK);
+   gcc_assert (TREE_CODE (inst) == NONTYPE_ARGUMENT_PACK
+   || DECL_PACK_P (inst));
  }
else
  inst = lookup_init_capture_pack (decl);
@@ -25282,7 +25273,8 @@ register_parameter_specializations (tree pattern, tree 
inst)
 }
   for (; tmpl_parm; tmpl_parm = DECL_CHAIN (tmpl_parm))
 {
-  if (!DECL_PACK_P (tmpl_parm))
+  if (!DECL_PACK_P (tmpl_parm)
+ || (spec_parm && DECL_PACK_P (spec_parm)))
{
  register_local_specialization (spec_parm, tmpl_parm);
  spec_parm = DECL_CHAIN (spec_parm);
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-generic-variadic20.C 
b/gcc/testsuite/g++.dg/cpp2a/lambda-generic-variadic20.C
new file mode 100644
index 000..3d69dbb8e98
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-generic-variadic20.C
@@ -0,0 +1,23 @@
+// PR c++/94546
+// { dg-do compile { target c++2a } }
+
+template  T&& forward(T&& t) { return static_cast(t); }
+
+template 
+void test(X&& plot)
+{
+// Note: For brevity, this lambda function is only
+// defined, not called nor assigned to a variable.
+// Doing those things won't fix the error.
+[&](T&&... rest)
+{
+plot(forward(rest)...);
+};
+}
+int main()
+{
+  

[committed] libstdc++: Improve tests for __cpp_lib_erase_if macro

2020-04-21 Thread Jonathan Wakely via Gcc-patches
* testsuite/21_strings/basic_string/erasure.cc: Check for updated
value of __cpp_lib_erase_if.
* testsuite/23_containers/deque/erasure.cc: Likewise.
* testsuite/23_containers/forward_list/erasure.cc: Likewise.
* testsuite/23_containers/list/erasure.cc: Likewise.
* testsuite/23_containers/map/erasure.cc: Likewise.
* testsuite/23_containers/set/erasure.cc: Likewise.
* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
* testsuite/23_containers/vector/erasure.cc: Likewise.

Tested x86_64-linux, committed to master.

commit 0fe9eaaa083b6cc032cbd3ad1286b1dd73ccdf54
Author: Jonathan Wakely 
Date:   Wed Apr 22 07:21:01 2020 +0100

libstdc++: Improve tests for __cpp_lib_erase_if macro

* testsuite/21_strings/basic_string/erasure.cc: Check for updated
value of __cpp_lib_erase_if.
* testsuite/23_containers/deque/erasure.cc: Likewise.
* testsuite/23_containers/forward_list/erasure.cc: Likewise.
* testsuite/23_containers/list/erasure.cc: Likewise.
* testsuite/23_containers/map/erasure.cc: Likewise.
* testsuite/23_containers/set/erasure.cc: Likewise.
* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
* testsuite/23_containers/vector/erasure.cc: Likewise.

diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc 
b/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc
index 6e475cf40bc..f36562a3f19 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc
@@ -21,6 +21,12 @@
 #include 
 #include 
 
+#ifndef __cpp_lib_erase_if
+# error "Feature-test macro for erase_if missing in "
+#elif __cpp_lib_erase_if < 202002
+# error "Feature-test macro for erase_if has wrong value in "
+#endif
+
 void
 test01()
 {
diff --git a/libstdc++-v3/testsuite/23_containers/deque/erasure.cc 
b/libstdc++-v3/testsuite/23_containers/deque/erasure.cc
index 328e2fdbefa..8bd0206c890 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/erasure.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/erasure.cc
@@ -22,9 +22,9 @@
 #include 
 
 #ifndef __cpp_lib_erase_if
-# error "Feature-test macro for erase_if missing"
+# error "Feature-test macro for erase_if missing in "
 #elif __cpp_lib_erase_if < 202002
-# error "Feature-test macro for erase_if has wrong value"
+# error "Feature-test macro for erase_if has wrong value in "
 #endif
 
 void
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc 
b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
index ce321cf0c59..133dc3a699b 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
@@ -22,9 +22,9 @@
 #include 
 
 #ifndef __cpp_lib_erase_if
-# error "Feature-test macro for erase_if missing"
+# error "Feature-test macro for erase_if missing in "
 #elif __cpp_lib_erase_if < 202002
-# error "Feature-test macro for erase_if has wrong value"
+# error "Feature-test macro for erase_if has wrong value in "
 #endif
 
 void
diff --git a/libstdc++-v3/testsuite/23_containers/list/erasure.cc 
b/libstdc++-v3/testsuite/23_containers/list/erasure.cc
index 2b543d2f321..3620342ba9a 100644
--- a/libstdc++-v3/testsuite/23_containers/list/erasure.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/erasure.cc
@@ -22,9 +22,9 @@
 #include 
 
 #ifndef __cpp_lib_erase_if
-# error "Feature-test macro for erase_if missing"
+# error "Feature-test macro for erase_if missing in "
 #elif __cpp_lib_erase_if < 202002
-# error "Feature-test macro for erase_if has wrong value"
+# error "Feature-test macro for erase_if has wrong value in "
 #endif
 
 void
diff --git a/libstdc++-v3/testsuite/23_containers/map/erasure.cc 
b/libstdc++-v3/testsuite/23_containers/map/erasure.cc
index 4575e191267..1bd84813a97 100644
--- a/libstdc++-v3/testsuite/23_containers/map/erasure.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/erasure.cc
@@ -23,9 +23,9 @@
 #include 
 
 #ifndef __cpp_lib_erase_if
-# error "Feature-test macro for erase_if missing"
+# error "Feature-test macro for erase_if missing in "
 #elif __cpp_lib_erase_if < 202002
-# error "Feature-test macro for erase_if has wrong value"
+# error "Feature-test macro for erase_if has wrong value in "
 #endif
 
 auto is_odd_pair = [](const std::pair& p)
diff --git a/libstdc++-v3/testsuite/23_containers/set/erasure.cc 
b/libstdc++-v3/testsuite/23_containers/set/erasure.cc
index 48e70db814f..e5cc4a2c949 100644
--- a/libstdc++-v3/testsuite/23_containers/set/erasure.cc
+++ b/libstdc++-v3/testsuite/23_containers/set/erasure.cc
@@ -22,9 +22,9 @@
 #include 
 
 #ifndef __cpp_lib_erase_if
-# error "Feature-test macro for erase_if missing"
+# error "Feature-

[PATCH] c++: Fix misuse of "override" in -Weffc++ warnings (PR 94698)

2020-04-21 Thread Jonathan Wakely via Gcc-patches
These warnings have nothing to do with virtual functions, so "override"
is inappropriate. The warnings are just talking about defining special
members, so let's say that.

PR translation/94698
* class.c (check_field_decls): Change "override" to "define" in
-Weffc++ diagnostics.

Tested powerpc64le-linux, OK for master?

commit fefa27c3514655e84c699245e282edfa552f9f64
Author: Jonathan Wakely 
Date:   Wed Apr 22 06:54:18 2020 +0100

c++: Fix misuse of "override" in -Weffc++ warnings (PR 94698)

These warnings have nothing to do with virtual functions, so "override"
is inappropriate. The warnings are just talking about defining special
members, so let's say that.

PR translation/94698
* class.c (check_field_decls): Change "override" to "define" in
-Weffc++ diagnostics.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 41f52e5a5a0..6e14cd37aa4 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -3838,13 +3838,13 @@ check_field_decls (tree t, tree *access_decls,
  if (! TYPE_HAS_COPY_CTOR (t))
{
  warning (OPT_Weffc__,
-  "  but does not override %<%T(const %T&)%>", t, t);
+  "  but does not define %<%T(const %T&)%>", t, t);
  if (!TYPE_HAS_COPY_ASSIGN (t))
warning (OPT_Weffc__, "  or %", t);
}
  else if (! TYPE_HAS_COPY_ASSIGN (t))
warning (OPT_Weffc__,
-"  but does not override %", t);
+"  but does not define %", t);
  inform (DECL_SOURCE_LOCATION (pointer_member),
  "pointer member %q+D declared here", pointer_member);
}


Re: [PATCH] aarch64:Add an error message in large code model for ilp32 [PR94577]

2020-04-21 Thread Christophe Lyon via Gcc-patches
Hi,

After this patch, a few tests are failing when running the testsuite
with -mabi=ilp32:
gcc.target/aarch64/pr63304_1.c (test for excess errors)
gcc.target/aarch64/pr63304_1.c scan-assembler-times adrp 6
gcc.target/aarch64/pr70120-2.c (test for excess errors)
gcc.target/aarch64/pr94530.c (test for excess errors)
gcc.target/aarch64/reload-valid-spoff.c (test for excess errors)

All of them fail because of the new error message: would you mind
adjusting the tests?

Thanks

Christophe

On Tue, 21 Apr 2020 at 16:10, Richard Sandiford
 wrote:
>
> "duanbo (C)"  writes:
> > Hi
> >
> >> -Original Message-
> >> From: Richard Sandiford [mailto:richard.sandif...@arm.com]
> >> Sent: Monday, April 20, 2020 10:42 PM
> >> To: duanbo (C) 
> >> Cc: GCC Patches 
> >> Subject: Re: [PATCH] aarch64:Add an error message in large code model for
> >> ilp32 [PR94577]
> >>
> >> "duanbo (C)"  writes:
> >> > Hi
> >> >
> >> >> -Original Message-
> >> >> From: Richard Sandiford [mailto:richard.sandif...@arm.com]
> >> >> Sent: Friday, April 17, 2020 9:38 PM
> >> >> To: duanbo (C) 
> >> >> Cc: Wilco Dijkstra ; gcc-patches@gcc.gnu.org
> >> >> Subject: Re: [PATCH PR94577] [AArch64] :Add an error message in large
> >> >> code model for ilp32
> >> >>
> >> >> "duanbo (C)"  writes:
> >> >> > Thank you for your suggestions.
> >> >> > I have modified accordingly and a full test has been carried, no
> >> >> > new failure
> >> >> witnessed.
> >> >> > Attached please find the new patch which has been adjusted to be
> >> >> > suitable
> >> >> for git am.
> >> >> > Does the v2 patch look better ?
> >> >> >
> >> >> > Thanks,
> >> >> > Duan bo
> >> >> >
> >> >> > -Original Message-
> >> >> > From: Wilco Dijkstra [mailto:wilco.dijks...@arm.com]
> >> >> > Sent: Tuesday, April 14, 2020 4:40 AM
> >> >> > To: GCC Patches ; duanbo (C)
> >> >> > 
> >> >> > Subject: Re: [PATCH PR2] aarch64:Add an error message in large
> >> >> > code model for ilp32
> >> >> >
> >> >> > Hi Duanbo,
> >> >> >
> >> >> >> This is a simple fix for pr94577.
> >> >> >> The option -mabi=ilp32 should not be used in large code model.
> >> >> >> Like x86,
> >> >> using -mx32 and -mcmodel=large together will result in an error message.
> >> >> >> On aarch64, there is no error message for this option conflict.
> >> >> >> A solution to this problem can be found in the attached patch.
> >> >> >> Bootstrap and tested on aarch64 Linux platform. No new regression
> >> >> witnessed.
> >> >> >> Any suggestion?
> >> >> >
> >> >> > Thanks for your patch, more than 4GB doesn't make any sense with
> >> >> > ILP32
> >> >> indeed.
> >> >> > A few suggestions:
> >> >> >
> >> >> > It would be good to also update the documentation for
> >> >> > -mcmodel=large to
> >> >> state it is incompatible with -fpic, -fPIC and -mabi=ilp32.
> >> >> >
> >> >> > The patch adds a another switch statement on mcmodel that ignores
> >> >> > the
> >> >> previous processing done (which may changes the selected mcmodel). It
> >> >> would be safer and more concise to use one switch at the top level
> >> >> and in each case use an if statement to handle the special cases.
> >> >> >
> >> >> > A few minor nitpics:
> >> >> >
> >> >> > +   PR  target/94577
> >> >> > +   * gcc.target/aarch64/pr94577.c : New test
> >> >> >
> >> >> > Just like comments, there should be a '.' at the end of changelog 
> >> >> > entries.
> >> >> >
> >> >> > AFAICT the format isn't exactly specified, but the email header
> >> >> > should be
> >> >> like:
> >> >> >
> >> >> > [PATCH][AArch64] PR94577: Add an error message in large code model
> >> >> > for
> >> >> > ilp32
> >> >> >
> >> >> > Sometimes the PR number is also placed in brackets.
> >> >> >
> >> >> > Cheers,
> >> >> > Wilco
> >> >> >
> >> >> >
> >> >> > From feb16a5e5d35d4f632e1be10ce0ac4f4c3505d22 Mon Sep 17
> >> 00:00:00
> >> >> 2001
> >> >> > From: Duan bo 
> >> >> > Date: Wed, 15 Apr 2020 05:19:31 -0400
> >> >> > Subject: [PATCH] aarch64: Add an error message in large code model
> >> >> > for
> >> >> > ilp32  [PR94577]
> >> >> >
> >> >> > The option -mabi=ilp32 should not be used in large code model. An
> >> >> > error message is added for the option conflict.
> >> >> >
> >> >> > 2020-04-15  Duan bo  
> >> >> >
> >> >> > PR target/94577
> >> >> > * config/aarch64/aarch64.c: Add an error message for option 
> >> >> > conflict.
> >> >> > * doc/invoke.texi (-mcmodel=large): Mention that 
> >> >> > -mcmodel=large
> >> >> is
> >> >> > incompatible with -fpic, -fPIC and -mabi=ilp32.
> >> >> >
> >> >> > 2020-04-15  Duan bo  
> >> >> >
> >> >> > PR target/94577
> >> >> > * gcc.target/aarch64/pr94577.c: New test.
> >> >> > ---
> >> >> >  gcc/ChangeLog  |  7 
> >> >> >  gcc/config/aarch64/aarch64.c   | 41 
> >> >> > --
> >> >> >  gcc/doc/invoke.texi|  4 ++-
> >> >> >  gcc/testsuite/ChangeLog|