Re: [PATCH] arc: Add --with-fpu support for ARCv2 cpus

2021-06-04 Thread Jeff Law via Gcc-patches




On 6/4/2021 1:29 AM, Claudiu Zissulescu via Gcc-patches wrote:

Hi Jeff,

I would like to add spport for selecting the ARCv2 FPU extension at
configuration-time.

The --with-fpu configuration option is ignored when -mfpu compiler
option is specified.

My concern is using `grep -P` when configuring. Is that ok?

Thanks,
Claudiu

gcc/
-mm-dd  Claudiu Zissulescu  

* config.gcc (arc): Add support for with_cpu option.
* config/arc/arc.h (OPTION_DEFAULT_SPECS): Add fpu.
I strongly suspect -P is a GNU-ism and probably won't work on other 
hosts were GCC is still used.  I'd avoid it and look for an alternate 
solution.


jeff



[committed] Fix H8 split conditions

2021-06-04 Thread Jeff Law via Gcc-patches


The irony here is I had this in-flight when the discussion about 
tightening the split conditions in define_insn_and_split started.  What 
spurred it was an unexpected split with after reworking some patterns to 
allow them to be used for redundant test/compare elimination.  THat was 
ultimately tracked down to a missed condition.  The pattern's condition 
included a condition that only enabled it on the H8/S variant, but the 
splitter just had "reload_completed", so the splitter ran on all the H8 
variants generating highly unexpected results.


Committed to the trunk.

Jeff


commit 549d7f4310f6f8c2c64efcb6f3efcee99c9d9f4f
Author: Jeff Law 
Date:   Sat Jun 5 01:27:02 2021 -0400

Fix split conditions in H8/300 port

gcc/

* config/h8300/addsub.md: Fix split condition in 
define_insn_and_split
patterns.
* config/h8300/bitfield.md: Likewise.
* config/h8300/combiner.md: Likewise.
* config/h8300/divmod.md: Likewise.
* config/h8300/extensions.md: Likewise.
* config/h8300/jumpcall.md: Likewise.
* config/h8300/movepush.md: Likewise.
* config/h8300/multiply.md: Likewise.
* config/h8300/other.md: Likewise.
* config/h8300/shiftrotate.md: Likewise.
* config/h8300/logical.md: Likewise.  Fix split pattern to use
code iterator that somehow slipped through.

diff --git a/gcc/config/h8300/addsub.md b/gcc/config/h8300/addsub.md
index 3585bffa9fc..b1eb0d20188 100644
--- a/gcc/config/h8300/addsub.md
+++ b/gcc/config/h8300/addsub.md
@@ -15,7 +15,7 @@
 (match_operand:QI 2 "h8300_src_operand" "rQi")))]
   "h8300_operands_match_p (operands)"
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0) (plus:QI (match_dup 1) (match_dup 2)))
  (clobber (reg:CC CC_REG))])])
 
@@ -34,7 +34,7 @@
 (match_operand:HI 2 "h8300_src_operand" "L,N,J,n,r")))]
   "!TARGET_H8300SX"
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0) (plus:HI (match_dup 1) (match_dup 2)))
  (clobber (reg:CC CC_REG))])])
 
@@ -81,7 +81,7 @@
 (match_operand:HI 2 "h8300_src_operand" "P3>X,P3"]
   ""
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0)
   (ior:SI (and:SI (match_dup 1) (const_int -256))
   (zero_extend:SI (match_dup 2
@@ -758,7 +758,7 @@
(match_operand:SI 2 "register_operand" "0")))]
   ""
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0)
   (ior:SI (ashift:SI (match_dup 1) (const_int 31))
   (match_dup 2)))
