[committed] RISC-V: Fix python3 compatibility for multilib-generator

2020-12-23 Thread Kito Cheng
The subprocess return string is raw bytes in python3, it must decode
before used as string, verifed with python2 and python3.

gcc/ChangeLog:

* config/riscv/multilib-generator (arch_canonicalize): Call
decode for the subprocess return value.
---
 gcc/config/riscv/multilib-generator | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/riscv/multilib-generator 
b/gcc/config/riscv/multilib-generator
index ccfd9ea18ea..64ff15f449b 100755
--- a/gcc/config/riscv/multilib-generator
+++ b/gcc/config/riscv/multilib-generator
@@ -57,7 +57,7 @@ def arch_canonicalize(arch):
   proc = subprocess.Popen([sys.executable, arch_can_script, arch],
   stdout=subprocess.PIPE)
   out, err = proc.communicate()
-  return out.strip()
+  return out.decode().strip()
 
 #
 # Handle expansion operation.
-- 
2.29.2



Go patch committed: Parenthesize channel type strings as needed

2020-12-23 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend avoids the ambiguity between "chan <-
(chan int)" and "chan (<- chan int)".  This parenthesizes the same way
as the gc compiler.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
a40029e3b185a4b4e16a2a83933f742ff48c9743
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 600d9769624..1e461f06e95 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-8d49adead59b8103f3bfeebd53ee508eda5ee94a
+d67579759e1769c08148304b2d378ec0b05637d6
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 16f0eb59a50..7d4c47f1c42 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -8845,7 +8845,22 @@ Channel_type::do_reflection(Gogo* gogo, std::string* 
ret) const
   if (!this->may_receive_)
 ret->append("<-");
   ret->push_back(' ');
+
+  bool need_paren = false;
+  if (this->may_send_
+  && this->may_receive_
+  && this->element_type_->channel_type() != NULL
+  && this->element_type_->unalias()->named_type() == NULL
+  && !this->element_type_->channel_type()->may_send())
+{
+  ret->push_back('(');
+  need_paren = true;
+}
+
   this->append_reflection(this->element_type_, gogo, ret);
+
+  if (need_paren)
+ret->push_back(')');
 }
 
 // Export.


[PATCH] libtool.m4: update GNU/Hurd test from upstream

2020-12-23 Thread Samuel Thibault
In upstream libtool, 47a889a4ca20 ("Improve GNU/Hurd support.") fixed
detection of shlibpath_overrides_runpath, thus avoiding unnecessary relink.
This backports it.

ChangeLog:

* libtool.m4: Match gnu* along other GNU systems.
* libffi/configure: Re-generate.
* libgomp/configure: Re-generate.

* libgo/config/libtool.m4: Match gnu* along other GNU systems.
* libgo/configure: Re-generate.

gcc/ChangeLog:

* configure: Re-generate.

libatomic/ChangeLog:

* configure: Re-generate.

libbacktrace/ChangeLog:

* configure: Re-generate.

libcc1/ChangeLog:

* configure: Re-generate.

libgfortran/ChangeLog:

* configure: Re-generate.

libgomp/ChangeLog:

* configure: Re-generate.

libhsail-rt/ChangeLog:

* configure: Re-generate.

libitm/ChangeLog:

* configure: Re-generate.

libobjc/ChangeLog:

* configure: Re-generate.

liboffloadmic/ChangeLog:

* configure: Re-generate.
* plugin/configure: Re-generate.

libphobos/ChangeLog:

* configure: Re-generate.

libquadmath/ChangeLog:

* configure: Re-generate.

libsanitizer/ChangeLog:

* configure: Re-generate.

libssp/ChangeLog:

* configure: Re-generate.

libstdc++-v3/ChangeLog:

* configure: Re-generate.

libvtv/ChangeLog:

* configure: Re-generate.

lto-plugin/ChangeLog:

* configure: Re-generate.

zlib/ChangeLog:

* configure: Re-generate.
---
 gcc/configure  | 12 +---
 libatomic/configure| 12 +---
 libbacktrace/configure | 12 +---
 libcc1/configure   | 12 +---
 libffi/configure   | 12 +---
 libgfortran/configure  | 12 +---
 libgo/config/libtool.m4| 12 +---
 libgo/configure| 12 +---
 libgomp/configure  | 12 +---
 libhsail-rt/configure  | 12 +---
 libitm/configure   | 12 +---
 libobjc/configure  | 12 +---
 liboffloadmic/configure| 12 +---
 liboffloadmic/plugin/configure | 12 +---
 libphobos/configure| 12 +---
 libquadmath/configure  | 12 +---
 libsanitizer/configure | 12 +---
 libssp/configure   | 12 +---
 libstdc++-v3/configure | 12 +---
 libtool.m4 | 12 +---
 libvtv/configure   | 12 +---
 lto-plugin/configure   | 12 +---
 zlib/configure | 12 +---
 23 files changed, 23 insertions(+), 253 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index fbe92089640..9a25dacf8b3 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -18366,16 +18366,6 @@ freebsd* | dragonfly*)
   esac
   ;;
 
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix 
${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
-
 haiku*)
   version_type=linux
   need_lib_prefix=no
@@ -18497,7 +18487,7 @@ linux*oldld* | linux*aout* | linux*coff*)
 # project, but have not yet been accepted: they are GCC-local changes
 # for the time being.  (See
 # https://lists.gnu.org/archive/html/libtool-patches/2018-05/msg0.html)
-linux* | k*bsd*-gnu | kopensolaris*-gnu | uclinuxfdpiceabi)
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu* | uclinuxfdpiceabi)
   version_type=linux
   need_lib_prefix=no
   need_version=no
diff --git a/libatomic/configure b/libatomic/configure
index 50fe5480b78..5867e69ac14 100755
--- a/libatomic/configure
+++ b/libatomic/configure
@@ -10570,16 +10570,6 @@ freebsd* | dragonfly*)
   esac
   ;;
 
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix 
${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
-
 haiku*)
   version_type=linux
   need_lib_prefix=no
@@ -10701,7 +10691,7 @@ linux*oldld* | linux*aout* | linux*coff*)
 # project, but have not yet been accepted: they are GCC-local changes
 # for the time being.  (See
 # https://lists.gnu.org/archive/html/libtool-patches/2018-05/msg0.html)
-linux* | k*bsd*-gnu | kopensolaris*-gnu | uclinuxfdpiceabi)
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu* | uclinuxfdpiceabi)
   version_type=linux
   need_lib_prefix=no
   need_version=no
diff --git a/libbacktrace/configure b/libbacktrace/configure
index 665adef7566..86e387f0ca5 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -10699,16 +10699,6 @@ freebsd* | dragonfly*)
   esac
   ;;
 
-gnu*)
-  version_type=linux
-  need_lib_prefix=no

[committed] avoid assuming allocation/deallocation calls are made through decls (PR 98160)

2020-12-23 Thread Martin Sebor via Gcc-patches

The previous fix for PR 98160 was incomplete and while it fixed
the more interesting aspect of the problem (a false positive) it
didn't remedy the ICE that showed up only with LTO.  I have
reduced (again) the problem to a non-LTO test case and committed
the attached trivial fix in r11-6329 after regtesting in on
x86_64-linux.

Martin
commit 0df311657dc8c2a7f6ce3464c9d9ae5d5033840c
Author: Martin Sebor 
Date:   Wed Dec 23 16:34:12 2020 -0700

PR middle-end/98160 - ICE in warn_dealloc_offset on member placement new and delete

gcc/ChangeLog:

PR middle-end/98160
* builtins.c (warn_dealloc_offset): Avoid assuming calls are made
through declared functions and not pointers.

gcc/testsuite/ChangeLog:

PR middle-end/98160
* g++.dg/warn/pr98160.C: New test.

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 498a1121dec..ffbb9b7f5f1 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -13400,6 +13400,8 @@ warn_dealloc_offset (location_t loc, tree exp, const access_ref &aref)
 return false;
 
   tree dealloc_decl = get_callee_fndecl (exp);
+  if (!dealloc_decl)
+return false;
 
   if (DECL_IS_OPERATOR_DELETE_P (dealloc_decl)
   && !DECL_IS_REPLACEABLE_OPERATOR (dealloc_decl))
@@ -13413,7 +13415,7 @@ warn_dealloc_offset (location_t loc, tree exp, const access_ref &aref)
 	  if (is_gimple_call (def_stmt))
 	{
 	  tree alloc_decl = gimple_call_fndecl (def_stmt);
-	  if (!DECL_IS_OPERATOR_NEW_P (alloc_decl))
+	  if (!alloc_decl || !DECL_IS_OPERATOR_NEW_P (alloc_decl))
 		return false;
 	}
 	}