@@ -782,7 +782,7 @@
(match_operand:SI 4 "register_operand" "0")))]
   "(INTVAL (operands[3]) & ~0x) == 0"
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0)
   (ior:SI (and:SI (ashift:SI (match_dup 1) (match_dup 2))
   (match_dup 3))
@@ -815,7 +815,7 @@
(match_operand:SI 4 "register_operand" "0")))]
   "((INTVAL (operands[3]) << INTVAL (operands[2])) & ~0x) == 0"
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0)
   (ior:SI (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
   (match_dup 3))
@@ -848,7 +848,7 @@
(match_operand:SI 3 "register_operand" "0")))]
   "INTVAL (operands[2]) < 16"
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0)
   (ior:SI (zero_extract:SI (match_dup 1)
(const_int 1)
@@ -875,7 +875,7 @@
(match_operand:SI 2 "register_operand" "0")))]
   ""
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0)
   (ior:SI (and:SI (lshiftrt:SI (match_dup 1) (const_int 30))
   (const_int 2))
@@ -902,7 +902,7 @@
(clobber (match_scratch:HI 3 "="))]
   ""
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0)
   (ior:SI (and:SI (lshiftrt:SI (match_dup 1) (const_int 9))
   (const_int 4194304))
@@ -993,7 +993,7 @@
 (const_int 1]
   ""
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0)
   (ior:SI (and:SI (match_dup 1) (const_int 1))
   (lshiftrt:SI (match_dup 1) (const_int 1
@@ -1147,7 +1147,7 @@
(const_int 8)) 1))]
   ""
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(parallel [(set (match_dup 0) (subreg:QI (lshiftrt:HI (match_dup 1)
 (const_int 8)) 1))

[Bug target/99293] Built-in vec_splat generates sub-optimal code for -mcpu=power10

2021-06-04 Thread meissner at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99293

Michael Meissner  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |meissner at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

[Bug target/99293] Built-in vec_splat generates sub-optimal code for -mcpu=power10

2021-06-04 Thread meissner at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99293

--- Comment #3 from Michael Meissner  ---
Created attachment 50947
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50947=edit
Proposed patch

[PATCH] PR 99293: Optimize splat of vec_extract for V2DI/V2DF.

2021-06-04 Thread Michael Meissner via Gcc-patches
PR 99293: Optimize splat of vec_extract for V2DI/V2DF.

We had optimizations for splat of a vector extract for the other vector
types, but we missed having one for V2DI and V2DF.  This patch adds a
combiner insn to do this optimization.

In looking at the source, we had similar optimizations for V4SI and V4SF
extract and splats, but we missed doing V2DI/V2DF.

Without the patch for the code:

vector long long splat_dup_l_0 (vector long long v)
{
  return __builtin_vec_splats (__builtin_vec_extract (v, 0));
}

the compiler generates (on a little endian power9):

splat_dup_l_0:
mfvsrld 9,34
mtvsrdd 34,9,9
blr

Now it generates:

splat_dup_l_0:
xxpermdi 34,34,34,3
blr

I have tested this on:

*   Little endian power9 running Linux using --with-code=power9
*   Big endian power8 running Linux using --with-code=power8
*   Little endian power10 running Linux using --with-code=power10

There were no regressions in the test suites (including 32-bit on big endian).
Can I check this into the master branch?

Can I check this into the open branches (GCC-11, GCC-10) after a soak-in period
if there were no errors during the soak-in period?

gcc/
2021-06-04  Michael Meissner  

PR target/99293
* config/rs6000/vsx.md (vsx_splat_extract_

PR target/99293
* gcc.target/powerpc/pr99293.c: New test.
---
 gcc/config/rs6000/vsx.md   | 18 ++
 gcc/testsuite/gcc.target/powerpc/pr99293.c | 22 ++
 2 files changed, 40 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/pr99293.c

diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index b49d5b44573..ecad45a43d1 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -5020,6 +5020,24 @@ (define_insn "vsx_splat__mem"
   "lxvdsx %x0,%y1"
   [(set_attr "type" "vecload")])
 
+;; Optimize SPLAT of an extract from a V2DF/V2DI vector with a constant element
+(define_insn "*vsx_splat_extract_"
+  [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wa")
+   (vec_duplicate:VSX_D
+(vec_select:
+ (match_operand:VSX_D 1 "vsx_register_operand" "wa")
+ (parallel [(match_operand 2 "const_0_to_1_operand" "n")]]
+  "VECTOR_MEM_VSX_P (mode)"
+{
+  int which_word = INTVAL (operands[2]);
+  if (!BYTES_BIG_ENDIAN)
+which_word = 1 - which_word;
+
+  operands[3] = GEN_INT (which_word ? 3 : 0);
+  return "xxpermdi %x0,%x1,%x1,%3";
+}
+  [(set_attr "type" "vecperm")])
+
 ;; V4SI splat support
 (define_insn "vsx_splat_v4si"
   [(set (match_operand:V4SI 0 "vsx_register_operand" "=we,we")
diff --git a/gcc/testsuite/gcc.target/powerpc/pr99293.c 
b/gcc/testsuite/gcc.target/powerpc/pr99293.c
new file mode 100644
index 000..20adc1f27f6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr99293.c
@@ -0,0 +1,22 @@
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O2 -mvsx" } */
+
+/* Test for PR 99263, which wants to do:
+   __builtin_vec_splats (__builtin_vec_extract (v, n))
+
+   where v is a V2DF or V2DI vector and n is either 0 or 1.  Previously the
+   compiler would do a direct move to the GPR registers to select the item and 
a
+   direct move from the GPR registers to do the splat.  */
+
+vector long long splat_dup_l_0 (vector long long v)
+{
+  return __builtin_vec_splats (__builtin_vec_extract (v, 0));
+}
+
+vector long long splat_dup_l_1 (vector long long v)
+{
+  return __builtin_vec_splats (__builtin_vec_extract (v, 1));
+}
+
+/* { dg-final { scan-assembler-times "xxpermdi" 2 } } */
-- 
2.31.1


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


[Bug inline-asm/100921] Inline assembly use of struct not counted as use for store elision

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100921

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|UNCONFIRMED |RESOLVED

--- Comment #1 from Andrew Pinski  ---
__asm__ __volatile__("call consumer" : : "D"());

You are just passing the address of the variable.  You either need "m"(v)
there, a simple "memory" might work too.

See PR 36639, and PR 93952.  There are others.

[Bug inline-asm/100921] New: Inline assembly use of struct not counted as use for store elision

2021-06-04 Thread ethereal at ethv dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100921

Bug ID: 100921
   Summary: Inline assembly use of struct not counted as use for
store elision
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: inline-asm
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ethereal at ethv dot net
  Target Milestone: ---

The following functions do not compile to the same result: (example is for
x86_64)

extern "C" void consumer(int *);
void example1() {
int v;
// this store will be elided as `v` is somehow never considered "read"
v = 0x12345; // some special constant
__asm__ __volatile__("call consumer" : : "D"());
// random value has now been used
}
void example2() {
int v;
// this store is _not_ elided, it's kept around
// even though the behaviour should be identical to example1
v = 0x12345;
consumer();
}

The use of `call` is not special, this appears to happen with any inline
assembly, including e.g. `mov`, `lgdt`, and `fld`. However, in both cases the
variable is "used" in the same way (taking the address of an initialized
variable), but are treated differently.

Various GCC versions tested (11.1, 9.3, 7.5, 6.4) all produce the same output.
clang outputs differently, and with the expected result for various versions
(3.3, 5.0, 12.0). Here's a godbolt link: https://godbolt.org/z/dWhx3zfse

[Bug libstdc++/100824] ranges::size should treat the subexpression as an lvalue

2021-06-04 Thread hewillk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100824

--- Comment #7 from 康桓瑋  ---
(In reply to Jonathan Wakely from comment #6)
> And LWG 3403 was fixed by r12-1228.

Hey, Jonathan, thank you for your contribution to gcc. Regarding the
implementation of LWG 3403, the return type of __int128 is unsigned. I don't
know if this is a typo.

[Bug tree-optimization/25290] PHI-OPT could be rewritten so that is uses match

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25290

Andrew Pinski  changed:

   What|Removed |Added

URL|https://gcc.gnu.org/piperma |
   |il/gcc-patches/2021-May/571 |
   |055.html|

--- Comment #19 from Andrew Pinski  ---
First patch for this was committed as r12-1152.
The second patch for this was posted at
https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571800.html .

[Bug tree-optimization/58195] Missed optimization opportunity when returning a conditional

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58195

--- Comment #6 from Andrew Pinski  ---
Note the loop based one is a little more complex due to the way GCC IR handles
overflow being wrapping or undefined; I am just going to fix the case where
overflow is defined as wrapping. The other case needs more work and maybe even
a huge change in the IR handling.

[Bug tree-optimization/100864] (a&!b) | b is not opimized to a | b for comparisons

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100864

--- Comment #4 from Andrew Pinski  ---
(In reply to Richard Biener from comment #3)
> You can possibly merge it with the
That is where I put it already, the ... was actually that part. Obviously this
was not a patch just showing what was done.

> 
> by using sth like logical_inverted_value (you want bit_inverted_value),
> 
> Also you don't need
> 
>  (for cmp (tcc_comparison)
>   (for icmp (tcc_comparison)
> 
> but just
> 
>   (for cmp (tcc_comparison)
>icmp (inverted_tcc_comparison)
>ncmp (inverted_tcc_comparison_with_nans))
> ...
>(if (ic == icmp || ic == ncmp)
> ...
> 
> right?

Does not work as there would be many of the same patterns with the above for
loop as inverted_tcc_comparison and inverted_tcc_comparison_with_nans have a
non empty intersection. The reason why it worked for the other usage of
inverted_tcc_comparison/inverted_tcc_comparison_with_nans is because it was the
resulting pattern rather than the matching pattern.

[PATCH] [libstdc++] Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]

2021-06-04 Thread Thomas Rodgers
Fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100889

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h (atomic_ref<_Tp*>::wait):
Change parameter type from _Tp to _Tp*.
* testsuite/29_atomics/atomic_ref/100889.cc: New test.
---
 libstdc++-v3/include/bits/atomic_base.h   |  2 +-
 .../testsuite/29_atomics/atomic_ref/100889.cc | 29 +++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic_ref/100889.cc

diff --git a/libstdc++-v3/include/bits/atomic_base.h 
b/libstdc++-v3/include/bits/atomic_base.h
index 029b8ad65a9..20cf1343c58 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -1870,7 +1870,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cpp_lib_atomic_wait
   _GLIBCXX_ALWAYS_INLINE void
-  wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept
+  wait(_Tp* __old, memory_order __m = memory_order_seq_cst) const noexcept
   { __atomic_impl::wait(_M_ptr, __old, __m); }
 
   // TODO add const volatile overload
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/100889.cc 
b/libstdc++-v3/testsuite/29_atomics/atomic_ref/100889.cc
new file mode 100644
index 000..1ea58cb6947
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/100889.cc
@@ -0,0 +1,29 @@
+// Copyright (C) 2019-2021 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 
+
+void
+test01()
+{
+  void* p;
+  std::atomic_ref a(p);
+  a.store(nullptr);
+}
-- 
2.26.2



Re: [PATCH 4/5 ver4] RS6000, Add test 128-bit shifts for just the int128 type.

2021-06-04 Thread Segher Boessenkool
Hi!

On Mon, Apr 26, 2021 at 09:36:26AM -0700, Carl Love wrote:
> The previous patch added the vector 128-bit integer shift instruction
> support for the V1TI type.  This patch renames and moves the VSX_TI
> iterator from vsx.md to VEC_TI in vector.md.  The uses of VEC_TI are
> also updated.

Okay for trunk.  Thanks!


Segher


Re: [PATCH 3/5 ver4] RS6000: Add TI to TD (128-bit DFP) and TD to TI support

2021-06-04 Thread Segher Boessenkool
Hi!

Maybe use "Add floattitd2 and fixtdti2" or similar as title?

On Mon, Apr 26, 2021 at 09:36:19AM -0700, Carl Love wrote:
> gcc/ChangeLog
> dje@gmail.com, gcc-patches@gcc.gnu.org, Bill Schmidt 
> , Peter Bergner ,  

What Will said here.

> 2021-04-26  Carl Love  
> * config/rs6000/dfp.md (floattitd2, fixtdti2): New define_insns.
> * config/rs6000/rs6000-call.c (P10V_BUILTIN_VCMPNET_P,
>   P10V_BUILTIN_VCMPAET_P): New overloaded definitions.

That last line is just spurious?

Okay for trunk.  Thanks!


Segher


[Bug c++/84476] [[nodiscard]] ignored on virtual functions accessed through pointer

2021-06-04 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84476

--- Comment #6 from Martin Sebor  ---
The same problem applies to attribute noreturn (but not deprecated).  Clang,
ICC, and Visual C++ behave as expected in both cases, suggesting GCC should
change.

Re: [PATCH] PR libstdc++/100889: Fix wrong param type in atomic_ref<_Tp*>::wait

2021-06-04 Thread Jonathan Wakely via Gcc-patches
On Sat, 5 Jun 2021, 00:05 Thomas Rodgers,  wrote:

> Fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100889
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/atomic_base.h (atomic_ref<_Tp*>::wait):
> Change parameter type from _Tp to _Tp*.
> * testsuite/29_atomics/atomic_ref/deduction.cc: Add
> reproducer case from PR.
>

That file is testing CTAD, there should be a better place to add this.



---
>  libstdc++-v3/include/bits/atomic_base.h   | 2 +-
>  libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/bits/atomic_base.h
> b/libstdc++-v3/include/bits/atomic_base.h
> index 029b8ad65a9..20cf1343c58 100644
> --- a/libstdc++-v3/include/bits/atomic_base.h
> +++ b/libstdc++-v3/include/bits/atomic_base.h
> @@ -1870,7 +1870,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>
>  #if __cpp_lib_atomic_wait
>_GLIBCXX_ALWAYS_INLINE void
> -  wait(_Tp __old, memory_order __m = memory_order_seq_cst) const
> noexcept
> +  wait(_Tp* __old, memory_order __m = memory_order_seq_cst) const
> noexcept
>{ __atomic_impl::wait(_M_ptr, __old, __m); }
>
>// TODO add const volatile overload
> diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc
> b/libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc
> index 86395b0c2b0..ed46b430f7c 100644
> --- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc
> +++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc
> @@ -34,6 +34,7 @@ test01()
>int* p = 
>std::atomic_ref a2(p);
>static_assert(std::is_same_v>);
> +  a2.store(nullptr);
>
>struct X { } x;
>std::atomic_ref a3(x);
> --
> 2.26.2
>
>


Re: [PATCH 2/5 ver4] RS6000: Add 128-bit Integer Operations

2021-06-04 Thread Segher Boessenkool
Hi!

On Mon, Apr 26, 2021 at 09:36:12AM -0700, Carl Love wrote:
> This patch adds the 128-bit integer support for divide, modulo, shift,
> compare of 128-bit integers instructions and builtin support.

>   (rs6000_gimple_fold_builtin) [P10V_BUILTIN_VCMPEQUT,
>   P10_BUILTIN_CMPNET, P10_BUILTIN_CMPGE_1TI,
>   P10_BUILTIN_CMPGE_U1TI, P10_BUILTIN_VCMPGTUT,
>   P10_BUILTIN_VCMPGTST, P10_BUILTIN_CMPLE_1TI,
>   P10_BUILTIN_CMPLE_U1TI]: New case statements.

>   (builtin_function_type)[P10_BUILTIN_128BIT_VMULEUD,
>   P10_BUILTIN_128BIT_VMULOUD, P10_BUILTIN_128BIT_DIVEU_V1TI,
>   P10_BUILTIN_128BIT_MODU_V1TI, P10_BUILTIN_CMPGE_U1TI,
>   P10_BUILTIN_VCMPGTUT, P10_BUILTIN_VCMPEQUT]: New case statements.

All P10_ here should be P10V_.

>   * config/rs6000/r6000.c (rs6000_handle_altivec_attribute)[E_TImode,
>   E_V1TImode]: New case statements.

Space between ) and [.

> +(define_insn "altivec_eqv1ti"
> +  [(set (match_operand:V1TI 0 "altivec_register_operand" "=v")
> + (eq:V1TI (match_operand:V1TI 1 "altivec_register_operand" "v")
> +  (match_operand:V1TI 2 "altivec_register_operand" "v")))]
> +  "TARGET_POWER10"
> +  "vcmpequq %0,%1,%2"
> +  [(set_attr "type" "veccmpfx")])

There already is

(define_insn "altivec_eq"
  [(set (match_operand:VI2 0 "altivec_register_operand" "=v")
(eq:VI2 (match_operand:VI2 1 "altivec_register_operand" "v")
(match_operand:VI2 2 "altivec_register_operand" "v")))]
  ""
  "vcmpequ %0,%1,%2"
  [(set_attr "type" "veccmpfx")])

so changing the iterator VI2 to also include V1TI (or making a new
iterator VI3 or something that includes it) will make this much easier.
(You also need the add something to VI_char; VI_unit already has it).

There are multiple iterators that can be used already.  Especially since
we have the "isa" and "enabled" attributes now :-)  So maybe we can come
up with a good logical name for it.

This can be done later.  But in the future, have an eye out if you can
just use existing patterns, it saves work :-)

The shift type things have the amount to shift by in the wrong place, so
that is a bit of a kink.


All the builtin stuff...  I didn't see mistakes, but I am so glad it
will all be rewritten soon, that is soo hard to look at :-)

> +(define_expand "vector_gtv1ti"
> +  [(set (match_operand:V1TI 0 "vlogical_operand")
> + (gt:V1TI (match_operand:V1TI 1 "vlogical_operand")
> +  (match_operand:V1TI 2 "vlogical_operand")))]
> +  "TARGET_POWER10"
> +  "")

So this will require extending VEC_C a bit if we merge patterns.

> +;; Swap upper/lower 64-bit values in a 128-bit vector
> +(define_insn "xxswapd_v1ti"
> +  [(set (match_operand:V1TI 0 "vsx_register_operand" "=v")
> + (subreg:V1TI
> +   (vec_select:V2DI
> + (subreg:V2DI
> +(match_operand:V1TI 1 "vsx_register_operand" "v") 0 )
> +  (parallel [(const_int 1)(const_int 0)]))
> +   0))]

There are spaces instead of tabs on most of these lines.


Okay for trunk with the trivialities fixed.  Also okay for GCC 11 once
it has been tested on all CPUs and OSes (all we care about that it :-) )
Thanks!


Segher


[Bug c/100920] New: bogus warn on -Wscalar-storage-order

2021-06-04 Thread george.thopas at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100920

Bug ID: 100920
   Summary: bogus warn on -Wscalar-storage-order
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: george.thopas at gmail dot com
  Target Milestone: ---

/* 
 * trying to use -Wscalar-storage-order on latest git version
 *
 * https://gcc.gnu.org/g:401bd4adcfda9965363b1ac3ba7e1580f15d6883
 *
 * below test exposes what looks like 2 wrong warnings  
 * a warning on an union where everything is big-endian 
 * a warning on type less void pointer
 *
 * gcc -Werror test.c
 *   
 * Thanks
 */
include 

struct s_1 {
int val;
} __attribute__((scalar_storage_order("big-endian")));

typedef struct s_1 t_1;

struct s_2 {
char val;
} __attribute__((scalar_storage_order("big-endian")));

typedef struct s_2 t_2;

struct s12 {
t_1 a[1];
t_2 b[1]; 
} __attribute__((scalar_storage_order("big-endian")));

typedef struct s12 t_s12;

/* Warning while everything is big-endian */
union u12 {
t_1 a[1];
t_2 b[1];
} __attribute__((scalar_storage_order("big-endian")));

typedef union u12 t_u12;

int main(void)
{
/* warning while assigning from a type less void pointer */
t_s12 *msg1 = __builtin_alloca(10);
t_u12 *msg2 = __builtin_alloca(10);
msg1->a[0].val=0;
msg2->a[0].val=0;
return 0;

[Bug c++/100919] multiple -Wdeprecated-declarations on a call to a deprecated member function pointer

2021-06-04 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100919

Martin Sebor  changed:

   What|Removed |Added

  Known to fail||10.2.0, 11.1.0, 12.0,
   ||4.9.4, 8.3.0, 9.1.0
   Keywords||diagnostic

--- Comment #1 from Martin Sebor  ---
The problem goes as far back as I can see (4.9 issues just one duplicate
warning, starting with 5.0 GCC issues three).

[PATCH] PR libstdc++/100889: Fix wrong param type in atomic_ref<_Tp*>::wait

2021-06-04 Thread Thomas Rodgers
Fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100889

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h (atomic_ref<_Tp*>::wait):
Change parameter type from _Tp to _Tp*.
* testsuite/29_atomics/atomic_ref/deduction.cc: Add
reproducer case from PR.
---
 libstdc++-v3/include/bits/atomic_base.h   | 2 +-
 libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/atomic_base.h 
b/libstdc++-v3/include/bits/atomic_base.h
index 029b8ad65a9..20cf1343c58 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -1870,7 +1870,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cpp_lib_atomic_wait
   _GLIBCXX_ALWAYS_INLINE void
-  wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept
+  wait(_Tp* __old, memory_order __m = memory_order_seq_cst) const noexcept
   { __atomic_impl::wait(_M_ptr, __old, __m); }
 
   // TODO add const volatile overload
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc 
b/libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc
index 86395b0c2b0..ed46b430f7c 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/deduction.cc
@@ -34,6 +34,7 @@ test01()
   int* p = 
   std::atomic_ref a2(p);
   static_assert(std::is_same_v>);
+  a2.store(nullptr);
 
   struct X { } x;
   std::atomic_ref a3(x);
-- 
2.26.2



[Bug c++/100919] New: multiple -Wdeprecated-declarations on a call to a deprecated member function pointer

2021-06-04 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100919

Bug ID: 100919
   Summary: multiple -Wdeprecated-declarations on a call to a
deprecated member function pointer
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The test case below shows that G++ issues three identical warnings for a single
call to function through a member pointer (both with [[deprecated]] or
__attribute__ ((deprecated))).  It should issue one one warning, same as for
direct calls.

$ cat t.C && gcc  -S -Wall t.C
struct A
{
  [[deprecated]] int f ();
  [[deprecated]] int (*pf) (); 
};

void f (A *p)
{
  p->f ();   // one warning (good)
}

void g (A *p)
{
  p->pf ();  // three warnings (bug)
}


t.C: In function ‘void f(A*)’:
t.C:9:8: warning: ‘int A::f()’ is deprecated [-Wdeprecated-declarations]
9 |   p->f ();   // one warning (good)
  |   ~^~
t.C:3:22: note: declared here
3 |   [[deprecated]] int f ();
  |  ^
t.C: In function ‘void g(A*)’:
t.C:14:6: warning: ‘A::pf’ is deprecated [-Wdeprecated-declarations]
   14 |   p->pf ();  // three warnings (bug)
  |  ^~
t.C:4:24: note: declared here
4 |   [[deprecated]] int (*pf) ();
  |^~
t.C:14:6: warning: ‘A::pf’ is deprecated [-Wdeprecated-declarations]
   14 |   p->pf ();  // three warnings (bug)
  |  ^~
t.C:4:24: note: declared here
4 |   [[deprecated]] int (*pf) ();
  |^~
t.C:14:6: warning: ‘A::pf’ is deprecated [-Wdeprecated-declarations]
   14 |   p->pf ();  // three warnings (bug)
  |  ^~
t.C:4:24: note: declared here
4 |   [[deprecated]] int (*pf) ();
  |^~

gcc-10-20210604 is now available

2021-06-04 Thread GCC Administrator via Gcc
Snapshot gcc-10-20210604 is now available on
  https://gcc.gnu.org/pub/gcc/snapshots/10-20210604/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 10 git branch
with the following options: git://gcc.gnu.org/git/gcc.git branch 
releases/gcc-10 revision dcc5cf980af747941b32fd16c1d6a07177a1a404

You'll find:

 gcc-10-20210604.tar.xz   Complete GCC

  SHA256=f51801255890135a8eacc2a2a03b0ccab05fbd13579b6dd7e5e53926eb175899
  SHA1=a716f139814a7528af638bd2a366d3bcdb408210

Diffs from 10-20210528 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-10
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.


[Bug c++/70057] duplicate integer overflow diagnostic in constant expressions

2021-06-04 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70057

Martin Sebor  changed:

   What|Removed |Added

  Known to fail|5.3.0, 6.3.0, 7.0   |10.2.0, 11.1.0, 12.0,
   ||5.5.0, 6.4.0, 7.2.0, 8.3.0,
   ||9.1.0
   Last reconfirmed|2017-02-27 00:00:00 |2021-6-4

--- Comment #4 from Martin Sebor  ---
Reconfirming with GCC 11.1.

[Bug tree-optimization/58073] Suboptimal optimisation of ((x & 0x70) == 0x00 || (x & 0x70) == 0x10 || (x & 0x70) == 0x20)

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58073

--- Comment #7 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #6)
> 
> And maybe even one like this (which will solve the issue sooner):
> 
> (bit_ior
>  (cmp (bit_and @0 INTEGER_CST@2) INTEGER_CST@3)
>  (cmp @0 INTEGER_CST@5)))

Note the final INTEGER_CST has to be 0 I think but you get the idea.

[Bug c/69972] duplicate integer overflow diagnostic in constant expressions

2021-06-04 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69972

Martin Sebor  changed:

   What|Removed |Added

   Last reconfirmed|2016-02-29 00:00:00 |2021-6-4
  Known to fail||10.2.0, 11.0, 6.3.0, 7.0.1,
   ||8.3.0, 9.3.0

--- Comment #5 from Martin Sebor  ---
Reconfirmed with GCC 11.

[PATCH] [libstdc++] Cleanup atomic timed wait implementation

2021-06-04 Thread Thomas Rodgers
This cleans up the implementation of atomic_timed_wait.h and fixes the
accidental pessimization of spinning after waiting in
__timed_waiter_pool::_M_do_wait_until.

libstdc++-v3/ChangeLog:

* include/bits/atomic_timed_wait.h (__wait_clock_t): Define
conditionally.
(__cond_wait_until_impl): Define conditionally.
(__cond_wait_until): Define conditionally. Simplify clock
type detection/conversion.
(__timed_waiter_pool::_M_do_wait_until): Move the spin above
the wait.

---
 libstdc++-v3/include/bits/atomic_timed_wait.h | 26 ++-
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/libstdc++-v3/include/bits/atomic_timed_wait.h 
b/libstdc++-v3/include/bits/atomic_timed_wait.h
index ec7ff51cdbc..19386e5806a 100644
--- a/libstdc++-v3/include/bits/atomic_timed_wait.h
+++ b/libstdc++-v3/include/bits/atomic_timed_wait.h
@@ -51,7 +51,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   namespace __detail
   {
+#ifdef _GLIBCXX_HAVE_LINUX_FUTEX || _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
 using __wait_clock_t = chrono::steady_clock;
+#else
+using __wait_clock_t = chrono::system_clock;
+#endif
 
 template
   __wait_clock_t::time_point
@@ -133,11 +137,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return false;
  }
   }
-#else
+// #elsif 
 // define _GLIBCXX_HAVE_PLATFORM_TIMED_WAIT and implement 
__platform_wait_until()
 // if there is a more efficient primitive supported by the platform
 // (e.g. __ulock_wait())which is better than pthread_cond_clockwait
-#endif // ! PLATFORM_TIMED_WAIT
+#else
+// Use wait on condition variable
 
 // Returns true if wait ended before timeout.
 // _Clock must be either steady_clock or system_clock.
@@ -173,12 +178,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __cond_wait_until(__condvar& __cv, mutex& __mx,
  const chrono::time_point<_Clock, _Dur>& __atime)
   {
-#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
-   if constexpr (is_same_v<_Clock, chrono::steady_clock>)
- return __detail::__cond_wait_until_impl(__cv, __mx, __atime);
-   else
-#endif
-   if constexpr (is_same_v<_Clock, chrono::system_clock>)
+   if constexpr (is_same_v<__wait_clock_t, _Clock>)
  return __detail::__cond_wait_until_impl(__cv, __mx, __atime);
else
  {
@@ -194,6 +194,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return false;
  }
   }
+#endif // ! PLATFORM_TIMED_WAIT
 
 struct __timed_waiter_pool : __waiter_pool_base
 {
@@ -300,17 +301,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  const chrono::time_point<_Clock, _Dur>&
  __atime) noexcept
  {
+
for (auto __now = _Clock::now(); __now < __atime;
  __now = _Clock::now())
  {
+   if (__base_type::_M_do_spin(__pred, __val,
+  __timed_backoff_spin_policy(__atime, __now)))
+ return true;
+
if (__base_type::_M_w._M_do_wait_until(
  __base_type::_M_addr, __val, __atime)
&& __pred())
  return true;
-
-   if (__base_type::_M_do_spin(__pred, __val,
-  __timed_backoff_spin_policy(__atime, __now)))
- return true;
  }
return false;
  }
-- 
2.26.2



[Bug target/100912] powerpc64le: ieee128 long double incorrectly printed when using shared libstdc++

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100912

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2021-06-04
  Component|libstdc++   |target
 Ever confirmed|0   |1
 Status|UNCONFIRMED |WAITING

--- Comment #1 from Andrew Pinski  ---
This sounds like it is still picking up the wrong libstdc++ really.

Can you disassemble (objdump -dr) ~/usr/lib64/libstdc++.so.6 to see which
vsnprintf is used there?

Also can you set LD_LIBRARY_PATH to ~/usr/lib64/ rather than using LD_PRELOAD
and see if that works.
The other thing to do use LD_DEBUG to figure out which libstdc++ is being used
really.

[Bug tree-optimization/58073] Suboptimal optimisation of ((x & 0x70) == 0x00 || (x & 0x70) == 0x10 || (x & 0x70) == 0x20) on x86_64

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58073

--- Comment #6 from Andrew Pinski  ---
#define shift 4

return ((mask(d) == (0x0 << shift)) ||
(mask(d) == (0x1 << shift)) ||
(mask(d) == (0x2 << shift)));

static inline unsigned mask(const struct dentry *dentry)
{
return dentry->d_flags & (0x7 << shift);
}



ifcombine does:
  _4 = _5 & 112; // this was already there.
  _8 = _4 == 16;
  _7 = _4 == 0;
  _9 = _7 | _8;
  _10 = _4 == 32;
  _11 = _9 | _10;

Which is correct.

reassoc1 does:

  _4 = _5 & 112;
  _8 = _4 == 16;
  _1 = _4 & 4294967279; // -17 or ~16
  _13 = _1 == 0;
  _7 = _4 == 0;
  _10 = _4 == 32;
  _11 = _10 | _13;

and that is where it messes up, it misses reassocation of all three ands
together. And _4 & 4294967279 removes bit 7 from the original and.


Final output:
  _4 = _5 & 112; // 0b111
  _1 = _5 & 96;  // 0b110
  _13 = _1 == 0; // 0b000
  _10 = _4 == 32;// 0b010
  _11 = _10 | _13;

So we need have another pattern for something like this:
(bit_ior
 (cmp (bit_and @0 INTEGER_CST@2) INTEGER_CST@3)
 (cmp (bit_and @0 INTEGER_CST@4) INTEGER_CST@5))

And maybe even one like this (which will solve the issue sooner):

(bit_ior
 (cmp (bit_and @0 INTEGER_CST@2) INTEGER_CST@3)
 (cmp @0 INTEGER_CST@5)))

Re: [PATCH] x86-64: Remove HAVE_LD_PIE_COPYRELOC

2021-06-04 Thread Fāng-ruì Sòng via Gcc-patches
PING^2 https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570139.html

On Mon, May 24, 2021 at 9:43 AM Fāng-ruì Sòng  wrote:
>
> Ping https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570139.html
>
> On Tue, May 11, 2021 at 8:29 PM Fangrui Song  wrote:
> >
> > This was introduced in 2014-12 to use local binding for external symbols
> > for -fPIE. Now that we have H.J. Lu's GOTPCRELX for years which mostly
> > nullify the benefit of HAVE_LD_PIE_COPYRELOC, HAVE_LD_PIE_COPYRELOC
> > should retire now.
> >
> > One design goal of -fPIE was to avoid copy relocations.
> > HAVE_LD_PIE_COPYRELOC has deviated from the goal.  With this change, the
> > -fPIE behavior of x86-64 will be closer to x86-32 and other targets.
> >
> > ---
> >
> > See https://gcc.gnu.org/legacy-ml/gcc/2019-05/msg00215.html for a list
> > of fixed and unfixed (e.g. gold incompatibility with protected
> > https://sourceware.org/bugzilla/show_bug.cgi?id=19823) issues.
> >
> > If you prefer a longer write-up, see
> > https://maskray.me/blog/2021-01-09-copy-relocations-canonical-plt-entries-and-protected
> > ---
> >  gcc/config.in |  6 ---
> >  gcc/config/i386/i386.c| 11 +---
> >  gcc/configure | 52 ---
> >  gcc/configure.ac  | 48 -
> >  gcc/doc/sourcebuild.texi  |  3 --
> >  .../gcc.target/i386/pie-copyrelocs-1.c| 14 -
> >  .../gcc.target/i386/pie-copyrelocs-2.c| 14 -
> >  .../gcc.target/i386/pie-copyrelocs-3.c| 14 -
> >  .../gcc.target/i386/pie-copyrelocs-4.c| 17 --
> >  gcc/testsuite/lib/target-supports.exp | 47 -
> >  10 files changed, 2 insertions(+), 224 deletions(-)
> >  delete mode 100644 gcc/testsuite/gcc.target/i386/pie-copyrelocs-1.c
> >  delete mode 100644 gcc/testsuite/gcc.target/i386/pie-copyrelocs-2.c
> >  delete mode 100644 gcc/testsuite/gcc.target/i386/pie-copyrelocs-3.c
> >  delete mode 100644 gcc/testsuite/gcc.target/i386/pie-copyrelocs-4.c
> >
> > diff --git a/gcc/config.in b/gcc/config.in
> > index e54f59ce0c3..a65bf5d4176 100644
> > --- a/gcc/config.in
> > +++ b/gcc/config.in
> > @@ -1659,12 +1659,6 @@
> >  #endif
> >
> >
> > -/* Define 0/1 if your linker supports -pie option with copy reloc. */
> > -#ifndef USED_FOR_TARGET
> > -#undef HAVE_LD_PIE_COPYRELOC
> > -#endif
> > -
> > -
> >  /* Define if your PowerPC linker has .gnu.attributes long double support. 
> > */
> >  #ifndef USED_FOR_TARGET
> >  #undef HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE
> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > index 915f89f571a..5ec3c6fd0c9 100644
> > --- a/gcc/config/i386/i386.c
> > +++ b/gcc/config/i386/i386.c
> > @@ -10579,11 +10579,7 @@ legitimate_pic_address_disp_p (rtx disp)
> > return true;
> > }
> >   else if (!SYMBOL_REF_FAR_ADDR_P (op0)
> > -  && (SYMBOL_REF_LOCAL_P (op0)
> > -  || (HAVE_LD_PIE_COPYRELOC
> > -  && flag_pie
> > -  && !SYMBOL_REF_WEAK (op0)
> > -  && !SYMBOL_REF_FUNCTION_P (op0)))
> > +  && SYMBOL_REF_LOCAL_P (op0)
> >&& ix86_cmodel != CM_LARGE_PIC)
> > return true;
> >   break;
> > @@ -22892,10 +22888,7 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree 
> > *clear, tree *update)
> >  static bool
> >  ix86_binds_local_p (const_tree exp)
> >  {
> > -  return default_binds_local_p_3 (exp, flag_shlib != 0, true, true,
> > - (!flag_pic
> > -  || (TARGET_64BIT
> > -  && HAVE_LD_PIE_COPYRELOC != 0)));
> > +  return default_binds_local_p_3 (exp, flag_shlib != 0, true, true, 
> > !flag_pic);
> >  }
> >  #endif
> >
> > diff --git a/gcc/configure b/gcc/configure
> > index f03fe888384..c500f5ca11e 100755
> > --- a/gcc/configure
> > +++ b/gcc/configure
> > @@ -29968,58 +29968,6 @@ fi
> >  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_pie" >&5
> >  $as_echo "$gcc_cv_ld_pie" >&6; }
> >
> > -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker PIE support with 
> > copy reloc" >&5
> > -$as_echo_n "checking linker PIE support with copy reloc... " >&6; }
> > -gcc_cv_ld_pie_copyreloc=no
> > -if test $gcc_cv_ld_pie = yes ; then
> > -  if test $in_tree_ld = yes ; then
> > -if test "$gcc_cv_gld_major_version" -eq 2 -a 
> > "$gcc_cv_gld_minor_version" -ge 25 -o "$gcc_cv_gld_major_version" -gt 2; 
> > then
> > -  gcc_cv_ld_pie_copyreloc=yes
> > -fi
> > -  elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
> > -# Check if linker supports -pie option with copy reloc
> > -case "$target" in
> > -i?86-*-linux* | x86_64-*-linux*)
> > -  cat > conftest1.s < > -   .globl  a_glob
> > -   .data
> > -   .type   a_glob, @object
> > -   .size  

[Bug tree-optimization/51781] Missed optimization for ==/!= comparison type-sinking

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51781

Andrew Pinski  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org

--- Comment #2 from Andrew Pinski  ---
Mine.

Psedu-match.pd code (needs expansion of some stuff but the general idea is
there)
(for (cmp ne eq)
 (cmp (convert @0) (bit_and @1 INTEGER_CST@2)
  (if (TYPE_UNSIGNED(@0) && @2 == maskforprecissionoftype(@0))
   (cmp @0 (convert:TYPE(@0) @1))

[Bug tree-optimization/68557] Missed x86 peephole optimization for multiplying by a bool

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68557

Andrew Pinski  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org

--- Comment #3 from Andrew Pinski  ---
Mine.

[Bug ipa/67014] builtin_tolower is inefficient.

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67014

Andrew Pinski  changed:

   What|Removed |Added

  Component|middle-end  |ipa
 CC||marxin at gcc dot gnu.org
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2021-06-04

--- Comment #1 from Andrew Pinski  ---
tolower is defined in the header file as:
extern __inline __attribute__ ((__gnu_inline__)) int
__attribute__ ((__nothrow__ , __leaf__)) tolower (int __c)
{
  return __c >= -128 && __c < 256 ? (*__ctype_tolower_loc ())[__c] : __c;
}


So __builtin_tolower is not using that inline function. So this is a front-end
issue where the the two function decls are not being merged into one or is an
inliner issue.

[Bug c++/100102] [9/10/11/12 Regression] ICE in tsubst, at cp/pt.c:15310

2021-06-04 Thread ed.gcc at pobox dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100102

--- Comment #21 from Eduard Rozenberg  ---
@ppalka Huge thanks for this fix - it's working well for me. Very happy to see
the patch applied with no problems to gcc 10.3.0, because it could take several
years until the OS and Nvidia support gcc 11 or 12. Otherwise I would have had
to move back to gcc 10.2.0 and build custom kernels for quite some time.

Tested as follows:
* Rebuilt Slackware gcc 10.3.0 packages with the patch for `pt.c`
* Built Nvidia nccl-tests - build succeeded (was failing before the patch)
* Built latest pytorch git with Nvidia support - build succeeded (was failing
before the patch)

[PATCH 13/13] v2 Add regression tests for PR 74765 and 74762

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch adds regression tests for two closely related bugs
resolved by the patch series.
Regression tests for TREE_NO_WARNING enhancement to warning groups.

PR middle-end/74765 - missing uninitialized warning (parenthesis, TREE_NO_WARNING abuse)
PR middle-end/74762 - [9/10/11/12 Regression] missing uninitialized warning (C++, parenthesized expr, TREE_NO_WARNING)

gcc/testsuite/ChangeLog:

	* g++.dg/uninit-pr74762.C: New test.
	* g++.dg/warn/uninit-pr74765.C: Same.

diff --git a/gcc/testsuite/g++.dg/uninit-pr74762.C b/gcc/testsuite/g++.dg/uninit-pr74762.C
new file mode 100644
index 000..ce1bc59773e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/uninit-pr74762.C
@@ -0,0 +1,24 @@
+/* PR c++/74762 - missing uninitialized warning (C++, parenthesized expr)
+   { dg-do compile }
+   { dg-options "-Wall" } */
+
+struct tree2;
+struct tree_vector2
+{
+  tree2 *elts[1];
+};
+
+struct tree2
+{
+  struct
+  {
+tree_vector2 vector;
+  } u;
+};
+
+tree2 *
+const_with_all_bytes_same (tree2 *val)
+{
+  int i;
+  return ((val->u.vector.elts[i]));   // { dg-warning "\\\[-Wuninitialized" }
+}
diff --git a/gcc/testsuite/g++.dg/warn/uninit-pr74765.C b/gcc/testsuite/g++.dg/warn/uninit-pr74765.C
new file mode 100644
index 000..1b8c124b18b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/uninit-pr74765.C
@@ -0,0 +1,24 @@
+/* PR c++/74765 - missing uninitialized warning (parenthesis,
+   TREE_NO_WARNING abuse)
+   { dg-do compile }
+   { dg-options "-Wall" } */
+
+int warn_equal_parens (int x, int y)
+{
+  int i;
+
+  if ((i == 0)) // { dg-warning "\\\[-Wuninitialized" }
+return x;
+
+  return y;
+}
+
+int warn_equal (int x, int y)
+{
+  int i;
+
+  if (i == 0)   // { dg-warning "\\\[-Wuninitialized" }
+return x;
+
+  return y;
+}


[PATCH 12/13] v2 Remove TREE_NO_WARNING and gimple*no_warning* APIs

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch removes the definitions of the TREE_NO_WARNING macro
and the gimple_get_no_warning_p() and gimple_set_no_warning() functions.
Remove legacy TREE_NO_WARNING amd gimple_*no_warning* APIs.

gcc/ChangeLog:

	* tree.h (TREE_NO_WARNING): Remove.
	* gimple.h (gimple_no_warning_p): Remove.
	(gimple_suppress_warning): Same.

diff --git a/gcc/tree.h b/gcc/tree.h
index 62b2de46479..3c92c58980e 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -699,13 +700,6 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
 /* Determines whether an ENUMERAL_TYPE has defined the list of constants. */
 #define ENUM_IS_OPAQUE(NODE) (ENUMERAL_TYPE_CHECK (NODE)->base.private_flag)
 
-/* In an expr node (usually a conversion) this means the node was made
-   implicitly and should not lead to any sort of warning.  In a decl node,
-   warnings concerning the decl should be suppressed.  This is used at
-   least for used-before-set warnings, and it set after one warning is
-   emitted.  */
-#define TREE_NO_WARNING(NODE) ((NODE)->base.nowarning_flag)
-
 /* Nonzero if we should warn about the change in empty class parameter
passing ABI in this TU.  */
 #define TRANSLATION_UNIT_WARN_EMPTY_P(NODE) \
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 91b92b4a4d1..ca5d4acfc71 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1948,22 +1969,6 @@ gimple_seq_singleton_p (gimple_seq seq)
 	  && (gimple_seq_first (seq) == gimple_seq_last (seq)));
 }
 
-/* Return true if no warnings should be emitted for statement STMT.  */
-
-static inline bool
-gimple_no_warning_p (const gimple *stmt)
-{
-  return stmt->no_warning;
-}
-
-/* Set the no_warning flag of STMT to NO_WARNING.  */
-
-static inline void
-gimple_set_no_warning (gimple *stmt, bool no_warning)
-{
-  stmt->no_warning = (unsigned) no_warning;
-}
-
 /* Set the visited status on statement STMT to VISITED_P.
 
Please note that this 'visited' property of the gimple statement is


[PATCH 11/13] v2 Use new per-location warning APIs in the Objective-C front end

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch replaces the uses of TREE_NO_WARNING in
the Objective-C front end with the new suppress_warning(),
warning_suppressed_p(), and copy_warning() APIs.
Add support for per-location warning groups.

gcc/objc/ChangeLog:

	* objc-act.c (objc_maybe_build_modify_expr): Replace direct uses
	of TREE_NO_WARNING with warning_suppressed_p, and suppress_warning.
	(objc_build_incr_expr_for_property_ref): Same.
	(objc_build_struct): Same.
	(synth_module_prologue): Same.
	* objc-gnu-runtime-abi-01.c (gnu_runtime_01_initialize): Same.
	* objc-next-runtime-abi-01.c (next_runtime_01_initialize): Same.
	* objc-next-runtime-abi-02.c (next_runtime_02_initialize): Same.

diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 8d106a4de26..ec20891152b 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -2007,7 +2007,7 @@ objc_maybe_build_modify_expr (tree lhs, tree rhs)
 	 correct (maybe a more sophisticated implementation could
 	 avoid generating the compound expression if not needed), but
 	 we need to turn it off.  */
-  TREE_NO_WARNING (compound_expr) = 1;
+  suppress_warning (compound_expr, OPT_Wunused);
   return compound_expr;
 }
   else
@@ -2129,7 +2129,7 @@ objc_build_incr_expr_for_property_ref (location_t location,
 
   /* Prevent C++ from warning with -Wall that "right operand of comma
  operator has no effect".  */
-  TREE_NO_WARNING (compound_expr) = 1;
+  suppress_warning (compound_expr, OPT_Wunused);
   return compound_expr;
 }
 
@@ -2262,8 +2262,9 @@ objc_build_struct (tree klass, tree fields, tree super_name)
   DECL_FIELD_IS_BASE (base) = 1;
 
   if (fields)
-	TREE_NO_WARNING (fields) = 1;	/* Suppress C++ ABI warnings -- we   */
-#endif	/* are following the ObjC ABI here.  */
+	/* Suppress C++ ABI warnings: we are following the ObjC ABI here.  */
+	suppress_warning (fields, OPT_Wabi);
+#endif
   DECL_CHAIN (base) = fields;
   fields = base;
 }
@@ -3112,19 +3113,19 @@ synth_module_prologue (void)
 		TYPE_DECL,
 		objc_object_name,
 		objc_object_type));
-  TREE_NO_WARNING (type) = 1;
+  suppress_warning (type);
 
   type = lang_hooks.decls.pushdecl (build_decl (input_location,
 		TYPE_DECL,
 		objc_instancetype_name,
 		objc_instancetype_type));
-  TREE_NO_WARNING (type) = 1;
+  suppress_warning (type);
 
   type = lang_hooks.decls.pushdecl (build_decl (input_location,
 		TYPE_DECL,
 		objc_class_name,
 		objc_class_type));
-  TREE_NO_WARNING (type) = 1;
+  suppress_warning (type);
 
   /* Forward-declare '@interface Protocol'.  */
   type = get_identifier (PROTOCOL_OBJECT_CLASS_NAME);
diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c
index 4add71edf41..976fa1e36cb 100644
--- a/gcc/objc/objc-gnu-runtime-abi-01.c
+++ b/gcc/objc/objc-gnu-runtime-abi-01.c
@@ -213,7 +213,7 @@ static void gnu_runtime_01_initialize (void)
 		TYPE_DECL,
 		objc_selector_name,
 		objc_selector_type));
-  TREE_NO_WARNING (type) = 1;
+  suppress_warning (type);
 
   /* typedef id (*IMP)(id, SEL, ...); */
   ftype = build_varargs_function_type_list (objc_object_type,
diff --git a/gcc/objc/objc-next-runtime-abi-01.c b/gcc/objc/objc-next-runtime-abi-01.c
index 3ec6e1703c1..183fc01abb2 100644
--- a/gcc/objc/objc-next-runtime-abi-01.c
+++ b/gcc/objc/objc-next-runtime-abi-01.c
@@ -282,7 +282,7 @@ static void next_runtime_01_initialize (void)
 		TYPE_DECL,
 		objc_selector_name,
 		objc_selector_type));
-  TREE_NO_WARNING (type) = 1;
+  suppress_warning (type);
 
   build_v1_class_template ();
   build_super_template ();
diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c
index 3cfcd0b1a57..963d1bf1ad8 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -379,7 +379,7 @@ static void next_runtime_02_initialize (void)
 		TYPE_DECL,
 		objc_selector_name,
 		objc_selector_type));
-  TREE_NO_WARNING (type) = 1;
+  suppress_warning (type);
 
   /* IMP : id (*) (id, _message_ref_t*, ...)
  SUPER_IMP : id (*) ( super_t*, _super_message_ref_t*, ...)


[PATCH 10/13] v2 Use new per-location warning APIs in the middle end

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch introduces declarations of the new
suppress_warning(), warning_suppressed_p(), and copy_warning() APIs,
and replaces the uses of TREE_NO_WARNING in the middle end with them.
Add support for per-location warning groups.

gcc/ChangeLog:

	* builtins.c (warn_string_no_nul): Replace uses of TREE_NO_WARNING,
	gimple_no_warning_p and gimple_set_no_warning with
	warning_suppressed_p, and suppress_warning.
	(c_strlen): Same.
	(maybe_warn_for_bound): Same.
	(warn_for_access): Same.
	(check_access): Same.
	(expand_builtin_strncmp): Same.
	(fold_builtin_varargs): Same.
	* calls.c (maybe_warn_nonstring_arg): Same.
	(maybe_warn_rdwr_sizes): Same.
	* cfgexpand.c (expand_call_stmt): Same.
	* cgraphunit.c (check_global_declaration): Same.
	* fold-const.c (fold_undefer_overflow_warnings): Same.
	(fold_truth_not_expr): Same.
	(fold_unary_loc): Same.
	(fold_checksum_tree): Same.
	* gengtype.c (open_base_files): Same.
	* gimple-array-bounds.cc (array_bounds_checker::check_array_ref): Same.
	(array_bounds_checker::check_mem_ref): Same.
	(array_bounds_checker::check_addr_expr): Same.
	(array_bounds_checker::check_array_bounds): Same.
	* gimple-expr.c (copy_var_decl): Same.
	* gimple-fold.c (gimple_fold_builtin_strcpy): Same.
	(gimple_fold_builtin_strncat): Same.
	(gimple_fold_builtin_stxcpy_chk): Same.
	(gimple_fold_builtin_stpcpy): Same.
	(gimple_fold_builtin_sprintf): Same.
	(fold_stmt_1): Same.
	* gimple-ssa-isolate-paths.c (diag_returned_locals): Same.
	* gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same.
	* gimple-ssa-sprintf.c (handle_printf_call): Same.
	* gimple-ssa-store-merging.c (imm_store_chain_info::output_merged_store): Same.
	* gimple-ssa-warn-restrict.c (maybe_diag_overlap): Same.
	(maybe_diag_access_bounds): Same.
	(check_call): Same.
	(check_bounds_or_overlap): Same.
	* gimple.c (gimple_build_call_from_tree): Same.
	* gimplify.c (gimplify_return_expr): Same.
	(gimplify_cond_expr): Same.
	(gimplify_modify_expr_complex_part): Same.
	(gimplify_modify_expr): Same.
	(gimple_push_cleanup): Same.
	(gimplify_expr): Same.
	* omp-expand.c (expand_omp_for_generic): Same.
	(expand_omp_taskloop_for_outer): Same.
	* omp-low.c (lower_rec_input_clauses): Same.
	(lower_lastprivate_clauses): Same.
	(lower_send_clauses): Same.
	(lower_omp_target): Same.
	* tree-cfg.c (pass_warn_function_return::execute): Same.
	* tree-complex.c (create_one_component_var): Same.
	* tree-inline.c (remap_gimple_op_r): Same.
	(copy_tree_body_r): Same.
	(declare_return_variable): Same.
	(expand_call_inline): Same.
	* tree-nested.c (lookup_field_for_decl): Same.
	* tree-sra.c (create_access_replacement): Same.
	(generate_subtree_copies): Same.
	* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Same.
	* tree-ssa-forwprop.c (combine_cond_expr_cond): Same.
	* tree-ssa-loop-ch.c (ch_base::copy_headers): Same.
	* tree-ssa-loop-im.c (execute_sm): Same.
	* tree-ssa-phiopt.c (cond_store_replacement): Same.
	* tree-ssa-strlen.c (maybe_warn_overflow): Same.
	(handle_builtin_strcpy): Same.
	(maybe_diag_stxncpy_trunc): Same.
	(handle_builtin_stxncpy_strncat): Same.
	(handle_builtin_strcat): Same.
	* tree-ssa-uninit.c (get_no_uninit_warning): Same.
	(set_no_uninit_warning): Same.
	(uninit_undefined_value_p): Same.
	(warn_uninit): Same.
	(maybe_warn_operand): Same.
	* tree-vrp.c (compare_values_warnv): Same.
	* vr-values.c (vr_values::extract_range_for_var_from_comparison_expr): Same.
	(test_for_singularity): Same.

	* gimple.h (warning_suppressed_p): New function.
	(suppress_warning): Same.
	(copy_no_warning): Same.
	(gimple_set_block): Call gimple_set_location.
	(gimple_set_location): Call copy_warning.
	* tree.h (no_warning, all_warnings): New constants.
	(warning_suppressed_p): New function.
	(suppress_warning): Same.
	(copy_no_warning): Same.

diff --git a/gcc/builtins.c b/gcc/builtins.c
index af1fe49bb48..740fed69873 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1095,7 +1095,9 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname,
 		bool exact /* = false */,
 		const wide_int bndrng[2] /* = NULL */)
 {
-  if ((expr && TREE_NO_WARNING (expr)) || TREE_NO_WARNING (arg))
+  const opt_code opt = OPT_Wstringop_overread;
+  if ((expr && warning_suppressed_p (expr, opt))
+  || warning_suppressed_p (arg, opt))
 return;
 
   loc = expansion_point_location_if_in_system_header (loc);
@@ -1123,14 +1125,14 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname,
   if (bndrng)
 	{
 	  if (wi::ltu_p (maxsiz, bndrng[0]))
-	warned = warning_at (loc, OPT_Wstringop_overread,
+	warned = warning_at (loc, opt,
  "%K%qD specified bound %s exceeds "
  "maximum object size %E",
  expr, func, bndstr, maxobjsize);
 	  else
 	{
 	  bool maybe = wi::to_wide (size) == bndrng[0];
-	  warned = warning_at (loc, OPT_Wstringop_overread,
+	  warned = warning_at (loc, opt,
    exact
    ? G_("%K%qD specified bound %s exceeds "
 	"the size %E of unterminated array")

[PATCH 9/13] v2 Use new per-location warning APIs in LTO

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch replaces the uses of TREE_NO_WARNING in the LTO
front end with the new suppress_warning() API.  It adds a couple of
FIXMEs that I plan to take care of in a follow up.
Add support for per-location warning groups.

gcc/lto/ChangeLog:

	* gimple-streamer-out.c (output_gimple_stmt): Same.
	* lto-common.c (compare_tree_sccs_1): Expand use of TREE_NO_WARNING.
	* lto-streamer-out.c (hash_tree): Same.
	* tree-streamer-in.c (unpack_ts_base_value_fields): Same.
	* tree-streamer-out.c (pack_ts_base_value_fields): Same.

diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index fcbf92300d4..7f7e06a79b8 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -73,7 +73,7 @@ output_gimple_stmt (struct output_block *ob, struct function *fn, gimple *stmt)
   /* Emit the tuple header.  */
   bp = bitpack_create (ob->main_stream);
   bp_pack_var_len_unsigned (, gimple_num_ops (stmt));
-  bp_pack_value (, gimple_no_warning_p (stmt), 1);
+  bp_pack_value (, warning_suppressed_p (stmt), 1);
   if (is_gimple_assign (stmt))
 bp_pack_value (,
 		   gimple_assign_nontemporal_move_p (
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index a26d4885800..f1809e60c1e 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -1207,7 +1207,7 @@ hash_tree (struct streamer_tree_cache_d *cache, hash_map *map,
   if (TYPE_P (t))
 hstate.add_flag (TYPE_ARTIFICIAL (t));
   else
-hstate.add_flag (TREE_NO_WARNING (t));
+hstate.add_flag (warning_suppressed_p (t));
   hstate.add_flag (TREE_NOTHROW (t));
   hstate.add_flag (TREE_STATIC (t));
   hstate.add_flag (TREE_PROTECTED (t));
diff --git a/gcc/lto/lto-common.c b/gcc/lto/lto-common.c
index bfe52a2e942..9e7ea877e66 100644
--- a/gcc/lto/lto-common.c
+++ b/gcc/lto/lto-common.c
@@ -1110,8 +1110,8 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map)
 compare_values (TYPE_UNSIGNED);
   if (TYPE_P (t1))
 compare_values (TYPE_ARTIFICIAL);
-  else
-compare_values (TREE_NO_WARNING);
+  else if (t1->base.nowarning_flag != t2->base.nowarning_flag)
+return false;
   compare_values (TREE_NOTHROW);
   compare_values (TREE_STATIC);
   if (code != TREE_BINFO)
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index e0522bf2ac1..31dbf2fb992 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -131,7 +131,8 @@ unpack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
   if (TYPE_P (expr))
 TYPE_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
   else
-TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1);
+/* FIXME: set all warning bits. */
+suppress_warning (expr, N_OPTS, (unsigned) bp_unpack_value (bp, 1));
   TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1);
   TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1);
   if (TREE_CODE (expr) != TREE_BINFO)
diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c
index 855d1cd59b9..b76e0c59c6f 100644
--- a/gcc/tree-streamer-out.c
+++ b/gcc/tree-streamer-out.c
@@ -104,7 +104,8 @@ pack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
   if (TYPE_P (expr))
 bp_pack_value (bp, TYPE_ARTIFICIAL (expr), 1);
   else
-bp_pack_value (bp, TREE_NO_WARNING (expr), 1);
+/* FIXME: pack all warning bits.  */
+bp_pack_value (bp, warning_suppressed_p (expr), 1);
   bp_pack_value (bp, TREE_NOTHROW (expr), 1);
   bp_pack_value (bp, TREE_STATIC (expr), 1);
   if (TREE_CODE (expr) != TREE_BINFO)


[PATCH 8/13] v2 Use new per-location warning APIs in libcc1

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch replaces the uses of TREE_NO_WARNING in libcc1 with
the new suppress_warning() API.
Add support for per-location warning groups.

libcc1/ChangeLog:

	* libcp1plugin.cc (record_decl_address): Replace a direct use
	of TREE_NO_WARNING with suppress_warning.

diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc
index 79694b91964..ea6ee553401 100644
--- a/libcc1/libcp1plugin.cc
+++ b/libcc1/libcp1plugin.cc
@@ -541,7 +541,7 @@ record_decl_address (plugin_context *ctx, decl_addr_value value)
   **slot = value;
   /* We don't want GCC to warn about e.g. static functions
  without a code definition.  */
-  TREE_NO_WARNING (value.decl) = 1;
+  suppress_warning (value.decl);
   return *slot;
 }
 


[PATCH 7/13] v2 Use new per-location warning APIs in the FORTRAN front end

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch replaces the uses of TREE_NO_WARNING in the FORTRAN
front end with the new suppress_warning() API.
Add support for per-location warning groups.

gcc/fortran/ChangeLog:

	* trans-array.c (trans_array_constructor): Replace direct uses
	of TREE_NO_WARNING with warning_suppressed_p, and suppress_warning.
	* trans-decl.c (gfc_build_qualified_array): Same.
	(gfc_build_dummy_array_decl): Same.
	(generate_local_decl): Same.
	(gfc_generate_function_code): Same.
	* trans-openmp.c (gfc_omp_clause_default_ctor): Same.
	(gfc_omp_clause_copy_ctor): Same.
	* trans-types.c (get_dtype_type_node): Same.
	(gfc_get_desc_dim_type): Same.
	(gfc_get_array_descriptor_base): Same.
	(gfc_get_caf_vector_type): Same.
	(gfc_get_caf_reference_type): Same.
	* trans.c (gfc_create_var_np): Same.

diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 7eeef554c0f..64a050ff196 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -2755,7 +2755,7 @@ trans_array_constructor (gfc_ss * ss, locus * where)
   desc = ss_info->data.array.descriptor;
   offset = gfc_index_zero_node;
   offsetvar = gfc_create_var_np (gfc_array_index_type, "offset");
-  TREE_NO_WARNING (offsetvar) = 1;
+  suppress_warning (offsetvar);
   TREE_USED (offsetvar) = 0;
   gfc_trans_array_constructor_value (_loop->pre, type, desc, c,
  , , dynamic);
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index c32bd05bb1b..3f7953c8400 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1040,7 +1040,7 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
   if (GFC_TYPE_ARRAY_LBOUND (type, dim) == NULL_TREE)
 	{
 	  GFC_TYPE_ARRAY_LBOUND (type, dim) = create_index_var ("lbound", nest);
-	  TREE_NO_WARNING (GFC_TYPE_ARRAY_LBOUND (type, dim)) = 1;
+	  suppress_warning (GFC_TYPE_ARRAY_LBOUND (type, dim));
 	}
   /* Don't try to use the unknown bound for assumed shape arrays.  */
   if (GFC_TYPE_ARRAY_UBOUND (type, dim) == NULL_TREE
@@ -1048,13 +1048,13 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
 	  || dim < GFC_TYPE_ARRAY_RANK (type) - 1))
 	{
 	  GFC_TYPE_ARRAY_UBOUND (type, dim) = create_index_var ("ubound", nest);
-	  TREE_NO_WARNING (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 1;
+	  suppress_warning (GFC_TYPE_ARRAY_UBOUND (type, dim));
 	}
 
   if (GFC_TYPE_ARRAY_STRIDE (type, dim) == NULL_TREE)
 	{
 	  GFC_TYPE_ARRAY_STRIDE (type, dim) = create_index_var ("stride", nest);
-	  TREE_NO_WARNING (GFC_TYPE_ARRAY_STRIDE (type, dim)) = 1;
+	  suppress_warning (GFC_TYPE_ARRAY_STRIDE (type, dim));
 	}
 }
   for (dim = GFC_TYPE_ARRAY_RANK (type);
@@ -1063,21 +1063,21 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
   if (GFC_TYPE_ARRAY_LBOUND (type, dim) == NULL_TREE)
 	{
 	  GFC_TYPE_ARRAY_LBOUND (type, dim) = create_index_var ("lbound", nest);
-	  TREE_NO_WARNING (GFC_TYPE_ARRAY_LBOUND (type, dim)) = 1;
+	  suppress_warning (GFC_TYPE_ARRAY_LBOUND (type, dim));
 	}
   /* Don't try to use the unknown ubound for the last coarray dimension.  */
   if (GFC_TYPE_ARRAY_UBOUND (type, dim) == NULL_TREE
   && dim < GFC_TYPE_ARRAY_RANK (type) + GFC_TYPE_ARRAY_CORANK (type) - 1)
 	{
 	  GFC_TYPE_ARRAY_UBOUND (type, dim) = create_index_var ("ubound", nest);
-	  TREE_NO_WARNING (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 1;
+	  suppress_warning (GFC_TYPE_ARRAY_UBOUND (type, dim));
 	}
 }
   if (GFC_TYPE_ARRAY_OFFSET (type) == NULL_TREE)
 {
   GFC_TYPE_ARRAY_OFFSET (type) = gfc_create_var_np (gfc_array_index_type,
 			"offset");
-  TREE_NO_WARNING (GFC_TYPE_ARRAY_OFFSET (type)) = 1;
+  suppress_warning (GFC_TYPE_ARRAY_OFFSET (type));
 
   if (nest)
 	gfc_add_decl_to_parent_function (GFC_TYPE_ARRAY_OFFSET (type));
@@ -1089,7 +1089,7 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
   && as->type != AS_ASSUMED_SIZE)
 {
   GFC_TYPE_ARRAY_SIZE (type) = create_index_var ("size", nest);
-  TREE_NO_WARNING (GFC_TYPE_ARRAY_SIZE (type)) = 1;
+  suppress_warning (GFC_TYPE_ARRAY_SIZE (type));
 }
 
   if (POINTER_TYPE_P (type))
@@ -1294,7 +1294,7 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy)
 
   /* Avoid uninitialized warnings for optional dummy arguments.  */
   if (sym->attr.optional)
-TREE_NO_WARNING (decl) = 1;
+suppress_warning (decl);
 
   /* We should never get deferred shape arrays here.  We used to because of
  frontend bugs.  */
@@ -5981,7 +5981,7 @@ generate_local_decl (gfc_symbol * sym)
 			 "does not have a default initializer",
 			 sym->name, >declared_at);
 	  if (sym->backend_decl != NULL_TREE)
-		TREE_NO_WARNING(sym->backend_decl) = 1;
+		suppress_warning (sym->backend_decl);
 	}
 	  else if (warn_unused_dummy_argument)
 	{
@@ -5991,7 +5991,7 @@ generate_local_decl (gfc_symbol * sym)
 			 >declared_at);
 
 	  if (sym->backend_decl != NULL_TREE)
-		TREE_NO_WARNING(sym->backend_decl) = 1;
+		suppress_warning 

[PATCH 6/13] v2 Use new per-location warning APIs in the C++ front end

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch replaces the uses of TREE_NO_WARNING in the C++
front end with the new suppress_warning(), warning_suppressed_p(),
and copy_warning() APIs.
Add support for per-location warning groups.

	* call.c (build_over_call): Replace direct uses of TREE_NO_WARNING
	with warning_suppressed_p, suppress_warning, and copy_no_warning, or
	nothing if not necessary.
	(set_up_extended_ref_temp): Same.
	* class.c (layout_class_type): Same.
	* constraint.cc (constraint_satisfaction_value): Same.
	* coroutines.cc (finish_co_await_expr): Same.
	(finish_co_yield_expr): Same.
	(finish_co_return_stmt): Same.
	(build_actor_fn): Same.
	(coro_rewrite_function_body): Same.
	(morph_fn_to_coro): Same.
	* cp-gimplify.c (genericize_eh_spec_block): Same.
	(gimplify_expr_stmt): Same.
	(cp_genericize_r): Same.
	(cp_fold): Same.
	* cp-ubsan.c (cp_ubsan_instrument_vptr): Same.
	* cvt.c (cp_fold_convert): Same.
	(convert_to_void): Same.
	* decl.c (wrapup_namespace_globals): Same.
	(grokdeclarator): Same.
	(finish_function): Same.
	(require_deduced_type): Same.
	* decl2.c (no_linkage_error): Same.
	(c_parse_final_cleanups): Same.
	* except.c (expand_end_catch_block): Same.
	* init.c (build_new_1): Same.
	(build_new): Same.
	(build_vec_delete_1): Same.
	(build_vec_init): Same.
	(build_delete): Same.
	* method.c (defaultable_fn_check): Same.
	* parser.c (cp_parser_fold_expression): Same.
	(cp_parser_primary_expression): Same.
	* pt.c (push_tinst_level_loc): Same.
	(tsubst_copy): Same.
	(tsubst_omp_udr): Same.
	(tsubst_copy_and_build): Same.
	* rtti.c (build_if_nonnull): Same.
	* semantics.c (maybe_convert_cond): Same.
	(finish_return_stmt): Same.
	(finish_parenthesized_expr): Same.
	(cp_check_omp_declare_reduction): Same.
	* tree.c (build_cplus_array_type): Same.
	* typeck.c (build_ptrmemfunc_access_expr): Same.
	(cp_build_indirect_ref_1): Same.
	(cp_build_function_call_vec): Same.
	(warn_for_null_address): Same.
	(cp_build_binary_op): Same.
	(unary_complex_lvalue): Same.
	(cp_build_modify_expr): Same.
	(build_x_modify_expr): Same.
	(convert_for_assignment): Same.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 17fc60cd4af..0afddd56496 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -9461,7 +9461,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 	{
 	  /* Avoid copying empty classes.  */
 	  val = build2 (COMPOUND_EXPR, type, arg, to);
-	  TREE_NO_WARNING (val) = 1;
+	  suppress_warning (val, OPT_Wunused);
 	}
   else if (tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (as_base)))
 	{
@@ -9492,7 +9492,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 		  build2 (MEM_REF, array_type, arg0, alias_set),
 		  build2 (MEM_REF, array_type, arg, alias_set));
 	  val = build2 (COMPOUND_EXPR, TREE_TYPE (to), t, to);