diff --git a/gcc/testsuite/g++.dg/warn/pr98160.C b/gcc/testsuite/g++.dg/warn/pr98160.C
new file mode 100644
index 000..b3c5783b5e1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/pr98160.C
@@ -0,0 +1,30 @@
+/* PR middle-end/98160 - ICE in warn_dealloc_offset on member placement
+   new and delete
+   { dg-do compile }
+   { dg-options "-O2 -Wall" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void* (*pf) (size_t);
+
+struct A;
+struct B
+{
+  B ();
+
+  void* operator new (size_t, A*);
+  void operator delete (void*, A*);
+};
+
+void operator delete (void *, A*);
+
+void B::operator delete (void*, A *p)
+{
+  void *q = pf (1);
+  ::operator delete ((char*)q + 1, p);
+}
+
+void* f (A *p)
+{
+  return new (p) B;
+}


[committed] avoid invalid arguments in get_offset_range (PR 98413)

2020-12-23 Thread Martin Sebor via Gcc-patches

get_offset_range() expects integer and pointer arguments but can't
deal with others such as C++ OFFSET_TYPE.  The attached fix has
the function fail for arguments of such types.  I have committed
the trivial change in r11-6328 after regression-testing in on
x86_64-linux.

Martin
commit fdd8560cce9f10fe5dcd26483440be136b81701d
Author: Martin Sebor 
Date:   Wed Dec 23 16:28:06 2020 -0700

PR c++/98413 - ICE on placement new and member pointer

gcc/ChangeLog:

PR c++/98413
* builtins.c (get_offset_range): Avoid non-integers/-pointers.

gcc/testsuite/ChangeLog:

PR c++/98413
* g++.dg/warn/pr98413.C: New test.

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 28e5ab2..498a1121dec 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -5097,6 +5097,8 @@ get_offset_range (tree x, gimple *stmt, offset_int r[2], range_query *rvals)
 x = TREE_OPERAND (x, 0);
 
   tree type = TREE_TYPE (x);
+  if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type))
+return false;
 
if (TREE_CODE (x) != INTEGER_CST
   && TREE_CODE (x) != SSA_NAME)
@@ -13398,6 +13400,7 @@ warn_dealloc_offset (location_t loc, tree exp, const access_ref &aref)
 return false;
 
   tree dealloc_decl = get_callee_fndecl (exp);
+
   if (DECL_IS_OPERATOR_DELETE_P (dealloc_decl)
   && !DECL_IS_REPLACEABLE_OPERATOR (dealloc_decl))
 {
diff --git a/gcc/testsuite/g++.dg/warn/pr98413.C b/gcc/testsuite/g++.dg/warn/pr98413.C
new file mode 100644
index 000..877871ad2c4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/pr98413.C
@@ -0,0 +1,23 @@
+/* PR c++/98413 - ICE on placement new and member pointer
+   { dg-do compile }
+   { dg-options "-Wall" } */
+
+void* operator new (__SIZE_TYPE__, void *p) { return p; }
+
+struct A { int m; } a;
+
+void fc (int A::*p)
+{
+  new (&(a.*p)) char;
+}
+
+void fi (int A::*p)
+{
+  new (&(a.*p)) int;
+}
+
+void fB (int A::*p)
+{
+  struct B { int a[2]; };
+  new (&(a.*p)) B;// { dg-warning "\\\[-Wplacement-new" }
+}


c++: EOF location [PR 96045]

2020-12-23 Thread Nathan Sidwell


Setting the EOF token location to be the start of a line just after
the ending newline is not most helpful.  While that location is
probably the right place to report preprocessing and lexing issues,
when parsing, the location just after the last token is better.  That
way we get to point at some actual text.  Setting the location from
the previous token has the advantage over just setting the location to
be the end of the final line, in that any ending comments do not get
considered, which I think is better.

PR c++/96045
gcc/cp/
* parser.c (cp_lexer_new_main): Adjust EOF token location.
gcc/testsuite/
* g++.dg/diagnostic/pr96045-1.C: New.
* g++.dg/diagnostic/pr96045-2.C: New.
* g++.dg/diagnostic/pr96045-3.C: New.
* c-c++-common/goacc/pr79428-1.c: Adjust EOF diagnostic location.
* c-c++-common/gomp/pr79428-2.c: Likewise
* c-c++-common/raw-string-6.c: Likewise
* g++.dg/cpp0x/decltype63.C: Likewise
* g++.dg/cpp0x/gen-attrs-64.C: Likewise
* g++.dg/cpp0x/pr68726.C: Likewise
* g++.dg/cpp0x/pr78341.C: Likewise
* g++.dg/cpp1y/pr65202.C: Likewise
* g++.dg/cpp1y/pr65340.C: Likewise
* g++.dg/cpp1y/pr68578.C: Likewise
* g++.dg/cpp1z/class-deduction44.C: Likewise
* g++.dg/diagnostic/unclosed-extern-c.C: Likewise
* g++.dg/diagnostic/unclosed-function.C: Likewise
* g++.dg/diagnostic/unclosed-namespace.C: Likewise
* g++.dg/diagnostic/unclosed-struct.C: Likewise
* g++.dg/ext/pr84598.C: Likewise
* g++.dg/other/switch4.C: Likewise
* g++.dg/parse/attr4.C: Likewise
* g++.dg/parse/cond4.C: Likewise
* g++.dg/parse/crash10.C: Likewise
* g++.dg/parse/crash18.C: Likewise
* g++.dg/parse/crash27.C: Likewise
* g++.dg/parse/crash34.C: Likewise
* g++.dg/parse/crash35.C: Likewise
* g++.dg/parse/crash52.C: Likewise
* g++.dg/parse/crash59.C: Likewise
* g++.dg/parse/crash61.C: Likewise
* g++.dg/parse/crash67.C: Likewise
* g++.dg/parse/error14.C: Likewise
* g++.dg/parse/error56.C: Likewise
* g++.dg/parse/invalid1.C: Likewise
* g++.dg/parse/parameter-declaration-1.C: Likewise
* g++.dg/parse/parser-pr28152-2.C: Likewise
* g++.dg/parse/parser-pr28152.C: Likewise
* g++.dg/parse/pr68722.C: Likewise
* g++.dg/parse/pr96258.C: Likewise
* g++.dg/pr46852.C: Likewise
* g++.dg/pr46868.C: Likewise
* g++.dg/template/crash115.C: Likewise
* g++.dg/template/crash43.C: Likewise
* g++.dg/template/crash90.C: Likewise
* g++.dg/template/error-recovery1.C: Likewise
* g++.dg/template/error57.C: Likewise
* g++.old-deja/g++.other/crash31.C: Likewise


--
Nathan Sidwell
diff --git c/gcc/cp/parser.c w/gcc/cp/parser.c
index 3883339aa64..dd8e8081847 100644
--- c/gcc/cp/parser.c
+++ w/gcc/cp/parser.c
@@ -666,6 +666,16 @@ cp_lexer_new_main (void)
   + lexer->buffer->length ()
 		  - 1;
 
+  if (lexer->buffer->length () != 1)
+{
+  /* Set the EOF token's location to be the just after the previous
+ token's range.  That way 'at-eof' diagnostics point at something
+	 meaninful.  */
+  auto range = get_range_from_loc (line_table, tok[-1].location);
+  tok[0].location
+	= linemap_position_for_loc_and_offset (line_table, range.m_finish, 1);
+}
+
   if (filter)
 module_token_cdtor (parse_in, filter);
 
diff --git c/gcc/testsuite/c-c++-common/goacc/pr79428-1.c w/gcc/testsuite/c-c++-common/goacc/pr79428-1.c
index 68dea5b145e..a8047e98123 100644
--- c/gcc/testsuite/c-c++-common/goacc/pr79428-1.c
+++ w/gcc/testsuite/c-c++-common/goacc/pr79428-1.c
@@ -4,5 +4,5 @@ void
 foo ()
 {
 #pragma acc routine /* { dg-error ".#pragma acc routine. must be at file scope" } */
-// { dg-error "expected" "end" { target c } .-1 }
-// { dg-error "-:expected" "end" { target c++ } .+1 }
+// { dg-error "expected" "end" { target *-*-* } .-1 }
+
diff --git c/gcc/testsuite/c-c++-common/gomp/pr79428-2.c w/gcc/testsuite/c-c++-common/gomp/pr79428-2.c
index 0914963b8f9..6d162a2c13f 100644
--- c/gcc/testsuite/c-c++-common/gomp/pr79428-2.c
+++ w/gcc/testsuite/c-c++-common/gomp/pr79428-2.c
@@ -5,5 +5,4 @@ foo ()
 {
 #pragma omp sections
 #pragma omp section /* { dg-error "'#pragma omp section' may only be used in '#pragma omp sections' construct|not allowed" } */
-// { dg-error "expected" "end" { target c } .-1 }
-// { dg-error "-:expected" "end" { target c++ } .+1 }
+// { dg-error "expected" "end" { target *-*-* } .-1 }
diff --git c/gcc/testsuite/c-c++-common/raw-string-6.c w/gcc/testsuite/c-c++-common/raw-string-6.c
index a2cb30e96c9..819dd44aff4 100644
--- c/gcc/testsuite/c-c++-common/raw-string-6.c
+++ w/gcc/testsuite/c-c++-common/raw-string-6.c
@@ -3,5 +3,4 @@
 // { dg-options "-std=c++0x" { target c++ } }
 
 const void *s0 = R"ouch()ouCh"; 	// { dg-e

[pushed] c++: Fix initializing empty base from prvalue [PR97597]

2020-12-23 Thread Jason Merrill via Gcc-patches
unsafe_return_slot_p wasn't recognizing an empty base as
potentially-overlapping, which it definitely is.

The change to build_base_path is to make the virtual conversion also
recognized by is_empty_base_ref; unsafe_return_slot_p doesn't to handle
virtual conversions, but hypothetical future callers might.

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

gcc/cp/ChangeLog:

PR c++/97597
* class.c (is_empty_base_ref): New.
(build_base_path): Add NOP_EXPR after offset.
* cp-tree.h (is_empty_base_ref): Declare it.
* call.c (unsafe_return_slot_p): Call it.

gcc/testsuite/ChangeLog:

PR c++/97597
* g++.dg/init/empty3.C: New test.
---
 gcc/cp/cp-tree.h   |  1 +
 gcc/cp/call.c  |  4 
 gcc/cp/class.c | 31 --
 gcc/testsuite/g++.dg/init/empty3.C | 18 +
 4 files changed, 52 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/init/empty3.C

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6cce9e2b407..fc6a7898475 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6484,6 +6484,7 @@ extern tree build_base_path   (enum 
tree_code, tree,
 extern tree convert_to_base(tree, tree, bool, bool,
 tsubst_flags_t);
 extern tree convert_to_base_statically (tree, tree);
+extern bool is_empty_base_ref  (tree);
 extern tree build_vtbl_ref (tree, tree);
 extern tree build_vfn_ref  (tree, tree);
 extern tree get_vtable_decl(tree, int);
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c2d62e582bf..65a4d73a7e0 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8426,6 +8426,10 @@ call_copy_ctor (tree a, tsubst_flags_t complain)
 bool
 unsafe_return_slot_p (tree t)
 {
+  /* Check empty bases separately, they don't have fields.  */
+  if (is_empty_base_ref (t))
+return true;
+
   STRIP_NOPS (t);
   if (TREE_CODE (t) == ADDR_EXPR)
 t = TREE_OPERAND (t, 0);
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index bc0d3d6bf86..fc5502aad98 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -494,8 +494,6 @@ build_base_path (enum tree_code code,
   if (want_pointer)
 target_type = ptr_target_type;
 
-  expr = build1 (NOP_EXPR, ptr_target_type, expr);
-
   if (!integer_zerop (offset))
 {
   offset = fold_convert (sizetype, offset);
@@ -506,6 +504,8 @@ build_base_path (enum tree_code code,
   else
 null_test = NULL;
 
+  expr = build1 (NOP_EXPR, ptr_target_type, expr);
+
  indout:
   if (!want_pointer)
 {
@@ -659,6 +659,33 @@ convert_to_base_statically (tree expr, tree base)
   return expr;
 }
 
+/* True IFF EXPR is a reference to an empty base class "subobject", as built in
+   convert_to_base_statically.  We look for the result of the fold_convert
+   call, a NOP_EXPR from one pointer type to another, where the target is an
+   empty base of the original type.  */
+
+bool
+is_empty_base_ref (tree expr)
+{
+  if (TREE_CODE (expr) == INDIRECT_REF)
+expr = TREE_OPERAND (expr, 0);
+  if (TREE_CODE (expr) != NOP_EXPR)
+return false;
+  tree type = TREE_TYPE (expr);
+  if (!POINTER_TYPE_P (type))
+return false;
+  type = TREE_TYPE (type);
+  if (!is_empty_class (type))
+return false;
+  STRIP_NOPS (expr);
+  tree fromtype = TREE_TYPE (expr);
+  if (!POINTER_TYPE_P (fromtype))
+return false;
+  fromtype = TREE_TYPE (fromtype);
+  return (CLASS_TYPE_P (fromtype)
+ && !same_type_ignoring_top_level_qualifiers_p (fromtype, type)
+ && DERIVED_FROM_P (type, fromtype));
+}
 
 tree
 build_vfield_ref (tree datum, tree type)
diff --git a/gcc/testsuite/g++.dg/init/empty3.C 
b/gcc/testsuite/g++.dg/init/empty3.C
new file mode 100644
index 000..510338b2a7e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/empty3.C
@@ -0,0 +1,18 @@
+// PR c++/97597
+
+struct pq {
+  pq (const pq &);
+};
+
+struct a9 {
+  operator pq () const;
+};
+
+struct zp : pq {
+  zp (const a9 &k3) : pq (k3) { }
+};
+
+int main()
+{
+  zp z = a9();
+}

base-commit: 0a541e746c71fe21eb72bae61a9ead541ed7e98d
-- 
2.27.0



Go patch committed: Nil-checked pointers and indexes can trap

2020-12-23 Thread Ian Lance Taylor via Gcc-patches
The Go frontend was treating indirections through pointers that had
been explicitly checked against nil and slice and string index
expressions as non-trapping memory references.  That is true for
ordinary Go programs, but it isn't true if the programs construct
their own memory addresses.  In particular it isn't true for the kinds
of programs that want to use runtime.SetPanicOnFault.  The effect of
this will be slightly larger binaries, due to additional exception
information, and perhaps slightly less optimization.  Bootstrapped and
ran Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
3224ee488de0b641cd553c25206ed31e9261be47
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index fbac942ad42..600d9769624 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-d238487d5c6e0c7f12c38305060fba8b7ec3605f
+8d49adead59b8103f3bfeebd53ee508eda5ee94a
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index adc1ebb4643..17b4cfd2c19 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -5334,7 +5334,6 @@ Unary_expression::do_get_backend(Translate_context* 
context)
   {
 go_assert(this->expr_->type()->points_to() != NULL);
 
-bool known_valid = false;
 Type* ptype = this->expr_->type()->points_to();
 Btype* pbtype = ptype->get_backend(gogo);
 switch (this->requires_nil_check(gogo))
@@ -5375,14 +5374,12 @@ Unary_expression::do_get_backend(Translate_context* 
context)
 compare,
 bcrash, ubexpr,
 loc);
-known_valid = true;
 break;
   }
 case NIL_CHECK_DEFAULT:
   go_unreachable();
   }
-ret = gogo->backend()->indirect_expression(pbtype, bexpr,
-   known_valid, loc);
+ret = gogo->backend()->indirect_expression(pbtype, bexpr, false, loc);
   }
   break;
 
@@ -13339,7 +13336,8 @@ 
Array_index_expression::do_get_backend(Translate_context* context)
 
  Type* ele_type = this->array_->type()->array_type()->element_type();
  Btype* ele_btype = ele_type->get_backend(gogo);
- ret = gogo->backend()->indirect_expression(ele_btype, ptr, true, loc);
+ ret = gogo->backend()->indirect_expression(ele_btype, ptr, false,
+loc);
}
   return ret;
 }
@@ -13679,7 +13677,7 @@ 
String_index_expression::do_get_backend(Translate_context* context)
 {
   ptr = gogo->backend()->pointer_offset_expression(ptr, bstart, loc);
   Btype* ubtype = Type::lookup_integer_type("uint8")->get_backend(gogo);
-  return gogo->backend()->indirect_expression(ubtype, ptr, true, loc);
+  return gogo->backend()->indirect_expression(ubtype, ptr, false, loc);
 }
 
   Expression* end = NULL;


Re: [pushed] c++: Fix constexpr array ICE [PR98332]

2020-12-23 Thread Jason Merrill via Gcc-patches

On 12/23/20 4:43 PM, Jakub Jelinek wrote:

On Wed, Dec 23, 2020 at 04:40:29PM -0500, Jason Merrill via Gcc-patches wrote:

diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C 
b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C
new file mode 100644
index 000..22d4c59f4f8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C
@@ -0,0 +1,5 @@
+// PR c++/98332
+// { dg-do compile { target c++11 } }
+
+struct S { int a = 2147483647 + 1; }; // { dg-warning "overflow" }


Wouldn't it be more portable to use __INT_MAX__ + 1 here, so that it
will work also on 16-bit int targets?


Good point, fixed.

Jason



Re: [pushed] c++: Fix constexpr array ICE [PR98332]

2020-12-23 Thread Jakub Jelinek via Gcc-patches
On Wed, Dec 23, 2020 at 04:40:29PM -0500, Jason Merrill via Gcc-patches wrote:
> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C 
> b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C
> new file mode 100644
> index 000..22d4c59f4f8
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C
> @@ -0,0 +1,5 @@
> +// PR c++/98332
> +// { dg-do compile { target c++11 } }
> +
> +struct S { int a = 2147483647 + 1; }; // { dg-warning "overflow" }

Wouldn't it be more portable to use __INT_MAX__ + 1 here, so that it
will work also on 16-bit int targets?

> +struct { S b[2][1][1][1]; } c;

Jakub



Re: [PATCH] c++, v2: Fix up floating point complex handling in build_zero_init_1 [PR98353]

2020-12-23 Thread Jason Merrill via Gcc-patches

On 12/23/20 1:59 AM, Jakub Jelinek wrote:

On Tue, Dec 22, 2020 at 09:56:03AM -0500, Jason Merrill via Gcc-patches wrote:

Not exactly sure why we just don't call build_zero_cst (type); for the > scalar 
types


I don't know either.  Want to test that?


The following passed bootstrap/regtested on x86_64-linux and i686-linux too.
And the function comment even confirms the behavior we need for
build_zero_init_1:
/* Build 0 constant of type TYPE.  This is used by constructor folding
and thus the constant should be represented in memory by
zero(es).  */
Ok for trunk?


OK.


2020-12-23  Jakub Jelinek  

PR c++/98353
* init.c (build_zero_init_1): Use build_zero_cst for SCALAR_TYPE_P
zero initializers.

--- gcc/cp/init.c.jj2020-12-09 09:03:38.270054654 +0100
+++ gcc/cp/init.c   2020-12-21 13:51:57.353332652 +0100
@@ -187,7 +187,7 @@ build_zero_init_1 (tree type, tree nelts
else if (NULLPTR_TYPE_P (type))
  init = build_int_cst (type, 0);
else if (SCALAR_TYPE_P (type))
-init = fold (convert (type, integer_zero_node));
+init = build_zero_cst (type);
else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type)))
  {
tree field;


Jakub





[pushed] c++: Fix constexpr array ICE [PR98332]

2020-12-23 Thread Jason Merrill via Gcc-patches
The element initializer was non-constant, so its CONSTRUCTOR element ended
up NULL, so unshare_constructor crashed trying to look at it.  This patch
fixes this in two places: First, by returning when we see a non-constant
initializer; second, by not crashing on NULL.

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

gcc/cp/ChangeLog:

PR c++/98332
* constexpr.c (unshare_constructor): Check for NULL.
(cxx_eval_vec_init_1): Always exit early if non-constant.

gcc/testsuite/ChangeLog:

PR c++/98332
* g++.dg/cpp0x/constexpr-overflow3.C: New test.
---
 gcc/cp/constexpr.c   | 4 ++--
 gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C | 5 +
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index b6f3e6e7a31..f7cc4132085 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1524,7 +1524,7 @@ unshare_constructor (tree t MEM_STAT_DECL)
   vec *v = CONSTRUCTOR_ELTS (n);
   constructor_elt *ce;
   for (HOST_WIDE_INT i = 0; vec_safe_iterate (v, i, &ce); ++i)
-   if (TREE_CODE (ce->value) == CONSTRUCTOR)
+   if (ce->value && TREE_CODE (ce->value) == CONSTRUCTOR)
  ptrs.safe_push (&ce->value);
 }
   return t;