-  TREE_NO_WARNING (val) = 1;
+  suppress_warning (val, OPT_Wunused);
 	}
 
   cp_warn_deprecated_use (fn, complain);
@@ -9566,7 +9566,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 {
   tree c = extract_call_expr (call);
   if (TREE_CODE (c) == CALL_EXPR)
-	TREE_NO_WARNING (c) = 1;
+	suppress_warning (c /* Suppress all warnings.  */);
 }
   if (TREE_CODE (fn) == ADDR_EXPR)
 {
@@ -12516,11 +12516,11 @@ set_up_extended_ref_temp (tree decl, tree expr, vec **cleanups,
 TREE_ADDRESSABLE (var) = 1;
 
   if (TREE_CODE (decl) == FIELD_DECL
-  && extra_warnings && !TREE_NO_WARNING (decl))
+  && extra_warnings && !warning_suppressed_p (decl))
 {
   warning (OPT_Wextra, "a temporary bound to %qD only persists "
 	   "until the constructor exits", decl);
-  TREE_NO_WARNING (decl) = true;
+  suppress_warning (decl);
 }
 
   /* Recursively extend temps in this initializer.  */
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index b53a4dbdd4e..c89ffadcef8 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -6704,7 +6704,7 @@ layout_class_type (tree t, tree *virtuals_p)
 	 laying out an Objective-C class.  The ObjC ABI differs
 	 from the C++ ABI, and so we do not want a warning
 	 here.  */
-	  && !TREE_NO_WARNING (field)
+	  && !warning_suppressed_p (field, OPT_Wabi)
 	  && !last_field_was_bitfield
 	  && !integer_zerop (size_binop (TRUNC_MOD_EXPR,
 	 DECL_FIELD_BIT_OFFSET (field),
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 03ce8eb9ff2..ae88666e4a2 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -3281,14 +3281,14 @@ constraint_satisfaction_value (tree t, tree args, sat_info info)
   else
 r = satisfy_nondeclaration_constraints (t, args, info);
   if (r == error_mark_node && info.quiet ()
-  && !(DECL_P (t) && TREE_NO_WARNING (t)))
+  && !(DECL_P (t) && warning_suppressed_p (t)))
 {
   /* Replay the error noisily.  */
   sat_info noisy (tf_warning_or_error, info.in_decl);
   constraint_satisfaction_value (t, args, noisy);
   if (DECL_P (t) && !args)
 	/* Avoid 

[PATCH 5/13] v2 Use new per-location warning APIs in the RL78 back end

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch replaces the uses of TREE_NO_WARNING in the RL78
back end with the new suppress_warning() and warning_suppressed_p()
APIs.
Add support for per-location warning groups.

gcc/ChangeLog:

	* config/rl78/rl78.c (rl78_handle_naked_attribute): Replace a direct
	use of TREE_NO_WARNING with suppress_warning.

diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c
index 4c34949a97f..22d1690a035 100644
--- a/gcc/config/rl78/rl78.c
+++ b/gcc/config/rl78/rl78.c
@@ -847,7 +847,7 @@ rl78_handle_naked_attribute (tree * node,
   /* Disable warnings about this function - eg reaching the end without
  seeing a return statement - because the programmer is doing things
  that gcc does not know about.  */
-  TREE_NO_WARNING (* node) = 1;
+  suppress_warning (* node);
 
   return NULL_TREE;
 }


[PATCH 4/13] v2 Use new per-location warning APIs in C family code

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch replaces the uses of TREE_NO_WARNING in the shared
C family front end with the new suppress_warning(),
warning_suppressed_p(), and copy_warning() APIs.
Add support for per-location warning groups.

gcc/c-family/ChangeLog:

	* c-common.c (c_wrap_maybe_const): Remove TREE_NO_WARNING.
	(c_common_truthvalue_conversion): Replace direct uses of
	TREE_NO_WARNING with warning_suppressed_p, suppress_warning, and
	copy_no_warning.
	(check_function_arguments_recurse): Same.
	* c-gimplify.c (c_gimplify_expr): Same.
	* c-warn.c (overflow_warning): Same.
	(warn_logical_operator): Same.
	(warn_if_unused_value): Same.
	(do_warn_unused_parameter): Same.

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index c4eb2b1c920..681fcc972f4 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3375,7 +3375,6 @@ pointer_int_sum (location_t loc, enum tree_code resultcode,
 tree
 c_wrap_maybe_const (tree expr, bool non_const)
 {
-  bool nowarning = TREE_NO_WARNING (expr);
   location_t loc = EXPR_LOCATION (expr);
 
   /* This should never be called for C++.  */
@@ -3386,8 +3385,6 @@ c_wrap_maybe_const (tree expr, bool non_const)
   STRIP_TYPE_NOPS (expr);
   expr = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL, expr);
   C_MAYBE_CONST_EXPR_NON_CONST (expr) = non_const;
-  if (nowarning)
-TREE_NO_WARNING (expr) = 1;
   protected_set_expr_location (expr, loc);
 
   return expr;
@@ -3633,12 +3630,12 @@ c_common_truthvalue_conversion (location_t location, tree expr)
   break;
 
 case MODIFY_EXPR:
-  if (!TREE_NO_WARNING (expr)
+  if (!warning_suppressed_p (expr, OPT_Wparentheses)
 	  && warn_parentheses
 	  && warning_at (location, OPT_Wparentheses,
 			 "suggest parentheses around assignment used as "
 			 "truth value"))
-	TREE_NO_WARNING (expr) = 1;
+	suppress_warning (expr, OPT_Wparentheses);
   break;
 
 case CONST_DECL:
@@ -6019,7 +6016,7 @@ check_function_arguments_recurse (void (*callback)
   void *ctx, tree param,
   unsigned HOST_WIDE_INT param_num)
 {
-  if (TREE_NO_WARNING (param))
+  if (warning_suppressed_p (param))
 return;
 
   if (CONVERT_EXPR_P (param)
diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
index 39c969d8f40..0d38b706f4c 100644
--- a/gcc/c-family/c-gimplify.c
+++ b/gcc/c-family/c-gimplify.c
@@ -713,7 +713,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
 	  && !TREE_STATIC (DECL_EXPR_DECL (*expr_p))
 	  && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL (*expr_p))
 	  && !warn_init_self)
-	TREE_NO_WARNING (DECL_EXPR_DECL (*expr_p)) = 1;
+	suppress_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self);
   break;
 
 case PREINCREMENT_EXPR:
diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index a587b993fde..cfa2373585f 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -155,7 +155,7 @@ overflow_warning (location_t loc, tree value, tree expr)
 			 value);
 
   if (warned)
-TREE_NO_WARNING (value) = 1;
+suppress_warning (value, OPT_Woverflow);
 }
 
 /* Helper function for walk_tree.  Unwrap C_MAYBE_CONST_EXPRs in an expression
@@ -219,7 +219,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type,
   && INTEGRAL_TYPE_P (TREE_TYPE (op_left))
   && !CONSTANT_CLASS_P (stripped_op_left)
   && TREE_CODE (stripped_op_left) != CONST_DECL
-  && !TREE_NO_WARNING (op_left)
+  && !warning_suppressed_p (op_left, OPT_Wlogical_op)
   && TREE_CODE (op_right) == INTEGER_CST
   && !integer_zerop (op_right)
   && !integer_onep (op_right))
@@ -234,7 +234,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type,
 	  = warning_at (location, OPT_Wlogical_op,
 			"logical % applied to non-boolean constant");
   if (warned)
-	TREE_NO_WARNING (op_left) = true;
+	suppress_warning (op_left, OPT_Wlogical_op);
   return;
 }
 
@@ -588,7 +588,7 @@ bool
 warn_if_unused_value (const_tree exp, location_t locus, bool quiet)
 {
  restart:
-  if (TREE_USED (exp) || TREE_NO_WARNING (exp))
+  if (TREE_USED (exp) || warning_suppressed_p (exp, OPT_Wunused_value))
 return false;
 
   /* Don't warn about void constructs.  This includes casting to void,
@@ -2422,7 +2422,7 @@ do_warn_unused_parameter (tree fn)
decl; decl = DECL_CHAIN (decl))
 if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
 	&& DECL_NAME (decl) && !DECL_ARTIFICIAL (decl)
-	&& !TREE_NO_WARNING (decl))
+	&& !warning_suppressed_p (decl, OPT_Wunused_parameter))
   warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_parameter,
 		  "unused parameter %qD", decl);
 }


[PATCH 3/13] v2 Use new per-location warning APIs in C front end

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch replaces the uses of TREE_NO_WARNING in the C front
end with the new suppress_warning(), warning_suppressed_p(), and
copy_warning() APIs.
Add support for per-location warning groups.

gcc/c/ChangeLog:

	* c-decl.c (pop_scope): Replace direct uses of TREE_NO_WARNING with
	warning_suppressed_p, suppress_warning, and copy_no_warning.
	(diagnose_mismatched_decls): Same.
	(duplicate_decls): Same.
	(grokdeclarator): Same.
	(finish_function): Same.
	(c_write_global_declarations_1): Same.
	* c-fold.c (c_fully_fold_internal): Same.
	* c-parser.c (c_parser_expr_no_commas): Same.
	(c_parser_postfix_expression): Same.
	* c-typeck.c (array_to_pointer_conversion): Same.
	(function_to_pointer_conversion): Same.
	(default_function_array_conversion): Same.
	(convert_lvalue_to_rvalue): Same.
	(default_conversion): Same.
	(build_indirect_ref): Same.
	(build_function_call_vec): Same.
	(build_atomic_assign): Same.
	(build_unary_op): Same.
	(c_finish_return): Same.
	(emit_side_effect_warnings): Same.
	(c_finish_stmt_expr): Same.
	(c_omp_clause_copy_ctor): Same.

diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 28f851b9d0b..adfdd56d49d 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -1295,7 +1295,7 @@ pop_scope (void)
 	case VAR_DECL:
 	  /* Warnings for unused variables.  */
 	  if ((!TREE_USED (p) || !DECL_READ_P (p))
-	  && !TREE_NO_WARNING (p)
+	  && !warning_suppressed_p (p, OPT_Wunused_but_set_variable)
 	  && !DECL_IN_SYSTEM_HEADER (p)
 	  && DECL_NAME (p)
 	  && !DECL_ARTIFICIAL (p)
@@ -2159,8 +2159,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
 
   if (DECL_IN_SYSTEM_HEADER (newdecl)
 	  || DECL_IN_SYSTEM_HEADER (olddecl)
-	  || TREE_NO_WARNING (newdecl)
-	  || TREE_NO_WARNING (olddecl))
+	  || warning_suppressed_p (newdecl, OPT_Wpedantic)
+	  || warning_suppressed_p (olddecl, OPT_Wpedantic))
 	return true;  /* Allow OLDDECL to continue in use.  */
 
   if (variably_modified_type_p (newtype, NULL))
@@ -2953,7 +2953,7 @@ duplicate_decls (tree newdecl, tree olddecl)
   if (!diagnose_mismatched_decls (newdecl, olddecl, , ))
 {
   /* Avoid `unused variable' and other warnings for OLDDECL.  */
-  TREE_NO_WARNING (olddecl) = 1;
+  suppress_warning (olddecl, OPT_Wunused);
   return false;
 }
 
@@ -7540,10 +7540,7 @@ grokdeclarator (const struct c_declarator *declarator,
 			   FIELD_DECL, declarator->u.id.id, type);
 	DECL_NONADDRESSABLE_P (decl) = bitfield;
 	if (bitfield && !declarator->u.id.id)
-	  {
-	TREE_NO_WARNING (decl) = 1;
-	DECL_PADDING_P (decl) = 1;
-	  }
+	  DECL_PADDING_P (decl) = 1;
 
 	if (size_varies)
 	  C_DECL_VARIABLE_SIZE (decl) = 1;
@@ -10232,7 +10229,7 @@ finish_function (location_t end_loc)
   && targetm.warn_func_return (fndecl)
   && warning (OPT_Wreturn_type,
 		  "no return statement in function returning non-void"))