@@ -4548,7 +4548,7 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree 
atype, tree init,
  eltinit = cxx_eval_constant_expression (&new_ctx, eltinit, lval,
  non_constant_p, overflow_p);
}
-  if (*non_constant_p && !ctx->quiet)
+  if (*non_constant_p)
break;
   if (new_ctx.ctor != ctx->ctor)
{
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C 
b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C
new file mode 100644
index 000..22d4c59f4f8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C
@@ -0,0 +1,5 @@
+// PR c++/98332
+// { dg-do compile { target c++11 } }
+
+struct S { int a = 2147483647 + 1; }; // { dg-warning "overflow" }
+struct { S b[2][1][1][1]; } c;

base-commit: 96de87b99bf8fd1c46df373bbcc2f7d76db716ad
-- 
2.27.0



Re: [PATCH] Fix ICE in warn_dealloc_offset

2020-12-23 Thread Martin Sebor via Gcc-patches

On 12/23/20 10:07 AM, Martin Liška wrote:

Hello.

I'm not fully familiar with code in warn_dealloc_offset, but I guess
the following can work.

Martin, what do you think?

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?


Thanks for looking into it!  I'm actually just testing the very same
fix.  It's taken me a while to come up with a non-LTO test case but
below is what I've got.

If you want to commit your fix go ahead, I'll just add the test case.
(FWIW, if you see OBJ_TYPE_REF there with LTO it's one possible trigger.
The test case below has a null pointer.)

Martin

typedef __SIZE_TYPE__ size_t;

void* (*pf) (size_t);

struct A;
struct B
{
  B ();

  void* operator new (size_t, A*);
  void operator delete (void*, A*);
};

void operator delete (void *, A*);

void B::operator delete (void*, A *p)
{
  void *q = pf (1);
  ::operator delete ((char*)q + 1, p);
}

void* f (A *p)
{
  return new (p) B;
}


Thanks,
Martin

gcc/ChangeLog:

 PR tree-optimization/98160
 * builtins.c (warn_dealloc_offset): Handle OBJ_TYPE_REF as
 def_stmt.
---
  gcc/builtins.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 28e5ab2..057a5b1a973 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -13410,7 +13410,7 @@ warn_dealloc_offset (location_t loc, tree exp, 
const access_ref &aref)

    if (is_gimple_call (def_stmt))
  {
    tree alloc_decl = gimple_call_fndecl (def_stmt);
-  if (!DECL_IS_OPERATOR_NEW_P (alloc_decl))
+  if (alloc_decl == NULL_TREE || !DECL_IS_OPERATOR_NEW_P 
(alloc_decl))

  return false;
  }
  }




[PATCH] Fix ICE in warn_dealloc_offset

2020-12-23 Thread Martin Liška

Hello.

I'm not fully familiar with code in warn_dealloc_offset, but I guess
the following can work.

Martin, what do you think?

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

PR tree-optimization/98160
* builtins.c (warn_dealloc_offset): Handle OBJ_TYPE_REF as
def_stmt.
---
 gcc/builtins.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 28e5ab2..057a5b1a973 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -13410,7 +13410,7 @@ warn_dealloc_offset (location_t loc, tree exp, const 
access_ref &aref)
  if (is_gimple_call (def_stmt))
{
  tree alloc_decl = gimple_call_fndecl (def_stmt);
- if (!DECL_IS_OPERATOR_NEW_P (alloc_decl))
+ if (alloc_decl == NULL_TREE || !DECL_IS_OPERATOR_NEW_P 
(alloc_decl))
return false;
}
}
--
2.29.2



Go patch committed: Remove references to slicecopy and slicestringcopy

2020-12-23 Thread Ian Lance Taylor via Gcc-patches
In the Go frontend, all calls to the runtime functions slicecopy and
slicestringcopy were removed in https://golang.org/cl/170005.  Remove
the remaining mentions.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
b26699c53b257d3354a4cfd3fc9174104f116154
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index e67aa3622fb..fbac942ad42 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-013a4ddcae2e8b840561c4411bab87f4f0f9ef42
+d238487d5c6e0c7f12c38305060fba8b7ec3605f
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/escape.cc b/gcc/go/gofrontend/escape.cc
index 8962f3f38d1..cf688740443 100644
--- a/gcc/go/gofrontend/escape.cc
+++ b/gcc/go/gofrontend/escape.cc
@@ -363,8 +363,6 @@ Node::op_format() const
  op << "append";
  break;
 
-   case Runtime::SLICECOPY:
-   case Runtime::SLICESTRINGCOPY:
case Runtime::TYPEDSLICECOPY:
  op << "copy";
  break;
diff --git a/gcc/go/gofrontend/runtime.def b/gcc/go/gofrontend/runtime.def
index 7ab94a3ffbc..ec01be0afe4 100644
--- a/gcc/go/gofrontend/runtime.def
+++ b/gcc/go/gofrontend/runtime.def
@@ -242,14 +242,6 @@ DEF_GO_RUNTIME(DEFERRETURN, "runtime.deferreturn", 
P1(BOOLPTR), R0())
 DEF_GO_RUNTIME(CLOSE, "runtime.closechan", P1(CHAN), R0())
 
 
-// Copy.
-DEF_GO_RUNTIME(SLICECOPY, "runtime.slicecopy",
-  P5(POINTER, INT, POINTER, INT, UINTPTR), R1(INT))
-
-// Copy from string.
-DEF_GO_RUNTIME(SLICESTRINGCOPY, "runtime.slicestringcopy",
-  P3(POINTER, INT, STRING), R1(INT))
-
 // Copy of value containing pointers.
 DEF_GO_RUNTIME(TYPEDSLICECOPY, "runtime.typedslicecopy",
   P5(TYPE, POINTER, INT, POINTER, INT), R1(INT))


[committed] d: Force TYPE_MODE of classes and non-POD structs as BLKmode (PR98427)

2020-12-23 Thread Iain Buclaw via Gcc-patches
Hi,

This patch forces the TYPE_MODE of non-POD types as BLKmode.  Without
this being forced, the optimizer could still make decisions that require
objects of the non-POD types to need a temporary, which would result in
an ICE during the expand to RTL passes.

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

Regards,
Iain.

---
gcc/d/ChangeLog:

PR d/98427
* types.cc (TypeVisitor::visit (TypeStruct *)): Set TYPE_MODE of all
non-trivial types as BLKmode.
(TypeVisitor::visit (TypeClass *)): Likewise.

gcc/testsuite/ChangeLog:

PR d/98427
* gdc.dg/pr98427.d: New test.
---
 gcc/d/types.cc | 10 --
 gcc/testsuite/gdc.dg/pr98427.d | 23 +++
 2 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr98427.d

diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index 94aa1f6b9b3..acb8c409526 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -964,7 +964,10 @@ public:
 if (!t->sym->isPOD ())
   {
for (tree tv = t->ctype; tv != NULL_TREE; tv = TYPE_NEXT_VARIANT (tv))
- TREE_ADDRESSABLE (tv) = 1;
+ {
+   TREE_ADDRESSABLE (tv) = 1;
+   SET_TYPE_MODE (tv, BLKmode);
+ }
   }
   }
 
@@ -999,7 +1002,10 @@ public:
 
 /* Classes only live in memory, so always set the TREE_ADDRESSABLE bit.  */
 for (tree tv = basetype; tv != NULL_TREE; tv = TYPE_NEXT_VARIANT (tv))
-  TREE_ADDRESSABLE (tv) = 1;
+  {
+   TREE_ADDRESSABLE (tv) = 1;
+   SET_TYPE_MODE (tv, BLKmode);
+  }
 
 /* Type is final, there are no derivations.  */
 if (t->sym->storage_class & STCfinal)
diff --git a/gcc/testsuite/gdc.dg/pr98427.d b/gcc/testsuite/gdc.dg/pr98427.d
new file mode 100644
index 000..225db8b8f2f
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr98427.d
@@ -0,0 +1,23 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98427
+// { dg-do compile }
+// { dg-options "-O2 -fno-inline" }
+
+@trusted memoizeExpr()
+{
+struct CodepointSet
+{
+struct CowArray
+{
+uint *ptr;
+}
+
+const CodepointSet binary(U)(U rhs)
+{
+return rhs;
+}
+
+CowArray array;
+}
+
+CodepointSet().binary(CodepointSet());
+}
-- 
2.27.0



libcody: Remove testsuite [PR 98318]

2020-12-23 Thread Nathan Sidwell
libcody's testsuite is not very portable, and is testing a host 
library, so will do weird things on cross compiling, I think.  Let's 
just drop it.


libcody/
* Makefile.in (LDFLAGS): Drop -L..
* tests/01-serialize/connect.cc: Delete.
* tests/01-serialize/decoder.cc: Delete.
* tests/01-serialize/encoder.cc: Delete.
* tests/02-comms/client-1.cc: Delete.
* tests/02-comms/pivot-1.cc: Delete.
* tests/02-comms/server-1.cc: Delete.
* tests/Makesub.in: Delete.
* tests/jouster: Delete.


--
Nathan Sidwell
diff --git c/libcody/Makefile.in w/libcody/Makefile.in
index a0722f9a385..6e38d51516f 100644
--- c/libcody/Makefile.in
+++ w/libcody/Makefile.in
@@ -100,7 +100,7 @@ endif
 CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
 
 # Linker options
-LDFLAGS := -L. @LDFLAGS@
+LDFLAGS := @LDFLAGS@
 LIBS := @LIBS@
 
 # Per-source & per-directory compile flags (warning: recursive)
diff --git c/libcody/tests/01-serialize/connect.cc w/libcody/tests/01-serialize/connect.cc
deleted file mode 100644
index 85277c844af..000
--- c/libcody/tests/01-serialize/connect.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-
-// Test client connection handshake
-// RUN: <
-
-using namespace Cody;
-
-int main (int, char *[])
-{
-  Client client (0, 1);
-
-  auto token = client.Connect ("TEST", "IDENT");
-
-  std::cerr << "Code:" << token.GetCode () << '\n';
-  std::cerr << "Version:" << token.GetInteger () << '\n';
-}
diff --git c/libcody/tests/01-serialize/decoder.cc w/libcody/tests/01-serialize/decoder.cc
deleted file mode 100644
index a3495d145da..000
--- c/libcody/tests/01-serialize/decoder.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// CODYlib		-*- mode:c++ -*-
-// Copyright (C) 2020 Nathan Sidwell, nat...@acm.org
-// License: Apache v2.0
-
-// RUN: <
-// C
-#include 
-
-using namespace Cody;
-
-int main (int, char *[])
-{
-  Detail::MessageBuffer reader;
-
-  reader.PrepareToRead ();
-  while (int e = reader.Read (0))
-if (e != EAGAIN && e != EINTR)
-  break;
-
-  std::vector words;
-  for (unsigned line = 0; !reader.IsAtEnd (); line++)
-{
-  if (int e = reader.Lex (words))
-	std::cerr << "error:" << strerror (e) << '\n';
-  for (unsigned ix = 0; ix != words.size (); ix++)
-	{
-	  auto &word = words[ix];
-
-	  std::cerr << "line:" << line << " word:" << ix
-		<< " '" << word << "'\n";
-	}
-}
-  return 0;
-}
diff --git c/libcody/tests/01-serialize/encoder.cc w/libcody/tests/01-serialize/encoder.cc
deleted file mode 100644
index c4cab6c630f..000
--- c/libcody/tests/01-serialize/encoder.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// CODYlib		-*- mode:c++ -*-
-// Copyright (C) 2020 Nathan Sidwell, nat...@acm.org
-// License: Apache v2.0
-
-// Test message encoding, both string quoting and continuation lines
-
-// RUN: $subdir$stem |& ezio $test
-// RUN-END:
-// The ¯ is utf8-encoded as c2 af
-// CHECK-NEXT: ^bob 'frob dob''\n¯\\'$
-// CHECK-NEXT: ^2 ;$
-// CHECK-NEXT: ^3$
-// CHECK-NEXT: $EOF
-
-// Cody
-#include "cody.hh"
-
-using namespace Cody;
-
-int main (int, char *[])
-{
-  Detail::MessageBuffer writer;
-
-  writer.BeginLine ();
-  writer.AppendWord ("bob");
-  writer.AppendWord ("frob dob", true);
-  writer.Append ("\n\xc2\xaf\\", true);
-  writer.EndLine ();
-
-  writer.PrepareToWrite ();
-  while (int err = writer.Write (2))
-if (err != EAGAIN && err != EINTR)
-  break;
-
-  writer.BeginLine ();
-  writer.Append ("2", true);
-  writer.EndLine ();
-  writer.BeginLine ();
-  writer.Append ("3", true);
-  writer.EndLine ();
-
-  writer.PrepareToWrite ();
-  while (int err = writer.Write (2))
-if (err != EAGAIN && err != EINTR)
-  break;
-
-  return 0;
-}
diff --git c/libcody/tests/02-comms/client-1.cc w/libcody/tests/02-comms/client-1.cc
deleted file mode 100644
index edff0ab4732..000
--- c/libcody/tests/02-comms/client-1.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-
-// Test client message round tripping
-/*
-  RUN: <
-
-using namespace Cody;
-
-int main (int, char *[])
-{
-  Client client (0, 1);
-
-  client.Cork ();
-  if (client.Connect ("TEST", "IDENT").GetCode () != Client::PC_CORKED)
-std::cerr << "Not corked!\n";
-  if (client.ModuleRepo ().GetCode () != Client::PC_CORKED)
-std::cerr << "Not corked!\n";
-  if (client.ModuleExport ("bar").GetCode () != Client::PC_CORKED)
-std::cerr << "Not corked!\n";
-  if (client.ModuleImport ("foo").GetCode () != Client::PC_CORKED)
-std::cerr << "Not corked!\n";
-  if (client.IncludeTranslate ("baz.frob").GetCode () != Client::PC_CORKED)
-std::cerr << "Not corked!\n";
-  if (client.IncludeTranslate ("./corge").GetCode () != Client::PC_CORKED)
-std::cerr << "Not corked!\n";
-  if (client.IncludeTranslate ("./quux").GetCode () != Client::PC_CORKED)
-std::cerr << "Not corked!\n";
-  if (client.ModuleCompiled ("bar").GetCode () != Client::PC_CORKED)
-std::cerr << "Not corked!\n";
-
-  auto result

[PATCH] i386: Fix __builtin_trunc with FE_DOWNWARD rounding direction [PR96793]

2020-12-23 Thread Uros Bizjak via Gcc-patches
[The same cure is needed for __builtin_trunc on 32bit SSE targets.]

x86_expand_truncdf_32 expander uses x86_sse_copysign_to_positive, which
is unable to change the sign from - to +.  When FE_DOWNWARD rounding
direction is in effect, the expanded sequence that involves subtraction
can trigger x - x = -0.0 special rule.  x86_sse_copysign_to_positive
fails to change the sign of the intermediate value, assumed to always
be positive, back to positive.

The patch adds one extra fabs that strips the sign from the intermediate
value when flag_rounding_math is in effect.

2020-12-23  Uroš Bizjak  

gcc/
PR target/96793
* config/i386/i386-expand.c (ix86_expand_truncdf_32):
Remove the sign of the intermediate value for flag_rounding_math.

gcc/testsuite/
PR target/96793
* gcc.target/i386/pr96793-1.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Pushed to mainline, will be backported to other release branches.

Uros.
diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index f838112783c..c856489c046 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -16534,7 +16534,7 @@ void
 ix86_expand_truncdf_32 (rtx operand0, rtx operand1)
 {
   machine_mode mode = GET_MODE (operand0);
-  rtx xa, mask, TWO52, one, res, smask, tmp;
+  rtx xa, xa2, TWO52, tmp, one, res, mask;
   rtx_code_label *label;
 
   /* C code for SSE variant we expand below.
@@ -16557,28 +16557,29 @@ ix86_expand_truncdf_32 (rtx operand0, rtx operand1)
   emit_move_insn (res, operand1);
 
   /* xa = abs (operand1) */