-TREE_NO_WARNING (fndecl) = 1;
+suppress_warning (fndecl, OPT_Wreturn_type);
 
   /* Complain about parameters that are only set, but never otherwise used.  */
   if (warn_unused_but_set_parameter)
@@ -10247,7 +10244,7 @@ finish_function (location_t end_loc)
 	&& !DECL_READ_P (decl)
 	&& DECL_NAME (decl)
 	&& !DECL_ARTIFICIAL (decl)
-	&& !TREE_NO_WARNING (decl))
+	&& !warning_suppressed_p (decl, OPT_Wunused_but_set_parameter))
 	  warning_at (DECL_SOURCE_LOCATION (decl),
 		  OPT_Wunused_but_set_parameter,
 		  "parameter %qD set but not used", decl);
@@ -12114,19 +12111,20 @@ c_write_global_declarations_1 (tree globals)
 	{
 	  if (C_DECL_USED (decl))
 	{
+	  /* TODO: Add OPT_Wundefined-inline.  */
 	  if (pedwarn (input_location, 0, "%q+F used but never defined",
 			   decl))
-		TREE_NO_WARNING (decl) = 1;
+		suppress_warning (decl /* OPT_Wundefined-inline.  */);
 	}
 	  /* For -Wunused-function warn about unused static prototypes.  */
 	  else if (warn_unused_function
 		   && ! DECL_ARTIFICIAL (decl)
-		   && ! TREE_NO_WARNING (decl))
+		   && ! warning_suppressed_p (decl, OPT_Wunused_function))
 	{
 	  if (warning (OPT_Wunused_function,
 			   "%q+F declared % but never defined",
 			   decl))
-		TREE_NO_WARNING (decl) = 1;
+		suppress_warning (decl, OPT_Wunused_function);
 	}
 	}
 
diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c
index 68c74cc1eb2..0ebcb469d28 100644
--- a/gcc/c/c-fold.c
+++ b/gcc/c/c-fold.c
@@ -154,7 +154,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
   tree orig_op0, orig_op1, orig_op2;
   bool op0_const = true, op1_const = true, op2_const = true;
   bool op0_const_self = true, op1_const_self = true, op2_const_self = true;
-  bool nowarning = TREE_NO_WARNING (expr);
+  bool nowarning = warning_suppressed_p (expr, OPT_Woverflow);
   bool unused_p;
   bool op0_lval = false;
   source_range old_range;
@@ -670,13 +670,13 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
  out:
   /* Some folding may introduce NON_LVALUE_EXPRs; all 

[PATCH 1/13] v2 [PATCH 1/13] Add support for per-location warning groups (PR 74765)

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch introduces the suppress_warning(),
warning_suppressed(), and copy_no_warning() APIs without making
use of them in the rest of GCC.  They are in three files:

  diagnostic-spec.{h,c}: Location-centric overloads.
  warning-control.cc: Tree- and gimple*-centric overloads.

The location-centric overloads are suitable to use from the diagnostic
subsystem.  The rest can be used from the front ends and the middle end.
Add support for per-location warning groups.

gcc/ChangeLog:

	* Makefile.in (OBJS-libcommon): Add diagnostic-spec.o.
	* gengtype.c (open_base_files): Add diagnostic-spec.h.
	* diagnostic-spec.c: New file.
	* diagnostic-spec.h: New file.
	* warning-control.cc: New file.

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 4cb2966157e..35eef812ac8 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1696,6 +1696,7 @@ OBJS = \
 	vmsdbgout.o \
 	vr-values.o \
 	vtable-verify.o \
+	warning-control.o \
 	web.o \
 	wide-int.o \
 	wide-int-print.o \
@@ -1707,8 +1708,8 @@ OBJS = \
 
 # Objects in libcommon.a, potentially used by all host binaries and with
 # no target dependencies.
-OBJS-libcommon = diagnostic.o diagnostic-color.o diagnostic-show-locus.o \
-	diagnostic-format-json.o json.o \
+OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
+	diagnostic-show-locus.o diagnostic-format-json.o json.o \
 	edit-context.o \
 	pretty-print.o intl.o \
 	sbitmap.o \
@@ -2648,6 +2649,7 @@ GTFILES = $(CPPLIB_H) $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(srcdir)/ipa-modref.h $(srcdir)/ipa-modref.c \
   $(srcdir)/ipa-modref-tree.h \
   $(srcdir)/signop.h \
+  $(srcdir)/diagnostic-spec.h $(srcdir)/diagnostic-spec.c \
   $(srcdir)/dwarf2out.h \
   $(srcdir)/dwarf2asm.c \
   $(srcdir)/dwarf2cfi.c \
diff --git a/gcc/diagnostic-spec.c b/gcc/diagnostic-spec.c
new file mode 100644
index 000..c5668831a9b
--- /dev/null
+++ b/gcc/diagnostic-spec.c
@@ -0,0 +1,177 @@
+/* Functions to enable and disable individual warnings on an expression
+   and statement basis.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   Contributed by Martin Sebor 
+
+   This file is part of GCC.
+
+   GCC 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.
+
+   GCC 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 GCC; see the file COPYING3.  If not see
+   .  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "backend.h"
+#include "bitmap.h"
+#include "tree.h"
+#include "cgraph.h"
+#include "hash-map.h"
+#include "diagnostic-spec.h"
+#include "pretty-print.h"
+#include "options.h"
+
+/* Initialize *THIS from warning option OPT.  */
+
+nowarn_spec_t::nowarn_spec_t (opt_code opt)
+{
+  /* Create a very simple mapping based on testing and experience.
+ It should become more refined with time. */
+  switch (opt)
+{
+case no_warning:
+  bits = 0;
+  break;
+
+case all_warnings:
+  bits = -1;
+  break;
+
+  /* Flow-sensitive warnings about pointer problems issued by both
+	 front ends and the middle end.  */
+case OPT_Waddress:
+case OPT_Wnonnull:
+  bits = NW_NONNULL;
+  break;
+
+  /* Flow-sensitive warnings about arithmetic overflow issued by both
+	 front ends and the middle end.  */
+case OPT_Woverflow:
+case OPT_Wshift_count_negative:
+case OPT_Wshift_count_overflow:
+case OPT_Wstrict_overflow:
+  bits = NW_VFLOW;
+  break;
+
+  /* Lexical warnings issued by front ends.  */
+case OPT_Wabi:
+case OPT_Wlogical_op:
+case OPT_Wparentheses:
+case OPT_Wreturn_type:
+case OPT_Wsizeof_array_div:
+case OPT_Wstrict_aliasing:
+case OPT_Wunused:
+case OPT_Wunused_function:
+case OPT_Wunused_but_set_variable:
+case OPT_Wunused_variable:
+case OPT_Wunused_but_set_parameter:
+  bits = NW_LEXICAL;
+  break;
+
+  /* Access warning group.  */
+case OPT_Warray_bounds:
+case OPT_Warray_bounds_:
+case OPT_Wformat_overflow_:
+case OPT_Wformat_truncation_:
+case OPT_Wrestrict:
+case OPT_Wstrict_aliasing_:
+case OPT_Wstringop_overflow_:
+case OPT_Wstringop_overread:
+case OPT_Wstringop_truncation:
+  bits = NW_ACCESS;
+  break;
+
+  /* Initialization warning group.  */
+case OPT_Winit_self:
+case OPT_Wuninitialized:
+case OPT_Wmaybe_uninitialized:
+	bits = NW_UNINIT;
+  break;
+
+default:
+  /* A catchall group for everything else.  */
+  bits = NW_OTHER;
+}
+}
+
+/* Map from location to its no-warning 

[PATCH 2/13] v2 Use new per-location warning APIs in Ada.

2021-06-04 Thread Martin Sebor via Gcc-patches

The attached patch replaces the uses of TREE_NO_WARNING in the Ada front
end with the new suppress_warning(), warning_suppressed_p(), and
copy_warning() APIs.
Add support for per-location warning groups.

gcc/ada/ChangeLog:

	* gcc-interface/trans.c (Handled_Sequence_Of_Statements_to_gnu):
	Replace TREE_NO_WARNING with suppress_warning.
	(gnat_gimplify_expr): Same.
	* gcc-interface/utils.c (gnat_pushdecl): Same.

diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index ee014a35cc2..949b7733766 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -5363,7 +5363,7 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node)
 	 because of the unstructured form of EH used by fe_sjlj_eh, there
 	 might be forward edges going to __builtin_setjmp receivers on which
 	 it is uninitialized, although they will never be actually taken.  */