-  xa = ix86_expand_sse_fabs (res, &smask);
+  xa = ix86_expand_sse_fabs (res, &mask);
 
   /* if (!isless (xa, TWO52)) goto label; */
   label = ix86_expand_sse_compare_and_jump (UNLE, TWO52, xa, false);
 
-  /* res = xa + TWO52 - TWO52; */
-  tmp = expand_simple_binop (mode, PLUS, xa, TWO52, NULL_RTX, 0, OPTAB_DIRECT);
-  tmp = expand_simple_binop (mode, MINUS, tmp, TWO52, tmp, 0, OPTAB_DIRECT);
-  emit_move_insn (res, tmp);
+  /* xa2 = xa + TWO52 - TWO52; */
+  xa2 = expand_simple_binop (mode, PLUS, xa, TWO52, NULL_RTX, 0, OPTAB_DIRECT);
+  xa2 = expand_simple_binop (mode, MINUS, xa2, TWO52, xa2, 0, OPTAB_DIRECT);
 
   /* generate 1.0 */
   one = force_reg (mode, const_double_from_real_value (dconst1, mode));
 
-  /* Compensate: res = xa2 - (res > xa ? 1 : 0)  */
-  mask = ix86_expand_sse_compare_mask (UNGT, res, xa, false);
-  emit_insn (gen_rtx_SET (mask, gen_rtx_AND (mode, mask, one)));
+  /* Compensate: xa2 = xa2 - (xa2 > xa ? 1 : 0)  */
+  tmp = ix86_expand_sse_compare_mask (UNGT, xa2, xa, false);
+  emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, one, tmp)));
   tmp = expand_simple_binop (mode, MINUS,
-res, mask, NULL_RTX, 0, OPTAB_DIRECT);
-  emit_move_insn (res, tmp);
+xa2, tmp, NULL_RTX, 0, OPTAB_DIRECT);
+  /* Remove the sign with FE_DOWNWARD, where x - x = -0.0.  */
+  if (flag_rounding_math)
+tmp = ix86_expand_sse_fabs (tmp, NULL);
 
-  /* res = copysign (res, operand1) */
-  ix86_sse_copysign_to_positive (res, res, force_reg (mode, operand1), smask);
+  /* res = copysign (xa2, operand1) */
+  ix86_sse_copysign_to_positive (res, tmp, res, mask);
 
   emit_label (label);
   LABEL_NUSES (label) = 1;
diff --git a/gcc/testsuite/gcc.target/i386/pr96793-1.c 
b/gcc/testsuite/gcc.target/i386/pr96793-1.c
new file mode 100644
index 000..b205d39f63c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr96793-1.c
@@ -0,0 +1,28 @@
+/* PR target/96793 */
+/* { dg-do run { target sse2_runtime } } */
+/* { dg-require-effective-target fenv } */
+/* { dg-options "-O2 -frounding-math -msse2 -mno-sse4 -mfpmath=sse" } */
+
+#include 
+
+double
+__attribute__((noinline))
+test (double value)
+{
+  return __builtin_trunc (value);
+}
+
+int
+main ()
+{
+  double result;
+
+  fesetround (FE_DOWNWARD);
+
+  result = test (0.25);
+
+  if (__builtin_signbit (result) != 0)
+__builtin_abort ();
+
+  return 0;
+}


Re: [RFC] [avr] Toolchain Integration for Testsuite Execution (avr cc0 to mode_cc0 conversion)

2020-12-23 Thread abebeos via Gcc-patches
On Sun, 13 Dec 2020 at 20:14, abebeos 
wrote:

>
>
> On Fri, 11 Dec 2020 at 20:32, Jeff Law  wrote:
>
>>
>>
>> On 12/9/20 6:12 AM, abebeos via Gcc-patches wrote:
>> > Essence:
>> >
>> > I need a confirmation that the testsuite setup as presented in:
>> >
>> > https://github.com/abebeos/avr-gnu
>> >
>> > works fine.
>> >
>> > The problem with the avr target is that the testsuite cannot be run
>> easily,
>> > mainly because of the need for a special simulated-target setup, which
>> does
>> > not work for avr as documented. This led developers to a dead-end with
>> > their non-cc0-avr-backends (the non-cc0 backend is needed thus avr is
>> not
>> > dropped from gcc11).
>> >
>> > I integrated a toolchain/testsetup to be able to run the gcc testsuite
>> > against a simulated avr target.
>> >
>> > I then used this toolchain to test 2 different existent
>> > non-cc0-avr-backends (from pipcet and saaadhu, both github).
>> >
>> > The result is that saaadhu's backend seems to be working 100%. It has
>> > identical testsuite results with the existing (but deprecated)
>> cc0-backend,
>> > which means that it can be used "as-is" for inclusion in gcc11.
>> >
>> > Please note that I did this work in context of a bounty @ bountysouce,
>> more
>> > information within the issue:
>> >
>> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92729#c35
>> I haven't looked at the github repo.  But I do have a couple comments
>> here.
>>
>> First, the author of the changes (pipcet and saaadhu) need to have
>> copyright assignments on file with the FSF.  Otherwise we can not use
>> their work at all.
>>
>> Second, the work needs to be submitted for inclusion.  I don't recall
>> seeing an official submission from either of them to gcc-patches.
>>
>> I'm definitely curious about the testing setup and whether or not it can
>> be replicated into our Jenkins setup.
>
>
> Where can I find this Jenkins setup?
>

To close this: assuming " into our Jenkins setup" is some redhat internal
jenkins setup.


> It is my understanding there is
>> no newlib support for avr so I'm curious what you're using for a basic
>> runtime library.
>>
>> jeff
>>
>>


Re: [PATCH] Add pytest for a GCOV test-case

2020-12-23 Thread Martin Liška

On 12/22/20 6:49 PM, David Malcolm wrote:

On Tue, 2020-12-22 at 12:39 +0100, Martin Liška wrote:

Hello.

The patch adds a new test for an existing GCOV test-case. Newly
added run-gcov-pytest parses JSON format produced by GCOV and
runs pytest on it.

Patch can bootstrap on x86_64-linux-gnu and survives regression
tests.


At a high level, this patch calls out to Python 3, allowing for test
logic to be written in Python, rather than Tcl.  Are we doing this
anywhere else in our test suite?


No.


I'm in favor of this (I'm much more
comfortable in Python than in Tcl, I dread anytime I have to touch the
Tcl code).


Yes, that was my original motivation. I always suffer when I'm supposed
to come up with a test-case.



The test implicitly requires python3, and the 3rd party pytest module
installed within it.  What happens if these aren't installed?  (ideally
an UNSUPPORTED at the DejaGnu level, I think).


Right now, one will see the following in the .log file:

/usr/bin/python3: No module named pytest


I must confess that I don't know how to properly mark that as UNRESOLVED
in DejaGNU.



Some further comments inline below...


Ready to be installed?
Thanks,
Martin

gcc/testsuite/ChangeLog:

PR gcov-profile/98273
* lib/gcov.exp: Add run-gcov-pytest function which runs pytest.
* g++.dg/gcov/pr98273.C: New test.
* g++.dg/gcov/gcov.py: New test.
* g++.dg/gcov/test-pr98273.py: New test.
---
   gcc/testsuite/g++.dg/gcov/gcov.py | 10 
   gcc/testsuite/g++.dg/gcov/pr98273.C   | 24 +++
   gcc/testsuite/g++.dg/gcov/test-pr98273.py | 27
++
   gcc/testsuite/lib/gcov.exp| 28
+++
   4 files changed, 89 insertions(+)
   create mode 100644 gcc/testsuite/g++.dg/gcov/gcov.py
   create mode 100644 gcc/testsuite/g++.dg/gcov/pr98273.C
   create mode 100644 gcc/testsuite/g++.dg/gcov/test-pr98273.py

diff --git a/gcc/testsuite/g++.dg/gcov/gcov.py
b/gcc/testsuite/g++.dg/gcov/gcov.py
new file mode 100644
index 000..a8c4ea9ae71
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov.py
@@ -0,0 +1,10 @@
+import gzip
+import json
+import os
+
+
+def gcov_from_env():
+# return parsed JSON content a GCOV_PATH file
+json_filename = os.environ['GCOV_PATH'] + '.gcov.json.gz'
+json_data = gzip.open(json_filename).read()
+return json.loads(json_data)
diff --git a/gcc/testsuite/g++.dg/gcov/pr98273.C
b/gcc/testsuite/g++.dg/gcov/pr98273.C
new file mode 100644
index 000..bfa83cbe4d0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/pr98273.C
@@ -0,0 +1,24 @@
+/* PR gcov-profile/98273 */
+
+/* { dg-options "--coverage -std=c++11" } */
+/* { dg-do run { target native } } */
+
+int
+main ()
+{
+  int i = 42;
+  {
+auto f = [] () {
+  auto g = [] () {};
+  g ();
+  g ();
+};
+f ();
+  }
+  ++i;
+  ++i;
+  ++i;
+  return 45 - i;
+}
+
+/* { dg-final { run-gcov-pytest pr98273.C "test-pr98273.py" } } */
diff --git a/gcc/testsuite/g++.dg/gcov/test-pr98273.py
b/gcc/testsuite/g++.dg/gcov/test-pr98273.py
new file mode 100644
index 000..6cb39d10c1e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/test-pr98273.py


I had an idea, not sure if a good one: if all of the test logic is
moved from the .C file to a python script, then perhaps the script
should be the name of the .C file with a .py suffix i.e. here it could
be "pr98273.C.py"


That does not work:
___
 ERROR collecting gcc/testsuite/g++.dg/gcov/pr98273.C.py 

ImportError while importing test module 
'/home/marxin/Programming/gcc/gcc/testsuite/g++.dg/gcov/pr98273.C.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named 'pr98273'
===
 short test summary info 

ERROR gcc/testsuite/g++.dg/gcov/pr98273.C.py

 Interrupted: 1 error during collection 

===
 1 error in 0.08s 
===



Or would there be cases where d

c++tools: Fix PIE [PR 98324]

2020-12-23 Thread Nathan Sidwell

Matthias has confirmed this fixes the problem.  pushing to trunk

This adds --enable-default-pie support to c++tools, so that the sample 
server is build -fPIE if requested.


PR bootstrap/98324
c++tools/
* Makefile.in: Add FLAGPIE.
* configure.ac: Add --enable-default-pie support.
* configure: Rebuilt.

--
Nathan Sidwell
diff --git i/c++tools/Makefile.in w/c++tools/Makefile.in
index 7dc67ad9e06..590a856af90 100644
--- i/c++tools/Makefile.in
+++ w/c++tools/Makefile.in
@@ -28,7 +28,9 @@ AUTOCONF := @AUTOCONF@
 AUTOHEADER := @AUTOHEADER@
 CXX := @CXX@
 CXXFLAGS := @CXXFLAGS@
-CXXOPTS := $(CXXFLAGS) -fno-exceptions -fno-rtti
+PIEFLAG := @PIEFLAG@
+CXXOPTS := $(CXXFLAGS) $(PIEFLAG) -fno-exceptions -fno-rtti
+LDFLAGS := @LDFLAGS@
 exeext := @EXEEXT@
 LIBIBERTY := ../libiberty/libiberty.a
 VERSION.O := ../gcc/version.o
@@ -88,7 +90,7 @@ MAPPER.O := server.o resolver.o
 CODYLIB = ../libcody/libcody.a
 CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I.
 g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
-	+$(CXX) $(LDFLAGS) -o $@ $^ $(VERSION.O) $(LIBIBERTY)
+	+$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(VERSION.O) $(LIBIBERTY)
 
 # copy to gcc dir so tests there can run
 all::../gcc/g++-mapper-server$(exeext)
diff --git i/c++tools/configure w/c++tools/configure
index e32558e936a..89441f50d1d 100755
--- i/c++tools/configure
+++ w/c++tools/configure
@@ -629,6 +629,7 @@ CPP
 ac_ct_CC
 CFLAGS
 CC
+PIEFLAG
 MAINTAINER
 CXX_AUX_TOOLS
 AUTOHEADER
@@ -699,6 +700,7 @@ ac_user_opts='
 enable_option_checking
 enable_c___tools
 enable_maintainer_mode
+enable_default_pie
 with_gcc_major_version_only
 '
   ac_precious_vars='build_alias
@@ -1329,6 +1331,7 @@ Optional Features:
   --enable-maintainer-mode
   enable maintainer mode. Add rules to rebuild
   configurey bits
+  --enable-default-pieenable Position Independent Executable as default
 
 Optional Packages:
   --with-PACKAGE[=ARG]use PACKAGE [ARG=yes]
@@ -2939,6 +2942,16 @@ $as_echo "$maintainer_mode" >&6; }
 test "$maintainer_mode" = yes && MAINTAINER=yes
 
 
+# Check whether --enable-default-pie was given.
+# Check whether --enable-default-pie was given.
+if test "${enable_default_pie+set}" = set; then :
+  enableval=$enable_default_pie; PIEFLAG=-fPIE
+else
+  PIEFLAG=
+fi
+
+
+
 # Check if O_CLOEXEC is defined by fcntl
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
diff --git i/c++tools/configure.ac w/c++tools/configure.ac
index 21b3a0668e6..1100dc24cd1 100644
--- i/c++tools/configure.ac
+++ w/c++tools/configure.ac
@@ -66,6 +66,13 @@ AC_MSG_RESULT([$maintainer_mode])
 test "$maintainer_mode" = yes && MAINTAINER=yes
 AC_SUBST(MAINTAINER)
 