-  TREE_NO_WARNING (gnu_jmpsave_decl) = 1;
+  suppress_warning (gnu_jmpsave_decl, OPT_Wuninitialized);
   gnu_jmpbuf_decl
 	= create_var_decl (get_identifier ("JMP_BUF"), NULL_TREE,
 			   jmpbuf_type,
@@ -8805,7 +8805,7 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
   else
 	{
 	  *expr_p = create_tmp_var (type, NULL);
-	  TREE_NO_WARNING (*expr_p) = 1;
+	  suppress_warning (*expr_p);
 	}
 
   gimplify_and_add (TREE_OPERAND (expr, 0), pre_p);
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 1786fbf8186..982274c6d77 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -836,7 +836,8 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
   if (!deferred_decl_context)
 DECL_CONTEXT (decl) = context;
 
-  TREE_NO_WARNING (decl) = (No (gnat_node) || Warnings_Off (gnat_node));
+  suppress_warning (decl, all_warnings,
+		No (gnat_node) || Warnings_Off (gnat_node));
 
   /* Set the location of DECL and emit a declaration for it.  */
   if (Present (gnat_node) && !renaming_from_instantiation_p (gnat_node))


[Bug tree-optimization/65412] sequence of ifs not turned into a switch statement

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65412

--- Comment #4 from Andrew Pinski  ---
clang decides at 4 to change it to a switch statement while GCC takes a few
extra ifs to change it.  Again this is heuristics at work.


#define B(y) void f##y(void);
#define B10(y)  B(y##0)  B(y##1)  B(y##2) \
B(y##3)  B(y##4)  B(y##5) \
B(y##6)  B(y##7)  B(y##8) \
B(y##9)

B10(1)

#define A(y) else if (x == y) f##y();

void f10(int x)
{
  if (0) ;
  A(11)
  A(12)
  A(13)
  A(14)
}

[Bug tree-optimization/65412] sequence of ifs not turned into a switch statement

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65412

Andrew Pinski  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |10.0
   Last reconfirmed|2015-12-28 00:00:00 |2021-6-4

--- Comment #3 from Andrew Pinski  ---
>From *.iftoswitch on the trunk:
;;  Canonical GIMPLE case clusters: 0 1 2 3 4 5


So I looked and this is fixed but not for the low if count.
Take:
#define B(y) void f##y(void);
#define B10(y)  B(y##0)  B(y##1)  B(y##2) \
B(y##3)  B(y##4)  B(y##5) \
B(y##6)  B(y##7)  B(y##8) \
B(y##9)
#define B100(y)  B10(y##0)  B10(y##1)  B10(y##2) \
 B10(y##3)  B10(y##4)  B10(y##5) \
 B10(y##6)  B10(y##7)  B10(y##8) \
 B10(y##9)

B10(1)
B100(1)

#define A(y) else if (x == y) f##y();
#define A10(y)  A(y##0) \
A(y##1) \
A(y##2) \
A(y##3) \
A(y##4) \
A(y##5) \
A(y##6) \
A(y##7) \
A(y##8) \
A(y##9)

#define A100(y) A10(y##0)  \
A10(y##1) \
A10(y##2) \
A10(y##3) \
A10(y##4) \
A10(y##5) \
A10(y##6) \
A10(y##7) \
A10(y##8) \
A10(y##9)

void f10(int x)
{
  if (0) ;
  A10(1)
}
void f100(int x)
{
  if (0) ;
  A100(1)
}

--- CUT 
f100 is converted while f10 is not.  This is a heuristics at work to see if it
is better as a jump table vs if statements.

https://godbolt.org/z/ofWGb5aKn for reference.

Clang decides (I don't know if they lower switches back to if statements) to do
the switch for all cases.

So we can close this as fixed.

[PATCH 0/13] v2 warning control by group and location (PR 74765)

2021-06-04 Thread Martin Sebor via Gcc-patches

This is a revised patch series to add warning control by group and
location, updated based on feedback on the initial series.

v2 changes include:

1) Use opt_code rather than int for the option argument to the new
   APIs.  This let me find and fix a bug in the original Ada change.
2) Use suppress_warning() and warning_suppressed_p() instead of
   get/set_no_warning, and also instead of warning_enabled/disabled
   for the names of the new functions (as requested/clarified offline
   by David).
3) Make the removal of the TREE_NO_WARNING macro and
   the gimple_get_no_warning_p() and gimple_set_no_warning()
   functions a standalone patch.
4) Include tests for PR 74765 and 74762 fixed by these changes.

I have retested the whole patch series on x86_64-linux.


[Bug fortran/95502] ICE in gfc_check_do_variable, at fortran/parse.c:4446

2021-06-04 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95502

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||anlauf at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |anlauf at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #3 from anlauf at gcc dot gnu.org ---
Patch: https://gcc.gnu.org/pipermail/fortran/2021-June/056133.html

[Bug c++/100918] [9/10/11/12 Regression] Naming a destructor as a qualified template-id results in bogus access error

2021-06-04 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100918

Patrick Palka  changed:

   What|Removed |Added

  Known to work||8.5.0
  Known to fail||10.3.0, 11.1.0, 9.4.0
   Target Milestone|--- |9.5
Summary|Naming a destructor as a|[9/10/11/12 Regression]
   |qualified template-id   |Naming a destructor as a
   |results in bogus access |qualified template-id
   |error   |results in bogus access
   ||error

[PATCH] PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446

2021-06-04 Thread Harald Anlauf via Gcc-patches
ICE-on-invalid issues during error recovery.  Testcase by Gerhard,
initial patch by Steve.  I found another variant which needed an
additional fix for a NULL pointer dereference.

Regtested on x86_64-pc-linux-gnu.

OK for mainline / 11-branch?

Thanks,
Harald


Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446

Avoid NULL pointer dereferences during error recovery.

gcc/fortran/ChangeLog:

PR fortran/95502
* expr.c (gfc_check_pointer_assign): Avoid NULL pointer
dereference.
* match.c (gfc_match_pointer_assignment): Likewise.
* parse.c (gfc_check_do_variable): Avoid comparison with NULL
symtree.

gcc/testsuite/ChangeLog:

PR fortran/95502
* gfortran.dg/pr95502.f90: New test.

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 956003ec605..b11ae7ce5c5 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3815,6 +3815,9 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
   int proc_pointer;
   bool same_rank;

+  if (!lvalue->symtree)
+return false;
+
   lhs_attr = gfc_expr_attr (lvalue);
   if (lvalue->ts.type == BT_UNKNOWN && !lhs_attr.proc_pointer)
 {
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 29462013038..d148de3e3b5 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -1409,7 +1409,7 @@ gfc_match_pointer_assignment (void)
   gfc_matching_procptr_assignment = 0;

   m = gfc_match (" %v =>", );
-  if (m != MATCH_YES)
+  if (m != MATCH_YES || !lvalue->symtree)
 {
   m = MATCH_NO;
   goto cleanup;
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 0522b391393..6d7845e8517 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -4588,6 +4588,9 @@ gfc_check_do_variable (gfc_symtree *st)
 {
   gfc_state_data *s;

+  if (!st)
+return 0;
+
   for (s=gfc_state_stack; s; s = s->previous)
 if (s->do_variable == st)
   {
diff --git a/gcc/testsuite/gfortran.dg/pr95502.f90 b/gcc/testsuite/gfortran.dg/pr95502.f90
new file mode 100644
index 000..d40fd9a5508
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95502.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446
+
+program p
+  integer, pointer :: z
+  nullify (z%kind)  ! { dg-error "in variable definition context" }
+  z%kind => NULL()  ! { dg-error "constant expression" }
+end


[PATCH] c++: access of dtor named by qualified template-id [PR100918]

2021-06-04 Thread Patrick Palka via Gcc-patches
Here, when resolving the destructor named by Inner::~Inner
(which is valid only before C++20) we end up in cp_parser_lookup_name to
look up the name Inner relative to the scope Inner.  The lookup
naturally finds the injected-class-name Inner, and because
is_template is true, we adjust this lookup result to the TEMPLATE_DECL
Inner, and then check access of this adjusted lookup result.  But this
access check fails because the scope is Inner and not Outer, and
the context_for_name_lookup of the TEMPLATE_DECL is Outer.

The simplest fix seems to be to perform the access check on the original
lookup result (the injected-class-name) instead of the TEMPLATE_DECL.
So this patch moves the access check in cp_parser_lookup_name to before
the injected-class-name adjustment.

Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
trunk?

PR c++/100918

gcc/cp/ChangeLog:

* parser.c (cp_parser_lookup_name): Check access of the lookup
result before we potentially adjust an injected-class-name to
its TEMPLATE_DECL.

gcc/testsuite/ChangeLog:

* g++.dg/template/access38.C: New test.
---
 gcc/cp/parser.c  | 24 +---
 gcc/testsuite/g++.dg/template/access38.C | 15 +++
 2 files changed, 28 insertions(+), 11 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/template/access38.C

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4a46828e162..829a94b2928 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -29505,6 +29505,19 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
   if (!decl || decl == error_mark_node)
 return error_mark_node;
 
+  /* If we have resolved the name of a member declaration, check to
+ see if the declaration is accessible.  When the name resolves to
+ set of overloaded functions, accessibility is checked when
+ overload resolution is done.  If we have a TREE_LIST, then the lookup
+ is either ambiguous or it found multiple injected-class-names, the
+ accessibility of which is trivially satisfied.
+
+ During an explicit instantiation, access is not checked at all,
+ as per [temp.explicit].  */
+  if (DECL_P (decl))
+check_accessibility_of_qualified_id (decl, object_type, parser->scope,
+tf_warning_or_error);
+
   /* Pull out the template from an injected-class-name (or multiple).  */
   if (is_template)
 decl = maybe_get_template_decl_from_type_decl (decl);
@@ -29531,17 +29544,6 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
  || TREE_CODE (decl) == UNBOUND_CLASS_TEMPLATE
  || BASELINK_P (decl));
 
-  /* If we have resolved the name of a member declaration, check to
- see if the declaration is accessible.  When the name resolves to
- set of overloaded functions, accessibility is checked when
- overload resolution is done.
-
- During an explicit instantiation, access is not checked at all,
- as per [temp.explicit].  */
-  if (DECL_P (decl))
-check_accessibility_of_qualified_id (decl, object_type, parser->scope,
-tf_warning_or_error);
-
   maybe_record_typedef_use (decl);
 
   return cp_expr (decl, name_location);
diff --git a/gcc/testsuite/g++.dg/template/access38.C 
b/gcc/testsuite/g++.dg/template/access38.C
new file mode 100644
index 000..488f8650c97
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/access38.C
@@ -0,0 +1,15 @@
+// PR c++/100918
+
+struct Outer {
+  template
+  struct Inner { ~Inner(); };
+};
+
+template<>
+Outer::Inner::~Inner() { } // { dg-error "template-id" "" { target 
c++20 } }
+
+template
+Outer::Inner::~Inner() { } // { dg-error "template-id" "" { target c++20 
} }
+
+Outer::Inner x;
+Outer::Inner y;
-- 
2.32.0.rc2



[Bug libstdc++/100824] ranges::size should treat the subexpression as an lvalue

2021-06-04 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100824

--- Comment #6 from Jonathan Wakely  ---
And LWG 3403 was fixed by r12-1228.

I plan to backport these three patches too.

Thanks for all the bug reports like this!

Re: [committed] libstdc++: Fix value categories used by ranges access CPOs [PR 100824]

2021-06-04 Thread Jonathan Wakely via Gcc-patches

On 04/06/21 21:44 +0100, Jonathan Wakely wrote:

On 04/06/21 18:03 +0100, Jonathan Wakely wrote:

The implementation of P2091R0 was incomplete, so that some range access
CPOs used perfect forwarding where they should not. This fixes it by
consistently operating on lvalues.

Some additional changes that are not necessary to fix the bug:

Modify the __as_const helper to simplify its usage. Instead of deducing
the value category from its argument, and requiring callers to forward
the argument as the correct category, add a non-deduced template
parameter which is used for the value category and accept the argument
as an lvalue. This means callers say __as_const(t) instead of
__as_const(std::forward(t)).

Always use an lvalue reference type as the template argument for the
_S_noexcept helpers, so that we only instantiate one specialization for
lvalues and rvalues of the same type.

Move some helper concepts and functions from namespace std::__detail
to ranges::__cust_access, to be consistent with the ranges::begin CPO.
This ensures that the __adl_begin concept and the _Begin::operator()
function are in the same namespace, so unqualified lookup is consistent
and the poison pills for begin are visible to both.

Simplified static assertions for arrays, because the expression a+0 is
already ill-formed for an array of incomplete type.

Signed-off-by: Jonathan Wakely 

libstdc++-v3/ChangeLog:

PR libstdc++/100824
* include/bits/iterator_concepts.h (__detail::__decay_copy)
(__detail::__member_begin, __detail::__adl_begin): Move to
namespace ranges::__cust_access.
(__detail::__ranges_begin): Likewise, and rename to __begin.
Remove redundant static assertion.
* include/bits/ranges_base.h (_Begin, _End, _RBegin, _REnd):
Use lvalue in noexcept specifier.
(__as_const): Add non-deduced parameter for value category.
(_CBegin, _CEnd, _CRBegin, _CREnd, _CData): Adjust uses of
__as_const.
(__member_size, __adl_size, __member_empty, __size0_empty):
(__eq_iter_empty, __adl_data): Use lvalue objects in
requirements.
(__sentinel_size): Likewise. Add check for conversion to
unsigned-like.
(__member_data): Allow non-lvalue types to satisfy the concept,
but use lvalue object in requirements.
(_Size, _SSize): Remove forwarding to always use an lvalue.
(_Data): Likewise. Add static assertion for arrays.
* testsuite/std/ranges/access/cdata.cc: Adjust expected
behaviour for rvalues. Add negative tests for ill-formed
expressions.
* testsuite/std/ranges/access/data.cc: Likewise.
* testsuite/std/ranges/access/empty.cc: Adjust expected
behaviour for rvalues.
* testsuite/std/ranges/access/size.cc: Likewise.


An additional problem with ranges::data was pointed out in the PR,
fixed with this patch.


And this implements the rest of LWG 3403. The change to the
ranges::ssize constraints was already done by the first patch in this
thread, this fixes the return type.

Tested powerpc64le-linux. Committed to trunk.

This should also be backported to gcc-11 and gcc-10.


commit 621ea10ca060ba19ec693aa73b5e29d553cca849
Author: Jonathan Wakely 
Date:   Fri Jun 4 20:28:04 2021

libstdc++: Implement LWG 3403 for std::ranges::ssize

I already changed the constraints for ranges::ssize to use ranges::size,
this implements the rest of LWG 3403, so that the returned type is the
signed type corresponding to the result of ranges::size.

Signed-off-by: Jonathan Wakely 

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (_SSize): Return the result of
ranges::size converted to the wider of make-signed-like-t and
ptrdiff_t, rather than the ranges different type.
* testsuite/std/ranges/access/ssize.cc: Adjust expected result
for an iota_view that uses an integer class type for its
difference_type.

diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h
index 61d91eb8389..e3c3962bcd9 100644
--- a/libstdc++-v3/include/bits/ranges_base.h
+++ b/libstdc++-v3/include/bits/ranges_base.h
@@ -425,22 +425,32 @@ namespace ranges
 
 struct _SSize
 {
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 3403. Domain of ranges::ssize(E) doesn't match ranges::size(E)
   template
 	requires requires (_Tp& __t) { _Size{}(__t); }
 	constexpr auto
 	operator()(_Tp&& __t) const noexcept(noexcept(_Size{}(__t)))
 	{
-	  using __iter_type = decltype(_Begin{}(__t));
-	  using __diff_type = iter_difference_t<__iter_type>;
-	  using __gnu_cxx::__int_traits;
 	  auto __size = _Size{}(__t);
-	  if constexpr (integral<__diff_type>)
+	  using __size_type = decltype(__size);
+	  // Return the wider of ptrdiff_t and make-signed-like-t<__size_type>.
+	  if constexpr (integral<__size_type>)
 	{
-	  if constexpr 

Re: [committed] libstdc++: Fix value categories used by ranges access CPOs [PR 100824]

2021-06-04 Thread Jonathan Wakely via Gcc-patches

On 04/06/21 18:03 +0100, Jonathan Wakely wrote:

The implementation of P2091R0 was incomplete, so that some range access
CPOs used perfect forwarding where they should not. This fixes it by
consistently operating on lvalues.

Some additional changes that are not necessary to fix the bug:

Modify the __as_const helper to simplify its usage. Instead of deducing
the value category from its argument, and requiring callers to forward
the argument as the correct category, add a non-deduced template
parameter which is used for the value category and accept the argument
as an lvalue. This means callers say __as_const(t) instead of
__as_const(std::forward(t)).

Always use an lvalue reference type as the template argument for the
_S_noexcept helpers, so that we only instantiate one specialization for
lvalues and rvalues of the same type.

Move some helper concepts and functions from namespace std::__detail
to ranges::__cust_access, to be consistent with the ranges::begin CPO.
This ensures that the __adl_begin concept and the _Begin::operator()
function are in the same namespace, so unqualified lookup is consistent
and the poison pills for begin are visible to both.

Simplified static assertions for arrays, because the expression a+0 is
already ill-formed for an array of incomplete type.

Signed-off-by: Jonathan Wakely 

libstdc++-v3/ChangeLog:

PR libstdc++/100824
* include/bits/iterator_concepts.h (__detail::__decay_copy)
(__detail::__member_begin, __detail::__adl_begin): Move to
namespace ranges::__cust_access.
(__detail::__ranges_begin): Likewise, and rename to __begin.
Remove redundant static assertion.
* include/bits/ranges_base.h (_Begin, _End, _RBegin, _REnd):
Use lvalue in noexcept specifier.
(__as_const): Add non-deduced parameter for value category.
(_CBegin, _CEnd, _CRBegin, _CREnd, _CData): Adjust uses of
__as_const.
(__member_size, __adl_size, __member_empty, __size0_empty):
(__eq_iter_empty, __adl_data): Use lvalue objects in
requirements.
(__sentinel_size): Likewise. Add check for conversion to
unsigned-like.
(__member_data): Allow non-lvalue types to satisfy the concept,
but use lvalue object in requirements.
(_Size, _SSize): Remove forwarding to always use an lvalue.
(_Data): Likewise. Add static assertion for arrays.
* testsuite/std/ranges/access/cdata.cc: Adjust expected
behaviour for rvalues. Add negative tests for ill-formed
expressions.
* testsuite/std/ranges/access/data.cc: Likewise.
* testsuite/std/ranges/access/empty.cc: Adjust expected
behaviour for rvalues.
* testsuite/std/ranges/access/size.cc: Likewise.


An additional problem with ranges::data was pointed out in the PR,
fixed with this patch.

Tested powerpc64le-linux. Committed to trunk.

This should also be backported to gcc-11 and gcc-10.


commit 3e5f2425f80aedd00f28235022a2755eb46f310d
Author: Jonathan Wakely 
Date:   Fri Jun 4 20:25:39 2021

libstdc++: Fix helper concept for ranges::data [PR 100824]

We need to decay the result of t.data() before checking if it's a
pointer.

Signed-off-by: Jonathan Wakely 

libstdc++-v3/ChangeLog:

PR libstdc++/100824
* include/bits/ranges_base.h (__member_data): Use __decay_copy.
* testsuite/std/ranges/access/data.cc: Add testcase from PR.

diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h
index 17a421a4927..61d91eb8389 100644
--- a/libstdc++-v3/include/bits/ranges_base.h
+++ b/libstdc++-v3/include/bits/ranges_base.h
@@ -495,8 +495,10 @@ namespace ranges
 && is_object_v>;
 
 template
-  concept __member_data
-	= requires(_Tp& __t) { { __t.data() } -> __pointer_to_object; };
+  concept __member_data = requires(_Tp& __t)
+	{
+	  { __cust_access::__decay_copy(__t.data()) } -> __pointer_to_object;
+	};
 
 template
   concept __begin_data = requires(_Tp& __t)
diff --git a/libstdc++-v3/testsuite/std/ranges/access/data.cc b/libstdc++-v3/testsuite/std/ranges/access/data.cc
index 237bbcc76c5..4f16f447f9f 100644
--- a/libstdc++-v3/testsuite/std/ranges/access/data.cc
+++ b/libstdc++-v3/testsuite/std/ranges/access/data.cc
@@ -92,8 +92,12 @@ test03()
   // ranges::data should treat the subexpression as an lvalue
   VERIFY( std::ranges::data(std::move(r)) == ::i );
   VERIFY( std::ranges::data(std::move(c)) == ::l );
-}
 
+  // PR libstdc++/100824 comment 3
+  // Check for member data() should use decay-copy
+  struct A { int*&& data(); };
+  static_assert( has_data );
+}
 
 int
 main()


[Bug libstdc++/100824] ranges::size should treat the subexpression as an lvalue

2021-06-04 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100824

--- Comment #5 from CVS Commits  ---
The master branch has been updated by Jonathan Wakely :

https://gcc.gnu.org/g:3e5f2425f80aedd00f28235022a2755eb46f310d

commit r12-1227-g3e5f2425f80aedd00f28235022a2755eb46f310d
Author: Jonathan Wakely 
Date:   Fri Jun 4 20:25:39 2021 +0100

libstdc++: Fix helper concept for ranges::data [PR 100824]

We need to decay the result of t.data() before checking if it's a
pointer.

Signed-off-by: Jonathan Wakely 

libstdc++-v3/ChangeLog:

PR libstdc++/100824
* include/bits/ranges_base.h (__member_data): Use __decay_copy.
* testsuite/std/ranges/access/data.cc: Add testcase from PR.

Re: [PATCH] PR libstdc++/98842: Fixed Constraints on operator<=>(optional, U)

2021-06-04 Thread Jonathan Wakely via Gcc-patches
On Thu, 3 Jun 2021 at 17:27, Seija K. via Libstdc++ 
wrote:

> The original operator was underconstrained. _Up needs to fulfill
> compare_three_way_result,
> as mentioned in this bug report
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98842
>

Thanks, I'll get the patch applied next week.



> diff --git a/libstdc++-v3/include/std/optional
> b/libstdc++-v3/include/std/optional
> index 8b9e038e6e510..9e61c1b2cbfbd 100644
> --- a/libstdc++-v3/include/std/optional
> +++ b/libstdc++-v3/include/std/optional
> @@ -1234,7 +1234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>  { return !__rhs || __lhs >= *__rhs; }
>
>  #ifdef __cpp_lib_three_way_comparison
> -  template
> +  template _Up>
>  constexpr compare_three_way_result_t<_Tp, _Up>
>  operator<=>(const optional<_Tp>& __x, const _Up& __v)
>  { return bool(__x) ? *__x <=> __v : strong_ordering::less; }
>
>


[Bug c++/100918] Naming a destructor as a qualified template-id results in bogus access error

2021-06-04 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100918

Patrick Palka  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |ppalka at gcc dot 
gnu.org
 Ever confirmed|0   |1
   Last reconfirmed||2021-06-04
 Status|UNCONFIRMED |ASSIGNED

Re: [PATCH] [libstdc++] Remove unused hasher instance.

2021-06-04 Thread Jonathan Wakely via Gcc-patches
On Fri, 4 Jun 2021 at 20:54, Thomas Rodgers wrote:

> This is a remnant of poorly executed refactoring.
>

OK for trunk and gcc-11, thanks.



> libstdc++-v3/ChangeLog:
>
> * include/std/barrier (__tree_barrier::_M_arrive): Remove
> unnecessary hasher instantiation.
> ---
>  libstdc++-v3/include/std/barrier | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/std/barrier
> b/libstdc++-v3/include/std/barrier
> index fd61fb4f9da..4210e30d1ce 100644
> --- a/libstdc++-v3/include/std/barrier
> +++ b/libstdc++-v3/include/std/barrier
> @@ -103,7 +103,6 @@ It looks different from literature pseudocode for two
> main reasons:
>static_cast<__barrier_phase_t>(__old_phase_val
> + 2);
>
> size_t __current_expected = _M_expected;
> -   std::hash __hasher;
> __current %= ((_M_expected + 1) >> 1);
>
> for (int __round = 0; ; ++__round)
> --
> 2.26.2
>
>


[Bug c++/100918] Naming a destructor as a qualified template-id results in bogus access error

2021-06-04 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100918

--- Comment #1 from Patrick Palka  ---
We began rejecting this starting with r9-4879.


If we replace the explicit specialization of Inner::~Inner with a generic
definition

struct Outer {
public:
template 
struct Inner { ~Inner(); };
};

template 
Outer::Inner::~Inner() {}

Outer::Inner x;

then we started to reject this version after r11-1350.

[Bug middle-end/100905] [OpenMP] ICE in convert_nonlocal_omp_clauses, at tree-nested.c:1514 with 'omp loop' in Fortran internal procedure

2021-06-04 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100905

Tobias Burnus  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|UNCONFIRMED |RESOLVED

--- Comment #3 from Tobias Burnus  ---
FIXED.

[Bug c++/100918] New: Naming a destructor as a qualified template-id results in bogus access error

2021-06-04 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100918

Bug ID: 100918
   Summary: Naming a destructor as a qualified template-id results
in bogus access error
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

The following testcase:

struct Outer {
template
struct Inner { ~Inner(); };
};

template<>
Outer::Inner::~Inner() {}

is rejected with

: In destructor ‘Outer::Inner::~Inner() [with T = int]’:
:7:21: error: ‘template struct Outer::Inner’ is inaccessible
within this context
:3:12: note: declared here

Re: [PATCH 2/5 ver4] RS6000: Add 128-bit Integer Operations

2021-06-04 Thread Segher Boessenkool
On Tue, Apr 27, 2021 at 06:46:16PM -0500, will schmidt wrote:
> On Mon, 2021-04-26 at 09:36 -0700, Carl Love wrote:
> > (rs6000_gimple_fold_builtin) [P10V_BUILTIN_VCMPEQUT,
> > P10_BUILTIN_CMPNET, P10_BUILTIN_CMPGE_1TI,
> > P10_BUILTIN_CMPGE_U1TI, P10_BUILTIN_VCMPGTUT,
> > P10_BUILTIN_VCMPGTST, P10_BUILTIN_CMPLE_1TI,
> > P10_BUILTIN_CMPLE_U1TI]: New case statements.
> 
> No signs of P10_BUILTIN_CMPNET below.  possibly P10V_BUILTIN_CMPNET?  
> S
> ame through at least P10_BUILTIN_CMPLE_U1TI.

It is P10V_BUILTIN_CMPNET (note the V).


Segher


[Bug c++/100809] PPC: __int128 divide/modulo does not use P10 instructions vdivsq/vdivuq

2021-06-04 Thread meissner at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100809

Michael Meissner  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |meissner at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #5 from Michael Meissner  ---
Patch submitted:
https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571942.html

[Bug testsuite/100168] Test gcc.dg/pr56727-2.c fails on power10 code generation

2021-06-04 Thread meissner at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100168

Michael Meissner  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |meissner at gcc dot 
gnu.org
   Last reconfirmed||2021-06-04

--- Comment #1 from Michael Meissner  ---
This is has been submitted with the patch:
https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570688.html

[Bug fortran/100917] Bind(c): errors handling long double real

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100917

--- Comment #1 from José Rui Faustino de Sousa  ---
Created attachment 50946
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50946=edit
C code for bind(c)

[Bug fortran/100917] New: Bind(c): errors handling long double real

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100917

Bug ID: 100917
   Summary: Bind(c): errors handling long double real
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jrfsousa at gcc dot gnu.org
  Target Milestone: ---

Created attachment 50945
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50945=edit
Fortran code showing problem

Hi All!

Wrong type and kind on handling long double real. Since kind is not related to
elem_len there seems to be no way to infer it.

Seen on:

GNU Fortran (GCC) 10.3.1 20210526
GNU Fortran (GCC) 11.1.1 20210526
GNU Fortran (GCC) 12.0.0 20210529 (experimental)

Thank you very much.

Best regards,
José Rui

[PATCH] [libstdc++] Remove unused hasher instance.

2021-06-04 Thread Thomas Rodgers
This is a remnant of poorly executed refactoring.

libstdc++-v3/ChangeLog:

* include/std/barrier (__tree_barrier::_M_arrive): Remove
unnecessary hasher instantiation.
---
 libstdc++-v3/include/std/barrier | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libstdc++-v3/include/std/barrier b/libstdc++-v3/include/std/barrier
index fd61fb4f9da..4210e30d1ce 100644
--- a/libstdc++-v3/include/std/barrier
+++ b/libstdc++-v3/include/std/barrier
@@ -103,7 +103,6 @@ It looks different from literature pseudocode for two main 
reasons:
   static_cast<__barrier_phase_t>(__old_phase_val + 2);
 
size_t __current_expected = _M_expected;
-   std::hash __hasher;
__current %= ((_M_expected + 1) >> 1);
 
for (int __round = 0; ; ++__round)
-- 
2.26.2



[Bug fortran/100916] Bind(c): CFI_type_other unimplemented.

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100916

--- Comment #1 from José Rui Faustino de Sousa  ---
Created attachment 50944
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50944=edit
C code for bind(c)

[Bug fortran/100916] New: Bind(c): CFI_type_other unimplemented.

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100916

Bug ID: 100916
   Summary: Bind(c): CFI_type_other unimplemented.
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jrfsousa at gcc dot gnu.org
  Target Milestone: ---

Created attachment 50943
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50943=edit
Fortran code showing problem

Hi All!

As per standard non C interoperability types get CFI_type_other.

Seen on:

GNU Fortran (GCC) 10.3.1 20210526
GNU Fortran (GCC) 11.1.1 20210526
GNU Fortran (GCC) 12.0.0 20210529 (experimental)

Thank you very much.

Best regards,
José Rui

Re: [PATCH 01/11] gen: Emit error msg for empty split condition

2021-06-04 Thread Segher Boessenkool
On Fri, Jun 04, 2021 at 01:03:34PM -0600, Martin Sebor wrote:
> Also, "insn" is not a word, and even though it's common abbreviation
> in GCC speak it's not necessarily something all users are familiar
> with, and doesn't lend itself to translation.  Please spell out
> the word instead.

This is a message for GCC developers, and it is not translated.


Segher


[Bug fortran/100915] Bind(c): failure handling C_FUNPTR

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100915

--- Comment #1 from José Rui Faustino de Sousa  ---
Created attachment 50942
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50942=edit
C code for bind(c)

[Bug fortran/100915] New: Bind(c): failure handling C_FUNPTR

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100915

Bug ID: 100915
   Summary: Bind(c): failure handling C_FUNPTR
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jrfsousa at gcc dot gnu.org
  Target Milestone: ---

Created attachment 50941
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50941=edit
Fortran code showing problem

Hi All!

Wrong type, kind and elem_len confuses CFI_address.

Seen on:

GNU Fortran (GCC) 10.3.1 20210526
GNU Fortran (GCC) 11.1.1 20210526
GNU Fortran (GCC) 12.0.0 20210529 (experimental)

Thank you very much.

Best regards,
José Rui

[Bug libstdc++/100824] ranges::size should treat the subexpression as an lvalue

2021-06-04 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100824

--- Comment #4 from Jonathan Wakely  ---
Ah yes, the __member_data and __adl_data concepts aren't decaying the result
types.

[Bug fortran/100914] Bind(c): errors handling complex

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

--- Comment #1 from José Rui Faustino de Sousa  ---
Created attachment 50940
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50940=edit
C code for bind(c)

[Bug fortran/100914] New: Bind(c): errors handling complex

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

Bug ID: 100914
   Summary: Bind(c): errors handling complex
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jrfsousa at gcc dot gnu.org
  Target Milestone: ---

Created attachment 50939
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50939=edit
Fortran code showing problem

Hi All!

Wrong type and kind with complex intrinsic type, causing failure at
CFI_Address.

Seen on:

GNU Fortran (GCC) 10.3.1 20210526
GNU Fortran (GCC) 11.1.1 20210526
GNU Fortran (GCC) 12.0.0 20210529 (experimental)

Thank you very much.

Best regards,
José Rui

Re: [PATCH 01/11] gen: Emit error msg for empty split condition

2021-06-04 Thread Martin Sebor via Gcc-patches

On 6/1/21 11:04 PM, Kewen Lin via Gcc-patches wrote:

As Segher suggested, this patch is to emit the error message
if the split condition of define_insn_and_split is empty while
the insn condition isn't.

gcc/ChangeLog:

* gensupport.c (process_rtx): Emit error message for empty
split condition in define_insn_and_split while the insn
condition isn't.
---
  gcc/gensupport.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/gcc/gensupport.c b/gcc/gensupport.c
index 0f19bd70664..52cee120215 100644
--- a/gcc/gensupport.c
+++ b/gcc/gensupport.c
@@ -620,6 +620,9 @@ process_rtx (rtx desc, file_location loc)
  }
else if (GET_CODE (desc) == DEFINE_INSN_AND_REWRITE)
  error_at (loc, "the rewrite condition must start with `&&'");
+   else if (split_cond[0] == '\0' && strlen (XSTR (desc, 2)) != 0)
+ error_at (loc, "the split condition mustn't be empty if the "
+"insn condition isn't empty");


The "mustn't" (and other similar contractions) should trigger
-Wdiag-format that GCC should be free of, or was not too long ago.
Can you please spell them out (the suggested alternative spelling
should be mentined in the warning)?

Also, "insn" is not a word, and even though it's common abbreviation
in GCC speak it's not necessarily something all users are familiar
with, and doesn't lend itself to translation.  Please spell out
the word instead.

Thanks
Martin


XSTR (split, 1) = split_cond;
if (GET_CODE (desc) == DEFINE_INSN_AND_REWRITE)
  XVEC (split, 2) = gen_rewrite_sequence (XVEC (desc, 1));





Re: [PATCH 02/57] Support scanning of build-time GC roots in gengtype

2021-06-04 Thread Bill Schmidt via Gcc-patches

On 5/20/21 5:24 PM, Segher Boessenkool wrote:

On Tue, May 11, 2021 at 11:01:22AM -0500, Bill Schmidt wrote:

Hi!  I'd like to ping this specific patch from the series, which is the
only one remaining that affects common code.  I confess that I don't
know whom to ask for a review for gengtype; I didn't get any good ideas
from MAINTAINERS.  If you know of a good reviewer candidate, please CC
them.

Richard is listed as the "gen* on machine desc" maintainer, that might
be the closest to this.  cc:ed.


Hi, Richard -- any thoughts on this patch?

https://gcc.gnu.org/pipermail/gcc-patches/2021-April/568841.html

Thanks!
Bill




Segher


Re: RFC: New mechanism for hard reg operands to inline asm

2021-06-04 Thread Andreas Krebbel via Gcc
On 6/4/21 8:18 PM, Paul Koning wrote:
...
> Yes, I would think this should be made a general mechanism that any target 
> could use.
> 
> I wonder if instead of creating a new mechanism you could do this simply by 
> creating new constraint names, where each name matches exactly one hard 
> register.  That's roughly what this amounts to, isn't it? 

I thought about this as well but I'm not sure this would work well without 
changing LRA. It would
mean to introduce many register classes with single registers. The presence of 
many "sparse"
register classes to my understanding would affect register allocation.

Perhaps it would work to just emit all the moves into or out of hard regs at 
expand time.

Andreas


[Bug c/100913] New: cppcheck: 2 * pointless new assignments in the parser ?

2021-06-04 Thread dcb314 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100913

Bug ID: 100913
   Summary: cppcheck: 2 * pointless new assignments in the parser
?
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

1.

trunk.git/gcc/c/c-parser.c:15600:12: style: Variable 'iterators' is assigned a
value that is never used. [unreadVariable]

git blame says:


trunk.git/g9a5de4d5af1c gcc/c/c-parser.c (Tobias Burnus   2021-05-28
10:01:19 +0200 15600) iterators = NULL_TREE;

2.

gcc/cp/parser.c:37830:12: style: Variable 'iterators' is assigned a value that
is never used. [unreadVariable]

Possible duplicate.

[Bug middle-end/100905] [OpenMP] ICE in convert_nonlocal_omp_clauses, at tree-nested.c:1514 with 'omp loop' in Fortran internal procedure

2021-06-04 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100905

--- Comment #2 from CVS Commits  ---
The master branch has been updated by Tobias Burnus :

https://gcc.gnu.org/g:c7070b31e12c18905ed0a60aaedd7a071aab5c60

commit r12-1226-gc7070b31e12c18905ed0a60aaedd7a071aab5c60
Author: Tobias Burnus 
Date:   Fri Jun 4 20:52:33 2021 +0200

OpenMP: Handle bind clause in tree-nested.c [PR100905]

PR middle-end/100905

gcc/ChangeLog:

* tree-nested.c (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Handle OMP_CLAUSE_BIND.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/loop-3.f90: New test.

Re: [EXTERNAL] Re: 64-bit integer typedef's and -fpic lead to infinite loop and growing memory use in port to x86-32

2021-06-04 Thread Barnes, Richard
I found the problem, and it was a mistake I made elsewhere that resulted in 
%edx being busy everywhere. I have fixed it and consider the issue resolved.

Richard Barnes


From: Barnes, Richard 
Sent: Friday, May 28, 2021 3:59 PM
To: H.J. Lu 
Cc: gcc@gcc.gnu.org 
Subject: Re: [EXTERNAL] Re: 64-bit integer typedef's and -fpic lead to infinite 
loop and growing memory use in port to x86-32

Our OS is not built with gcc. It is built with native compilers and linkers. It 
sounds like you are talking about cross compiling, which is something we have 
considered but hope to avoid.

Richard Barnes

From: H.J. Lu 
Sent: Friday, May 28, 2021 3:52 PM
To: Barnes, Richard 
Cc: gcc@gcc.gnu.org 
Subject: Re: [EXTERNAL] Re: 64-bit integer typedef's and -fpic lead to infinite 
loop and growing memory use in port to x86-32

[EXTERNAL SENDER: This email originated from outside of Stratus Technologies. 
Do not click links or open attachments unless you recognize the sender and know 
the content is safe.]

On Fri, May 28, 2021 at 12:42 PM Barnes, Richard
 wrote:
>
> Unfortunately, our OS is only a 32-bit OS. It's ABI is only a 32-bit ABI. As 
> you imply, if we had a 64-bit OS, we would have more registers and more 
> memory and would probably avoid this problem. Also, libgcc2.c is supposed to 
> be built natively by the gcc-10.2.0 compiler you have just created.
>

Are you aware that you can build a 32-bit OS with x86-64?  You can try
-mx32 with
GCC on Ubuntu.  You will get more registers as well as IP relative addressing.


--
H.J.



[committed] d: Fix ICE in gimplify_var_or_parm_decl, at gimplify.c:2755 (PR100882)

2021-06-04 Thread Iain Buclaw via Gcc-patches
Hi,

Constructor calls for temporaries were reusing the TARGET_EXPR_SLOT of a
TARGET_EXPR for an assignment, which later got passed to `build_assign',
which stripped away the outer TARGET_EXPR, leaving a reference to a lone
temporary with no declaration.

This stripping away of the TARGET_EXPR also discarded any cleanups that
may have been assigned to the expression as well.

So now the reuse of TARGET_EXPR_SLOT has been removed, and
`build_assign' now constructs assignments inside the TARGET_EXPR_INITIAL
slot.  This has also been extended to `return_expr', to deal with
possibility of a TARGET_EXPR being returned.

Bootstrapped and regression tested on x86_64-linux-gnu{-m32,-mx32},
committed to mainline, and backported to the releases/gcc-9,
releases/gcc-10, and releases/gcc-11 branches.

Regards,
Iain.

---
gcc/d/ChangeLog:

PR d/100882
* d-codegen.cc (build_assign): Construct initializations inside
TARGET_EXPR_INITIAL.
(compound_expr): Remove intermediate expressions that have no
side-effects.
(return_expr): Construct returns inside TARGET_EXPR_INITIAL.
* expr.cc (ExprVisitor::visit (CallExp *)): Remove useless assignment
to TARGET_EXPR_SLOT.

gcc/testsuite/ChangeLog:

PR d/100882
* gdc.dg/pr100882a.d: New test.
* gdc.dg/pr100882b.d: New test.
* gdc.dg/pr100882c.d: New test.
* gdc.dg/torture/pr100882.d: New test.
---
 gcc/d/d-codegen.cc  | 36 -
 gcc/d/expr.cc   |  7 +
 gcc/testsuite/gdc.dg/pr100882a.d| 35 
 gcc/testsuite/gdc.dg/pr100882b.d| 19 +
 gcc/testsuite/gdc.dg/pr100882c.d| 25 +
 gcc/testsuite/gdc.dg/torture/pr100882.d | 21 +++
 6 files changed, 131 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr100882a.d
 create mode 100644 gcc/testsuite/gdc.dg/pr100882b.d
 create mode 100644 gcc/testsuite/gdc.dg/pr100882c.d
 create mode 100644 gcc/testsuite/gdc.dg/torture/pr100882.d

diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 5fa1acd9240..9a9447371aa 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -1330,6 +1330,7 @@ component_ref (tree object, tree field)
 tree
 build_assign (tree_code code, tree lhs, tree rhs)
 {
+  tree result;
   tree init = stabilize_expr ();
   init = compound_expr (init, stabilize_expr ());
 
@@ -1348,22 +1349,27 @@ build_assign (tree_code code, tree lhs, tree rhs)
   if (TREE_CODE (rhs) == TARGET_EXPR)
 {
   /* If CODE is not INIT_EXPR, can't initialize LHS directly,
-since that would cause the LHS to be constructed twice.
-So we force the TARGET_EXPR to be expanded without a target.  */
+since that would cause the LHS to be constructed twice.  */
   if (code != INIT_EXPR)
{
  init = compound_expr (init, rhs);
- rhs = TARGET_EXPR_SLOT (rhs);
+ result = build_assign (code, lhs, TARGET_EXPR_SLOT (rhs));
}
   else
{
  d_mark_addressable (lhs);
- rhs = TARGET_EXPR_INITIAL (rhs);
+ TARGET_EXPR_INITIAL (rhs) = build_assign (code, lhs,
+   TARGET_EXPR_INITIAL (rhs));
+ result = rhs;
}
 }
+  else
+{
+  /* Simple assignment.  */
+  result = fold_build2_loc (input_location, code,
+   TREE_TYPE (lhs), lhs, rhs);
+}
 
-  tree result = fold_build2_loc (input_location, code,
-TREE_TYPE (lhs), lhs, rhs);
   return compound_expr (init, result);
 }
 
@@ -1485,6 +1491,11 @@ compound_expr (tree arg0, tree arg1)
   if (arg0 == NULL_TREE || !TREE_SIDE_EFFECTS (arg0))
 return arg1;
 
+  /* Remove intermediate expressions that have no side-effects.  */
+  while (TREE_CODE (arg0) == COMPOUND_EXPR
+&& !TREE_SIDE_EFFECTS (TREE_OPERAND (arg0, 1)))
+arg0 = TREE_OPERAND (arg0, 0);
+
   if (TREE_CODE (arg1) == TARGET_EXPR)
 {
   /* If the rhs is a TARGET_EXPR, then build the compound expression
@@ -1505,6 +1516,19 @@ compound_expr (tree arg0, tree arg1)
 tree
 return_expr (tree ret)
 {
+  /* Same as build_assign, the DECL_RESULT assignment replaces the temporary
+ in TARGET_EXPR_SLOT.  */
+  if (ret != NULL_TREE && TREE_CODE (ret) == TARGET_EXPR)
+{
+  tree exp = TARGET_EXPR_INITIAL (ret);
+  tree init = stabilize_expr ();
+
+  exp = fold_build1_loc (input_location, RETURN_EXPR, void_type_node, exp);
+  TARGET_EXPR_INITIAL (ret) = compound_expr (init, exp);
+
+  return ret;
+}
+
   return fold_build1_loc (input_location, RETURN_EXPR,
  void_type_node, ret);
 }
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index aad7cbbf947..e76cae98f7e 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -1894,15 +1894,10 @@ public:
   exp = d_convert (build_ctype (e->type), exp);
 
 /* If 

[Bug d/100882] ICE in gimplify_var_or_parm_decl, at gimplify.c:2755

2021-06-04 Thread ibuclaw at gdcproject dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100882

Iain Buclaw  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Iain Buclaw  ---
Fix committed and backported.

[Bug d/100882] ICE in gimplify_var_or_parm_decl, at gimplify.c:2755

2021-06-04 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100882

--- Comment #4 from CVS Commits  ---
The releases/gcc-9 branch has been updated by Iain Buclaw
:

https://gcc.gnu.org/g:b81bb0a6025588ac752cd78cce74ecf0d9ab4494

commit r9-9569-gb81bb0a6025588ac752cd78cce74ecf0d9ab4494
Author: Iain Buclaw 
Date:   Fri Jun 4 19:38:26 2021 +0200

d: Fix ICE in gimplify_var_or_parm_decl, at gimplify.c:2755 (PR100882)

Constructor calls for temporaries were reusing the TARGET_EXPR_SLOT of a
TARGET_EXPR for an assignment, which later got passed to `build_assign',
which stripped away the outer TARGET_EXPR, leaving a reference to a lone
temporary with no declaration.

This stripping away of the TARGET_EXPR also discarded any cleanups that
may have been assigned to the expression as well.

So now the reuse of TARGET_EXPR_SLOT has been removed, and
`build_assign' now constructs assignments inside the TARGET_EXPR_INITIAL
slot.  This has also been extended to `return_expr', to deal with
possibility of a TARGET_EXPR being returned.

gcc/d/ChangeLog:

PR d/100882
* d-codegen.cc (build_assign): Construct initializations inside
TARGET_EXPR_INITIAL.
(compound_expr): Remove intermediate expressions that have no
side-effects.
(return_expr): Construct returns inside TARGET_EXPR_INITIAL.
* expr.cc (ExprVisitor::visit (CallExp *)): Remove useless
assignment
to TARGET_EXPR_SLOT.

gcc/testsuite/ChangeLog:

PR d/100882
* gdc.dg/pr100882a.d: New test.
* gdc.dg/pr100882b.d: New test.
* gdc.dg/pr100882c.d: New test.
* gdc.dg/pr100882d.d: New test.

(cherry picked from commit e8761d4c21b5f4cc1c5612be9bf952a07c8a2238)

[Bug libstdc++/100912] New: powerpc64le: ieee128 long double incorrectly printed when using shared libstdc++

2021-06-04 Thread msc at linux dot ibm.com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100912

Bug ID: 100912
   Summary: powerpc64le: ieee128 long double incorrectly printed
when using shared libstdc++
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: msc at linux dot ibm.com
  Target Milestone: ---

Steps to reproduce:

- Build gcc with IEEE128 as the default long double format (using GCC source
revision cb6e6d5faa3f817435b6f203226fa5969d7a7264).

~/build/gcc> ~/src/gcc/configure --prefix=/home/mscastanho/usr
--with-long-double-128 --with-long-double-format=ieee
--build=powerpc64le-linux-gnu --host=powerpc64le-linux-gnu
--target=powerpc64le-linux-gnu --enable-languages=c++ --with-glibc-version=2.33
--disable-bootstrap CC=gcc-11 CXX=g++-11

~/build/gcc> make && make install

~/build/gcc> /home/mscastanho/usr/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/home/mscastanho/usr/bin/g++
COLLECT_LTO_WRAPPER=/home/mscastanho/usr/libexec/gcc/powerpc64le-linux-gnu/12.0.0/lto-wrapper
Target: powerpc64le-linux-gnu
Configured with: /home/mscastanho/src/gcc/configure
--prefix=/home/mscastanho/usr --with-long-double-128
--with-long-double-format=ieee --build=powerpc64le-linux-gnu
--host=powerpc64le-linux-gnu --target=powerpc64le-linux-gnu
--enable-languages=c++ --with-glibc-version=2.33 --disable-bootstrap CC=gcc-11
CXX=g++-11
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210604 (experimental) (GCC)


- Build and run simple test program with the new compiler and libstdc++

~/build/gcc> cat ~/test-ieee128.cpp 
#include 
using namespace std;
int main () {
long double n = 1.0L;
cout << n << endl;
return 0;
}

~/build/gcc> /home/mscastanho/usr/bin/g++ -g ~/test-ieee128.cpp -o test-shared
~/build/gcc> LD_PRELOAD=~/usr/lib64/libstdc++.so.6 ./test-shared
6.95326e-310

Here I'd expect "1" to be printed. 

If the same program is statically linked to libstdc++, it works as expected:

mscastanho@yanny4:~/build/gcc> /home/mscastanho/usr/bin/g++ -g
-static-libstdc++ ~/test-ieee128.cpp -o test-static
mscastanho@yanny4:~/build/gcc> ./test-static 
1


After running the two programs side-by-side under gdb, I found out they are
actually calling two different symbols for vsnprintf on std::__convert_from_v.

Dynamically linked binary:

>>> disas _ZSt16__convert_from_vRKP15__locale_structPciPKcz
Dump of assembler code for function
_ZSt16__convert_from_vRKP15__locale_structPciPKcz:
   0x77d19340 <+0>: addis   r2,r12,37
   0x77d19344 <+4>: addir2,r2,-14912
=> 0x77d19348 <+8>: mflrr0
   0x77d1934c <+12>:std r29,-24(r1)
   0x77d19350 <+16>:std r30,-16(r1)
   0x77d19354 <+20>:mr  r29,r6
   0x77d19358 <+24>:std r31,-8(r1)
   0x77d1935c <+28>:mr  r30,r5
   0x77d19360 <+32>:mr  r31,r4
   0x77d19364 <+36>:std r0,16(r1)
   0x77d19368 <+40>:stdur1,-64(r1)
   0x77d1936c <+44>:std r7,128(r1)
   0x77d19370 <+48>:std r8,136(r1)
   0x77d19374 <+52>:std r10,152(r1)
   0x77d19378 <+56>:std r9,144(r1)
   0x77d1937c <+60>:ld  r3,0(r3)
   0x77d19380 <+64>:bl  0x77d09b60
<06bf.plt_call.__uselocale@@GLIBC_2.17>
   0x77d19384 <+68>:ld  r2,24(r1)
   0x77d19388 <+72>:mr  r5,r29
   0x77d1938c <+76>:mr  r4,r30
   0x77d19390 <+80>:addir6,r1,128
   0x77d19394 <+84>:mr  r9,r3
   0x77d19398 <+88>:mr  r3,r31
   0x77d1939c <+92>:mr  r30,r9
   0x77d193a0 <+96>:bl  0x77d112a0
<06bf.plt_call.vsnprintf@@GLIBC_2.17><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   0x77d193a4 <+100>:   ld  r2,24(r1)
   0x77d193a8 <+104>:   mr  r31,r3
   0x77d193ac <+108>:   mr  r3,r30
   0x77d193b0 <+112>:   bl  0x77d09b60
<06bf.plt_call.__uselocale@@GLIBC_2.17>
   0x77d193b4 <+116>:   ld  r2,24(r1)
   0x77d193b8 <+120>:   addir1,r1,64
   0x77d193bc <+124>:   mr  r3,r31
   0x77d193c0 <+128>:   ld  r0,16(r1)
   0x77d193c4 <+132>:   ld  r29,-24(r1)
   0x77d193c8 <+136>:   ld  r30,-16(r1)
   0x77d193cc <+1

[Bug d/100882] ICE in gimplify_var_or_parm_decl, at gimplify.c:2755

2021-06-04 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100882

--- Comment #3 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Iain Buclaw
:

https://gcc.gnu.org/g:dcc5cf980af747941b32fd16c1d6a07177a1a404

commit r10-9891-gdcc5cf980af747941b32fd16c1d6a07177a1a404
Author: Iain Buclaw 
Date:   Fri Jun 4 19:38:26 2021 +0200

d: Fix ICE in gimplify_var_or_parm_decl, at gimplify.c:2755 (PR100882)

Constructor calls for temporaries were reusing the TARGET_EXPR_SLOT of a
TARGET_EXPR for an assignment, which later got passed to `build_assign',
which stripped away the outer TARGET_EXPR, leaving a reference to a lone
temporary with no declaration.

This stripping away of the TARGET_EXPR also discarded any cleanups that
may have been assigned to the expression as well.

So now the reuse of TARGET_EXPR_SLOT has been removed, and
`build_assign' now constructs assignments inside the TARGET_EXPR_INITIAL
slot.  This has also been extended to `return_expr', to deal with
possibility of a TARGET_EXPR being returned.

gcc/d/ChangeLog:

PR d/100882
* d-codegen.cc (build_assign): Construct initializations inside
TARGET_EXPR_INITIAL.
(compound_expr): Remove intermediate expressions that have no
side-effects.
(return_expr): Construct returns inside TARGET_EXPR_INITIAL.
* expr.cc (ExprVisitor::visit (CallExp *)): Remove useless
assignment
to TARGET_EXPR_SLOT.

gcc/testsuite/ChangeLog:

PR d/100882
* gdc.dg/pr100882a.d: New test.
* gdc.dg/pr100882b.d: New test.
* gdc.dg/pr100882c.d: New test.
* gdc.dg/pr100882d.d: New test.

(cherry picked from commit e8761d4c21b5f4cc1c5612be9bf952a07c8a2238)

[Bug d/100882] ICE in gimplify_var_or_parm_decl, at gimplify.c:2755

2021-06-04 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100882

--- Comment #2 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Iain Buclaw
:

https://gcc.gnu.org/g:83f932f23cae74344ec9e67c76faf2f014857992

commit r11-8512-g83f932f23cae74344ec9e67c76faf2f014857992
Author: Iain Buclaw 
Date:   Fri Jun 4 19:38:26 2021 +0200

d: Fix ICE in gimplify_var_or_parm_decl, at gimplify.c:2755 (PR100882)

Constructor calls for temporaries were reusing the TARGET_EXPR_SLOT of a
TARGET_EXPR for an assignment, which later got passed to `build_assign',
which stripped away the outer TARGET_EXPR, leaving a reference to a lone
temporary with no declaration.

This stripping away of the TARGET_EXPR also discarded any cleanups that
may have been assigned to the expression as well.

So now the reuse of TARGET_EXPR_SLOT has been removed, and
`build_assign' now constructs assignments inside the TARGET_EXPR_INITIAL
slot.  This has also been extended to `return_expr', to deal with
possibility of a TARGET_EXPR being returned.

gcc/d/ChangeLog:

PR d/100882
* d-codegen.cc (build_assign): Construct initializations inside
TARGET_EXPR_INITIAL.
(compound_expr): Remove intermediate expressions that have no
side-effects.
(return_expr): Construct returns inside TARGET_EXPR_INITIAL.
* expr.cc (ExprVisitor::visit (CallExp *)): Remove useless
assignment
to TARGET_EXPR_SLOT.

gcc/testsuite/ChangeLog:

PR d/100882
* gdc.dg/pr100882a.d: New test.
* gdc.dg/pr100882b.d: New test.
* gdc.dg/pr100882c.d: New test.
* gdc.dg/torture/pr100882.d: New test.

(cherry picked from commit e8761d4c21b5f4cc1c5612be9bf952a07c8a2238)

[Bug d/100882] ICE in gimplify_var_or_parm_decl, at gimplify.c:2755

2021-06-04 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100882

--- Comment #1 from CVS Commits  ---
The master branch has been updated by Iain Buclaw :

https://gcc.gnu.org/g:df3fbd5957f12927a459a2686f4eee55f66ec2f4

commit r12-1225-gdf3fbd5957f12927a459a2686f4eee55f66ec2f4
Author: Iain Buclaw 
Date:   Fri Jun 4 19:38:26 2021 +0200

d: Fix ICE in gimplify_var_or_parm_decl, at gimplify.c:2755 (PR100882)

Constructor calls for temporaries were reusing the TARGET_EXPR_SLOT of a
TARGET_EXPR for an assignment, which later got passed to `build_assign',
which stripped away the outer TARGET_EXPR, leaving a reference to a lone
temporary with no declaration.

This stripping away of the TARGET_EXPR also discarded any cleanups that
may have been assigned to the expression as well.

So now the reuse of TARGET_EXPR_SLOT has been removed, and
`build_assign' now constructs assignments inside the TARGET_EXPR_INITIAL
slot.  This has also been extended to `return_expr', to deal with
possibility of a TARGET_EXPR being returned.

gcc/d/ChangeLog:

PR d/100882
* d-codegen.cc (build_assign): Construct initializations inside
TARGET_EXPR_INITIAL.
(compound_expr): Remove intermediate expressions that have no
side-effects.
(return_expr): Construct returns inside TARGET_EXPR_INITIAL.
* expr.cc (ExprVisitor::visit (CallExp *)): Remove useless
assignment
to TARGET_EXPR_SLOT.

gcc/testsuite/ChangeLog:

PR d/100882
* gdc.dg/pr100882a.d: New test.
* gdc.dg/pr100882b.d: New test.
* gdc.dg/pr100882c.d: New test.
* gdc.dg/torture/pr100882.d: New test.

[Bug fortran/100911] Bind(c): failure handling C_PTR

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100911

--- Comment #1 from José Rui Faustino de Sousa  ---
Created attachment 50938
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50938=edit
C code for bind(c)

[Bug fortran/100911] New: Bind(c): failure handling C_PTR

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100911

Bug ID: 100911
   Summary: Bind(c): failure handling C_PTR
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jrfsousa at gcc dot gnu.org
  Target Milestone: ---

Created attachment 50937
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50937=edit
Fortran code showing problem

Hi All!

Wrong type and kind and crash due to division by zero (elem_len==0)

Seen on:

GNU Fortran (GCC) 10.3.1 20210526
GNU Fortran (GCC) 11.1.1 20210526
GNU Fortran (GCC) 12.0.0 20210529 (experimental)

Thank you very much.

Best regards,
José Rui

[Bug target/100909] [12 Regression] powerpc64le: Regression causing unexpected error with IBM long double

2021-06-04 Thread bergner at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100909

Peter Bergner  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 CC||bergner at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org,
   ||segher at gcc dot gnu.org
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2021-06-04

--- Comment #1 from Peter Bergner  ---
Confirmed.  creduce on the attached test case gives me:

bergner@pike:~/gcc/BUGS/PR100909$ cat pr100909.i
void __attribute__((__optimize__("O2"))) a() { }

bergner@pike:~/gcc/BUGS/PR100909$
/home/bergner/gcc/build/gcc-fsf-mainline-pr100799-debug/gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-mainline-pr100799-debug/gcc -S 
-mlong-double-128 -mabi=ibmlongdouble pr100909.i 
pr100909.i:1:1: error: ‘-mabi=ibmlongdouble’ requires ‘-mlong-double-128’
1 | void __attribute__((__optimize__("O2"))) a() { }
  | ^~~~
pr100909.i: In function ‘a’:
pr100909.i:1:1: error: ‘-mabi=ibmlongdouble’ requires ‘-mlong-double-128’
pr100909.i:1:1: error: ‘-mabi=ibmlongdouble’ requires ‘-mlong-double-128’
pr100909.i:1:42: error: ‘-mabi=ibmlongdouble’ requires ‘-mlong-double-128’
1 | void __attribute__((__optimize__("O2"))) a() { }
  |  ^
pr100909.i:1:42: error: ‘-mabi=ibmlongdouble’ requires ‘-mlong-double-128’

[Bug fortran/100910] Bind(c): errors handling long double complex

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100910

--- Comment #1 from José Rui Faustino de Sousa  ---
Created attachment 50936
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50936=edit
C code for bind(c)

[Bug fortran/100910] New: Bind(c): errors handling long double complex

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100910

Bug ID: 100910
   Summary: Bind(c): errors handling long double complex
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jrfsousa at gcc dot gnu.org
  Target Milestone: ---

Created attachment 50935
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50935=edit
Fortran code showing problem

Hi All!

Errors handling kind due to kind not being realted to elem_len.

Seen on:

GNU Fortran (GCC) 10.3.1 20210526
GNU Fortran (GCC) 11.1.1 20210526
GNU Fortran (GCC) 12.0.0 20210529 (experimental)

Thank you very much.

Best regards.
José Rui

[Bug middle-end/100908] asan clobberes register asm variables

2021-06-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100908

Andrew Pinski  changed:

   What|Removed |Added

   Severity|normal  |enhancement

--- Comment #2 from Andrew Pinski  ---
(In reply to Andreas Krebbel from comment #1)
> https://gcc.gnu.org/pipermail/gcc/2021-June/236269.html

Yes this will help solve the limitations which are already mentioned in the
manual:
Warning: In the above example, be aware that a register (for example r0) can be
call-clobbered by subsequent code, including function calls and library calls
for arithmetic operators on other variables (for example the initialization of
p2). In this case, use temporary variables for expressions between the register
assignments:

[Bug fortran/99839] [9/10/11/12 Regression] ICE in inline_matmul_assign, at fortran/frontend-passes.c:4234

2021-06-04 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99839

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #10 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-12, and committed on 11-, 10- and 9-branch.  Closing.

Thanks for the report!

[Bug fortran/99839] [9/10/11/12 Regression] ICE in inline_matmul_assign, at fortran/frontend-passes.c:4234

2021-06-04 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99839

--- Comment #9 from CVS Commits  ---
The releases/gcc-9 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:e912880888f9529eb44e3456c4753fc556c63812

commit r9-9568-ge912880888f9529eb44e3456c4753fc556c63812
Author: Harald Anlauf 
Date:   Fri Jun 4 19:23:48 2021 +0200

Fortran - ICE in inline_matmul_assign

Restrict inlining of matmul to those cases where assignment to the
result array does not need special treatment.

gcc/fortran/ChangeLog:

PR fortran/99839
* frontend-passes.c (inline_matmul_assign): Do not inline matmul
if the assignment to the resulting array if it is not of canonical
type (real/integer/complex/logical).

gcc/testsuite/ChangeLog:

PR fortran/99839
* gfortran.dg/inline_matmul_25.f90: New test.

(cherry picked from commit bee8619ad0ac3bd27b7c8dc5819b83a5e8e147a0)

Re: RFC: New mechanism for hard reg operands to inline asm

2021-06-04 Thread Paul Koning via Gcc



> On Jun 4, 2021, at 2:02 PM, Andreas Krebbel via Gcc  wrote:
> 
> Hi,
> 
> I wonder if we could replace the register asm construct for
> inline assemblies with something a bit nicer and more obvious.
> E.g. turning this (real world example from IBM Z kernel code):
> 
> int diag8_response(int cmdlen, char *response, int *rlen)
> {
>register unsigned long reg2 asm ("2") = (addr_t) cpcmd_buf;
>register unsigned long reg3 asm ("3") = (addr_t) response;
>register unsigned long reg4 asm ("4") = cmdlen | 0x4000L;
>register unsigned long reg5 asm ("5") = *rlen; /* <-- */
>asm volatile(
>"   diag%2,%0,0x8\n"
>"   brc 8,1f\n"
>"   agr %1,%4\n"
>"1:\n"
>: "+d" (reg4), "+d" (reg5)
>: "d" (reg2), "d" (reg3), "d" (*rlen): "cc");
>*rlen = reg5;
>return reg4;
> }
> 
> into this:
> 
> int diag8_response(int cmdlen, char *response, int *rlen)
> {
>unsigned long len = cmdlen | 0x4000L;
> 
>asm volatile(
>"   diag%2,%0,0x8\n"
>"   brc 8,1f\n"
>"   agr %1,%4\n"
>"1:\n"
>: "+{r4}" (len), "+{r5}" (*rlen)
>: "{r2}" ((addr_t)cpcmd_buf), "{r3}" ((addr_t)response), "d" 
> (*rlen): "cc");
>return len;
> }
> 
> Apart from being much easier to read because the hard regs become part
> of the inline assembly it solves also a couple of other issues:
> 
> - function calls might clobber register asm variables see BZ100908
> - the constraints for the register asm operands are superfluous
> - one register asm variable cannot be used for 2 different inline
>  assemblies if the value is expected in different hard regs
> 
> I've started with a hackish implementation for IBM Z using the
> TARGET_MD_ASM_ADJUST hook and let all the places parsing constraints
> skip over the {} parts.  But perhaps it would be useful to make this a
> generic mechanism for all targets?!
> 
> Andreas

Yes, I would think this should be made a general mechanism that any target 
could use.

I wonder if instead of creating a new mechanism you could do this simply by 
creating new constraint names, where each name matches exactly one hard 
register.  That's roughly what this amounts to, isn't it? 

paul



[Bug middle-end/100908] asan clobberes register asm variables

2021-06-04 Thread krebbel at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100908

--- Comment #1 from Andreas Krebbel  ---
https://gcc.gnu.org/pipermail/gcc/2021-June/236269.html

  1   2   3   >