+# Check whether --enable-default-pie was given.
+AC_ARG_ENABLE(default-pie,
+[AS_HELP_STRING([--enable-default-pie],
+		  [enable Position Independent Executable as default])],
+[PIEFLAG=-fPIE], [PIEFLAG=])
+AC_SUBST([PIEFLAG])
+
 # Check if O_CLOEXEC is defined by fcntl
 AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[


Re: [PATCH][DOC] Document my changes in GCC 11.

2020-12-23 Thread Martin Liška

On 12/22/20 4:23 PM, Jonathan Wakely wrote:

can be transformed into a switch statement can be transformed into a
switch statement


Good point! I'm going to install the patch with the fix of this.

Thanks,
Martin



[PATCH, OpenMP 5.0] Target mapping C++ members inside member functions

2020-12-23 Thread Chung-Lin Tang

Hi Jakub,
this patch is to fix some of the problems with target mapping when inside
C++ member functions:

1. Allow deref '->' in map clauses.
2. Allow this[X] in map clauses.
3. Create map(this->member) from map(member), when encountering member's 
FIELD_DECL.

This actually may not be the last related patch, since this patch is only for 
C++,
while the deref feature parity probably is also needed in C. Also the convention
required "map(struct:) map()..." sequence still needs further 
middle-end
gimplify modifications to generate. However this is already useful for compiling
some programs, and enter/exit data usage.

Tested C++ and libgomp without regressions, is this okay? Probably will need to 
wait
till stage1 to commit.

Thanks,
Chung-Lin

2020-12-23  Chung-Lin Tang  

gcc/cp/
* parser.c (cp_parser_omp_clause_map): Adjust call to
cp_parser_omp_var_list_no_open to set 'allow_deref' argument to true.
* semantics.c (handle_omp_array_sections_1): Add handling to create
'this->member' from 'member' FIELD_DECL.
(finish_omp_clauses): Likewise. Adjust to allow 'this[]' in OpenMP
map clauses.

gcc/testsuite/
* g++.dg/gomp/target-3.C: New test.
* g++.dg/gomp/this-2.C: Adjust testcase.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7ea8c28830e..1d5a508dd71 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -37720,7 +37720,7 @@ cp_parser_omp_clause_map (cp_parser *parser, tree list)
 }
 
   nlist = cp_parser_omp_var_list_no_open (parser, OMP_CLAUSE_MAP, list,
- NULL);
+ NULL, true);
 
   for (c = nlist; c != list; c = OMP_CLAUSE_CHAIN (c))
 OMP_CLAUSE_SET_MAP_KIND (c, kind);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 92e32c8e0ad..d21b58df954 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -4808,6 +4808,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec 
&types,
   if (REFERENCE_REF_P (t)
  && TREE_CODE (TREE_OPERAND (t, 0)) == COMPONENT_REF)
t = TREE_OPERAND (t, 0);
+  if ((ort == C_ORT_ACC || ort == C_ORT_OMP)
+ && TREE_CODE (t) == FIELD_DECL)
+   t = finish_non_static_data_member (t, NULL_TREE, NULL_TREE);
   ret = t;
   if (TREE_CODE (t) == COMPONENT_REF
  && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
@@ -4833,8 +4836,12 @@ handle_omp_array_sections_1 (tree c, tree t, vec 
&types,
  return error_mark_node;
}
  t = TREE_OPERAND (t, 0);
- if (ort == C_ORT_ACC && TREE_CODE (t) == INDIRECT_REF)
-   t = TREE_OPERAND (t, 0);
+ if ((ort == C_ORT_ACC || ort == C_ORT_OMP)
+ && TREE_CODE (t) == INDIRECT_REF)
+   {
+ t = TREE_OPERAND (t, 0);
+ STRIP_NOPS (t);
+   }
}
  if (REFERENCE_REF_P (t))
t = TREE_OPERAND (t, 0);
@@ -4854,6 +4861,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec 
&types,
  return error_mark_node;
}
   else if (ort == C_ORT_OMP
+  && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
+  && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TO
+  && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FROM
   && TREE_CODE (t) == PARM_DECL
   && DECL_ARTIFICIAL (t)
   && DECL_NAME (t) == this_identifier)
@@ -7441,6 +7451,11 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type 
ort)
t = TREE_OPERAND (t, 0);
  if (REFERENCE_REF_P (t))
t = TREE_OPERAND (t, 0);
+ if (TREE_CODE (t) == INDIRECT_REF)
+   {
+ t = TREE_OPERAND (t, 0);
+ STRIP_NOPS (t);
+   }
  if (bitmap_bit_p (&map_field_head, DECL_UID (t)))
break;
  if (bitmap_bit_p (&map_head, DECL_UID (t)))
@@ -7555,6 +7570,14 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type 
ort)
goto handle_map_references;
}
}
+ if ((ort == C_ORT_ACC || ort == C_ORT_OMP)
+ && !processing_template_decl
+ && TREE_CODE (t) == FIELD_DECL)
+   {
+ OMP_CLAUSE_DECL (c) = finish_non_static_data_member (t, NULL_TREE,
+  NULL_TREE);
+ break;
+   }
  if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
{
  if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
@@ -7581,7 +7604,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type 
ort)
omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
  remove = true;
}
- else if (ort != C_ORT_ACC && t == current_class_ptr)
+ else if (ort != C_

Re: Account for VxWorks headers in libstdc++ test on names

2020-12-23 Thread Jonathan Wakely via Gcc-patches
On Tue, 22 Dec 2020, 21:39 Alexandre Oliva,  wrote:

>
> Undefine various macros unexpectedly defined by VxWorks headers.
>
> Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
> Ok to install?
>

OK, thanks.



>
> from Olivier Hainque 
> for  libstdc++-v3/ChangeLog
>
> * testsuite/17_intro/names.cc: Account for VxWorks headers.
> ---
>  libstdc++-v3/testsuite/17_intro/names.cc |   41
> ++
>  1 file changed, 41 insertions(+)
>
> diff --git a/libstdc++-v3/testsuite/17_intro/names.cc
> b/libstdc++-v3/testsuite/17_intro/names.cc
> index 2c8bfff26e1ca..4760a9efd7991 100644
> --- a/libstdc++-v3/testsuite/17_intro/names.cc
> +++ b/libstdc++-v3/testsuite/17_intro/names.cc
> @@ -211,4 +211,45 @@
>  #undef ptr
>  #endif
>
> +#ifdef __VXWORKS__
> +
> +#include <_vxworks-versions.h>
> +
> +// Some VxWorks 6 or 7 headers are using those.
> +
> +// private/objLibP.h
> +#undef u
> +
> +// arch/ppc/ffs/ArchLib.h
> +#undef i
> +#undef j
> +
> +// math.h
> +#undef x
> +#undef y
> +
> +// stdio.h
> +#undef ptr
> +
> +// VxWorks >= 7 specificities
> +
> +#if _VXWORKS_MAJOR_GE(7)
> +
> +// regs.h regs structure has a field 'r'
> +#undef r
> +
> +#ifndef __RTP__
> +// in bootLib.h, bootParamCheck has parameters x, a-f
> +#undef a
> +#undef b
> +#undef c
> +#undef d
> +#undef e
> +#undef f
> +#endif // __RTP__
> +
> +#endif // VxWorks Major >= 7
> +
> +#endif // __VXWORKS__
> +
>  #include 
>
>
> --
> Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
>Free Software Activist GNU Toolchain Engineer
> Vim, Vi, Voltei pro Emacs -- GNUlius Caesar
>


[C PATCH] [testsuite] bogus warning [P98029]

2020-12-23 Thread Uecker, Martin


With the fix to PR98047 "C: Drop qualifiers of assignment expressions." 
also the new incorrect warning for assignment of certain volatile expressions
introduced by dropping qualifiers in lvalue conversion (PR97702)
disappeared [P98029]. This patch only adds a test case.

-- Martin


C: Add test for incorrect warning for assignment of certain volatile
expressions fixed by commit 58a45ce [PR98029]

2020-12-12  Martin Uecker  

gcc/testsuite/
 PR c/98029
 * gcc.dg/pr98029.c: New test.   


diff --git a/gcc/testsuite/gcc.dg/pr98029.c b/gcc/testsuite/gcc.dg/pr98029.c
new file mode 100644
index 000..148f23ce5e0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr98029.c
@@ -0,0 +1,21 @@
+/* pr98029 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused" } */
+
+double f2 (void)
+{
+   volatile double d;
+   int i;
+
+   for (d = 2.0, i = 0; i < 5; i++, d *= d) /* { dg-bogus "right-hand 
operand of comma
expression has no effect" } */
+   ;
+
+   return d;
+}
+
+int g(void)
+{
+   volatile int x;
+   (x = 1, (void)1); /* { dg-bogus "right-hand operand of comma expression 
has no effect" } */
+   return x;
+}