Re: [PATCH v2 1/2] RISC-V: Accept version, supervisor ext and more than one NSE for -march.

2019-03-17 Thread Andreas Schwab
FAIL: gcc.target/riscv/arch-1.c  (test for errors, line )
FAIL: gcc.target/riscv/arch-1.c (test for excess errors)
Excess errors:
cc1: error: '-march=rv32I': first ISA subset must be `e', `i' or `g'

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [patch, fortran] Fix PR 88008, ICE on invalid

2019-03-17 Thread Dominique d'Humières
Hi Thomas,

The patch looks good to me, with one nit:

+  gfc_error ("Error in component call at %L",

and

  call x%z%g()  ! { dg-error "Error in typebound call" }

doesn’t look right.

Thanks for the patch.

Dominique

Re: [patch, fortran] Fix PR 88008, ICE on invalid

2019-03-17 Thread Thomas Koenig

Hi Domoinique,


+  gfc_error ("Error in component call at %L",

and

   call x%z%g()  ! { dg-error "Error in typebound call" }


Corrected.

If there isn't anything else, I'll commit tonight (as three
quarters obvious) to keep down the number of concurrent patches
in my tree :-)

Regards

Thomas


QWn提%%供%%税%%栗%dT

2019-03-17 Thread 李老师
gcc-patches@gcc.gnu.org
+
黄削
 
可  办 税 票,认 证 后 付  歀。
  详   电:李 生,136—6075— 4190,
   业   q:157— 533— 2698
---


[patch, fortran] Fix PR 68009, wrong prototype in runtime_error

2019-03-17 Thread Thomas Koenig

Hello world,

this fixes a 7/8/9 regression. The problem is that front-end inlining
of matmul could generate calls to _gfortran_runtime_error which were
called as non-variadic.  This fixes the problem by setting the
backend_decl on the resovled symbol, so it always uses the right one.

Putting it into the resolution stage seems a bit strange, but I tried
several other methods such as putting it into the global symbol table,
and nothing else I tried worked.

You can check on x86_64 if the patch works by doing

$ cat nn.f90
module x
contains
  subroutine mm(a,b,c)
real, dimension(:) :: a, c
real, dimension(:,:) :: b
c = matmul(a,b)
  end subroutine mm
end module x

$ gfortran -S -O -fcheck=bounds nn.f90

and then looking for code snippets like

movl$89, %ecx
movq%rdi, %rdx
movl$.LC0, %edi
movl$0, %eax
call_gfortran_runtime_error

where setting %eax to zero indicates that we are indeed using
varargs, because %eax contains the number of float arguments,
which is zero.

No test case, because there is not really a good way to check for this.

So, OK for trunk?

Regards

Thomas

2019-03-17  Thomas Koenig  

PR fortran/68009
* iresolve.c: Include trans.h.
(gfc_resolve_fe_runtine_error): Set backend_decl on
resolved_sym.
Index: iresolve.c
===
--- iresolve.c	(Revision 269624)
+++ iresolve.c	(Arbeitskopie)
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "intrinsic.h"
 #include "constructor.h"
 #include "arith.h"
+#include "trans.h"
 
 /* Given printf-like arguments, return a stable version of the result string.
 
@@ -2495,6 +2496,10 @@ gfc_resolve_fe_runtime_error (gfc_code *c)
 a->name = "%VAL";
 
   c->resolved_sym = gfc_get_intrinsic_sub_symbol (name);
+  /* We set the backend_decl here because runtime_error is a
+ variadic function and we would use the wrong calling
+ convention otherwise.  */
+  c->resolved_sym->backend_decl = gfor_fndecl_runtime_error;
 }
 
 void


Ping [PATCH] [MinGW] Set __USE_MINGW_ACCESS for C++ as well

2019-03-17 Thread Johannes Pfau

Am 03.03.19 um 11:41 schrieb Johannes Pfau:

We set __USE_MINGW_ACCESS for windows hosts to use MinGWs wrapper
for the access function. The wrapper ensures that access behaves
in the expected way (e.g. for special files, such as nul).
However, we now compile most sources with the C++ compiler and
the __USE_MINGW_ACCESS in CFLAGS is not used there. This causes
GCCs build against newer msvcrt versions with incompatible
access implementations to fail. This patch adds the flag to the
CXXFLAGS for all bootstrap stages. Bootstrapped on
x86_64-mingw64-seh.

config/ChangeLog:

2019-03-02  Johannes Pfau  

* mh-mingw: Also set __USE_MINGW_ACCESS flag for C++ code.

---
  config/mh-mingw | 5 +
  1 file changed, 5 insertions(+)

diff --git a/config/mh-mingw b/config/mh-mingw
index bc1d27477d0..a795096f038 100644
--- a/config/mh-mingw
+++ b/config/mh-mingw
@@ -2,6 +2,11 @@
  # Vista (see PR33281 for details).
  BOOT_CFLAGS += -D__USE_MINGW_ACCESS -Wno-pedantic-ms-format
  CFLAGS += -D__USE_MINGW_ACCESS
+STAGE1_CXXFLAGS += -D__USE_MINGW_ACCESS
+STAGE2_CXXFLAGS += -D__USE_MINGW_ACCESS
+STAGE3_CXXFLAGS += -D__USE_MINGW_ACCESS
+STAGE4_CXXFLAGS += -D__USE_MINGW_ACCESS
+
  # Increase stack limit to a figure based on the Linux default, with 4MB added
  # as GCC turns out to need that much more to pass all the limits-* tests.
  LDFLAGS += -Wl,--stack,12582912



Ping. Would be great to get this into GCC as 
https://github.com/niXman/mingw-builds/ now has a --with-default-msvcrt= 
which simplifies building MinGW for a specific MSVC version a lot, but 
at least the bootstrap builds are currently blocked by this issue.



Best regards,

Johannes



New Swedish PO file for 'gcc' (version 9.1-b20190203)

2019-03-17 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the Swedish team of translators.  The file is available at:

https://translationproject.org/latest/gcc/sv.po

(This file, 'gcc-9.1-b20190203.sv.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

https://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

https://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




[RFA patch, Fortran] PR60144 - Misleading error message when missing "then" after "if" and "else if"

2019-03-17 Thread Dominique d'Humières
With the proposed patch

2 | if (.TRUE.)  
  |  1
Error: Cannot assign to a named constant at (1)
3 | else if (.FALSE.) 
  |   1
Error: Unexpected junk after ELSE statement at (1)

is changed to

2 | if (.TRUE.)  
  |  1
Error: Syntax error in IF-clause after (1)
3 | else if (.FALSE.) 
  | 1
Error: Missing THEN in ELSE IF statement after (1)

The first change is done by removing the block

/* The gfc_match_assignment() above may have returned a MATCH_NO
…
   return MATCH_ERROR;
}

This block has been introduced at revision r116570 to handle assignment to a 
named constant as in the test
simpleif_2.f90, but this is now handled elsewhere.

The second change is done by some more parsing of the ELSE IF statement.

While at these changes, I have also made the error

3 | if (.FALSE. then c="!" 
  |1
Error: Missing ')' in statement at or before (1)

to be less surprising

3 | if (.FALSE. then c="!" 
  |   1
Error: Missing ')' in statement at or before (1)

Also

7 | if a=b ! 
  |1
Error: Unclassifiable statement at (1)

changed to

7 | if a=b ! 
  |   1
Error: Missing '(' in IF-expression at (1)

which avoids the error to be deleted if it appears after other ones.

Bootstrapped and tested on darwin. Is it OK for trunk?

TIA

Dominique

2019-03-17  Dominique d'Humieres  

PR fortran/60144
* match.c (gfc_match_parens): Change the location for missing ')'.
(gfc_match_if): Detect a missing '('. Remove the spurious named
constant error. Change the wording of some errors.
(gfc_match_else): Change the wording of an error.
(gfc_match_elseif): Detect a missing '('. Improve the matching
process to get a better syntax analysis.

2019-03-17  Dominique d'Humieres  

PR fortran/60144
* gfortran.dg/block_name_2.f90: Adjust dg-error.
* gfortran.dg/dec_type_print_3.f90.f90: Likewise
* gfortran.dg/pr60144.f90: New test. 



patch-60144
Description: Binary data


Re: [wwwdocs] add gcc 9 changes

2019-03-17 Thread Sandra Loosemore

On 3/4/19 5:28 PM, Martin Sebor wrote:

Attached is a patch with (mostly) my changes for GCC 9.  To make
things easier to find I grouped related changes together within
the sections I changed.  I put warnings under the same bullet,
built-ins, and attributes.


I have a few nit-picky comments...

s/command line option/command-line option/g
s/command line utilitly/command-line utility/  (typo, not just hyphen)
s/red-zones/red zones/g

Please try to reformat this to avoid lines longer than 80 characters, 
except where it's unavoidable in  markup.


-Sandra


[committed] Fix test failures that require alias support on hppa*-*-hpux*

2019-03-17 Thread John David Anglin
Committed to trunk.

Dave
-- 
John David Anglin  dave.ang...@bell.net

2019-03-17  John David Anglin  

PR testsuite/89666
* c-c++-common/builtin-has-attribute-3.c: Define SKIP_ALIAS on
hppa*-*-hpux*.
* gcc.dg/attr-copy.c: Require alias support.
* gcc.dg/ipa/ipa-icf-39.c: Likewise.

Index: c-c++-common/builtin-has-attribute-3.c
===
--- c-c++-common/builtin-has-attribute-3.c  (revision 269717)
+++ c-c++-common/builtin-has-attribute-3.c  (working copy)
@@ -2,7 +2,7 @@
{ dg-do compile }
{ dg-options "-Wall -ftrack-macro-expansion=0" }
{ dg-options "-Wall -Wno-narrowing -Wno-unused-local-typedefs 
-ftrack-macro-expansion=0" { target c++ } }
-   { dg-additional-options "-DSKIP_ALIAS" { target *-*-darwin* } }
+   { dg-additional-options "-DSKIP_ALIAS" { target *-*-darwin* hppa*-*-hpux* } 
}
 */

 #define ATTR(...) __attribute__ ((__VA_ARGS__))
Index: gcc.dg/attr-copy.c
===
--- gcc.dg/attr-copy.c  (revision 269717)
+++ gcc.dg/attr-copy.c  (working copy)
@@ -1,6 +1,7 @@
 /* PR middle-end/81824 - Warn for missing attributes with function aliases
Exercise error handling for attribute copy.
{ dg-do compile }
+   { dg-require-alias "" }
{ dg-options "-O2 -Wall" } */

 #define ATTR(list)   __attribute__ (list)
Index: gcc.dg/ipa/ipa-icf-39.c
===
--- gcc.dg/ipa/ipa-icf-39.c (revision 269717)
+++ gcc.dg/ipa/ipa-icf-39.c (working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-alias "" } */
 /* { dg-options "-O2 -fdump-ipa-icf -fmerge-all-constants 
-fdbg-cnt=merged_ipa_icf:1:3"  } */
 /* { dg-prune-output "dbg_cnt 'merged_ipa_icf' set to 1-3" } */



[committed] Fix tests that need c99 complex support

2019-03-17 Thread John David Anglin
This patch fixes three tests that fail on hppa*-*-hpux* due to the lack of
c99 complex support.

Committed to trunk.

Dave
-- 
John David Anglin  dave.ang...@bell.net

2019-03-17  John David Anglin  

* gcc.dg/pr88074.c: Require c99_runtime.
* gcc.dg/warn-abs-1.c: Likewise.
* gfortran.dg/ISO_Fortran_binding_1.f90: Likewise.

Index: gcc.dg/pr88074.c
===
--- gcc.dg/pr88074.c(revision 269717)
+++ gcc.dg/pr88074.c(working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target c99_runtime } } */
 /* { dg-options "-O" } */

 #include 
Index: gcc.dg/warn-abs-1.c
===
--- gcc.dg/warn-abs-1.c (revision 269717)
+++ gcc.dg/warn-abs-1.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target c99_runtime } } */
 /* { dg-options "-Wabsolute-value" } */

 #include 
Index: gfortran.dg/ISO_Fortran_binding_1.f90
===
--- gfortran.dg/ISO_Fortran_binding_1.f90   (revision 269717)
+++ gfortran.dg/ISO_Fortran_binding_1.f90   (working copy)
@@ -1,4 +1,4 @@
-! { dg-do run }
+! { dg-do run { target c99_runtime } }
 ! { dg-additional-sources ISO_Fortran_binding_1.c }
 !
 ! Test F2008 18.5: ISO_Fortran_binding.h functions.


[committed] Fix failure of two tests requiring visibility support on 32-bit hppa*-*-hpux*

2019-03-17 Thread John David Anglin
Committed to trunk.

Dave
-- 
John David Anglin  dave.ang...@bell.net

2013-03-17  John David Anglin  

* gfortran.dg/pointer_init_10.f90: Require visibility support.
* gfortran.dg/temporary_3.f90: Likewise.

Index: gfortran.dg/pointer_init_10.f90
===
--- gfortran.dg/pointer_init_10.f90 (revision 269717)
+++ gfortran.dg/pointer_init_10.f90 (working copy)
@@ -1,4 +1,5 @@
 ! { dg-do run }
+! { dg-require-visibility "" }
 !
 ! PR 84504: [F08] procedure pointer variables cannot be initialized with 
functions returning pointers
 !
Index: gfortran.dg/temporary_3.f90
===
--- gfortran.dg/temporary_3.f90 (revision 269717)
+++ gfortran.dg/temporary_3.f90 (working copy)
@@ -1,4 +1,5 @@
 ! { dg-do run }
+! { dg-require-visibility "" }
 !
 ! Tests the fix for PR68846 in which compiler generated temporaries were
 ! receiving the attributes of dummy arguments. This test is the original.


[committed] Fix another test needing large alignment on hppa*-*-hpux*

2019-03-17 Thread John David Anglin
Committed to trunk.

Dave
-- 
John David Anglin  dave.ang...@bell.net

2019-03-03-17  John David Anglin  

* gcc.dg/compat/pr83487-1_x.c: Use -fno-common option on hppa*-*-hpux*.
* gcc.dg/compat/pr83487-1_y.c: Likewise.

Index: gcc.dg/compat/pr83487-1_x.c
===
--- gcc.dg/compat/pr83487-1_x.c (revision 269717)
+++ gcc.dg/compat/pr83487-1_x.c (working copy)
@@ -1,3 +1,4 @@
+/* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */
 #include "pr83487-1.h"

 extern
Index: gcc.dg/compat/pr83487-1_y.c
===
--- gcc.dg/compat/pr83487-1_y.c (revision 269717)
+++ gcc.dg/compat/pr83487-1_y.c (working copy)
@@ -1,3 +1,4 @@
+/* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */
 #include "pr83487-1.h"

 struct A a;


[C++ PATCH] PR c++/89571 - ICE with ill-formed noexcept on constructor.

2019-03-17 Thread Jason Merrill
Earlier changes to defer instantiating a defaulted noexcept-specifier that
depends on yet-unparsed default member initializers broke this testcase,
where instantiation fails for another reason.  In this case there's no
reason to defer and try again later, so let's not.

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

* pt.c (maybe_instantiate_noexcept): Only return false if defaulted.
(regenerate_decl_from_template): Use it for noexcept-specs.
---
 gcc/cp/pt.c | 34 +++--
 gcc/testsuite/g++.dg/cpp0x/noexcept36.C | 22 
 gcc/cp/ChangeLog|  6 +
 3 files changed, 54 insertions(+), 8 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept36.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2ab6e273c3a..dc5c24c47a7 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -23991,12 +23991,18 @@ regenerate_decl_from_template (tree decl, tree tmpl, 
tree args)
   if (args_depth > parms_depth)
args = get_innermost_template_args (args, parms_depth);
 
-  specs = tsubst_exception_specification (TREE_TYPE (code_pattern),
- args, tf_error, NULL_TREE,
- /*defer_ok*/false);
-  if (specs && specs != error_mark_node)
-   TREE_TYPE (decl) = build_exception_variant (TREE_TYPE (decl),
-   specs);
+  /* Instantiate a dynamic exception-specification.  noexcept will be
+handled below.  */
+  if (tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (code_pattern)))
+   if (TREE_VALUE (raises))
+ {
+   specs = tsubst_exception_specification (TREE_TYPE (code_pattern),
+   args, tf_error, NULL_TREE,
+   /*defer_ok*/false);
+   if (specs && specs != error_mark_node)
+ TREE_TYPE (decl) = build_exception_variant (TREE_TYPE (decl),
+ specs);
+ }
 
   /* Merge parameter declarations.  */
   decl_parm = skip_artificial_parms_for (decl,
@@ -24062,6 +24068,8 @@ regenerate_decl_from_template (tree decl, tree tmpl, 
tree args)
   if (DECL_DECLARED_INLINE_P (code_pattern)
  && !DECL_DECLARED_INLINE_P (decl))
DECL_DECLARED_INLINE_P (decl) = 1;
+
+  maybe_instantiate_noexcept (decl, tf_error);
 }
   else if (VAR_P (decl))
 {
@@ -24187,7 +24195,13 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t 
complain)
   static hash_set* fns = new hash_set;
   bool added = false;
   if (DEFERRED_NOEXCEPT_PATTERN (noex) == NULL_TREE)
-   spec = get_defaulted_eh_spec (fn, complain);
+   {
+ spec = get_defaulted_eh_spec (fn, complain);
+ if (spec == error_mark_node)
+   /* This might have failed because of an unparsed DMI, so
+  let's try again later.  */
+   return false;
+   }
   else if (!(added = !fns->add (fn)))
{
  /* If hash_set::add returns true, the element was already there.  */
@@ -24247,7 +24261,11 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t 
complain)
fns->remove (fn);
 
   if (spec == error_mark_node)
-   return false;
+   {
+ /* This failed with a hard error, so let's go with false.  */
+ gcc_assert (seen_error ());
+ spec = noexcept_false_spec;
+   }
 
   TREE_TYPE (fn) = build_exception_variant (fntype, spec);
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept36.C 
b/gcc/testsuite/g++.dg/cpp0x/noexcept36.C
new file mode 100644
index 000..980a28cd207
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept36.C
@@ -0,0 +1,22 @@
+// PR c++/89571
+// { dg-do compile { target c++11 } }
+
+struct z8 {
+  constexpr static int qq /* = 0 */;  // { dg-error "initializer" }
+};
+
+template
+struct kf {
+  kf (const kf &) noexcept (T::qq);  // { dg-error "constant" }
+};
+
+struct lk {
+  kf e1;
+};
+
+template
+T &sc ();
+
+struct b6 {
+  decltype (lk (sc ())) zz;
+};
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6c96c24430f..8738f2c3cf4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-03-14  Jason Merrill  
+
+   PR c++/89571 - ICE with ill-formed noexcept on constructor.
+   * pt.c (maybe_instantiate_noexcept): Only return false if defaulted.
+   (regenerate_decl_from_template): Use it for noexcept-specs.
+
 2019-03-14  Jason Merrill  
 
* parser.c (cp_parser_decl_specifier_seq): Support C++20

base-commit: 6f9b555b441312235713247f996b67372efb8ddd
-- 
2.20.1



[patch] Multilib support for amd64 FreeBSD

2019-03-17 Thread Andreas Tobler

Hi all,

this patch adds support for multilib on x86_64-unknown-freebsd*
The multilibs are 32-bit.

This patch is functionality tested on gcc8 and gcc9. Test suite testing 
is a bit tricky since the FreeBSD dynamic linker handles both, the 
32-bit and the 64-bit binaries. So, if I have a 64-bit libgcc in the 
LD_LIBRARY_PATH the test fails.
I tweaked the build tree and removed the 64-bit libgcc to test the 
32-bit binaries built. So far it looks good. Need to find a way to 
extend the testsuite to handle this situation.


Any comments about it are welcome.

Also, when would be the best time to commit this patch? Afair trunk is 
in stage4, right?

The patch itself only affects x86_64-unknown-freebsd.

TIA,
Andreas

2019-03-17  Andreas Tobler  

* config/i386/freebsd64.h: Add bits for 32-bit multilib support.
* config/i386/t-freebsd64: New file.
* config.gcc: Add the t-freebsd64 for multilib support.


Index: config/i386/freebsd64.h
===
--- config/i386/freebsd64.h (revision 269746)
+++ config/i386/freebsd64.h (working copy)
@@ -31,7 +31,7 @@
 
 #undef LINK_SPEC
 #define LINK_SPEC "\
-  %{m32:-m elf_i386_fbsd} \
+  %{m32:-m elf_i386_fbsd}%{!m32:-m elf_x86_64_fbsd} \
   %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \
   %{v:-V} \
   %{assert*} %{R*} %{rpath*} %{defsym*} \
@@ -42,3 +42,6 @@
-dynamic-linker %(fbsd_dynamic_linker) } \
 %{static:-Bstatic}} \
   %{symbolic:-Bsymbolic}"
+
+#undef MULTILIB_DEFAULTS
+#define MULTILIB_DEFAULTS { "m64" }
Index: config/i386/t-freebsd64
===
--- config/i386/t-freebsd64 (nonexistent)
+++ config/i386/t-freebsd64 (working copy)
@@ -0,0 +1,30 @@
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# 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
+# .
+
+# The 32-bit libraries are found in /usr/lib32
+
+# To support i386 and x86-64, the directory structrue
+# should be:
+#
+#  /lib has x86-64 libraries.
+#  /lib32 has i386 libraries.
+#
+
+MULTILIB_OPTIONS= m32
+MULTILIB_DIRNAMES   = 32
+MULTILIB_OSDIRNAMES = ../lib32
Index: config.gcc
===
--- config.gcc  (revision 269746)
+++ config.gcc  (working copy)
@@ -4925,8 +4925,11 @@
;;
i[34567]86-*-dragonfly* | x86_64-*-dragonfly*)
;;
-   i[34567]86-*-freebsd* | x86_64-*-freebsd*)
+   i[34567]86-*-freebsd*)
;;
+   x86_64-*-freebsd*)
+   tmake_file="${tmake_file} i386/t-freebsd64"
+   ;;
ia64*-*-linux*)
;;
 


[PR fortran/85797, patch] - ICE in gfc_element_size, at fortran/target-memory.c:126

2019-03-17 Thread Harald Anlauf
The attached patch fixes an ICE-on-invalid code when the TRANSFER
intrinsic is being handed procedures to the SOURCE or MOLD arguments.
My reading of the standard suggests that this is not allowed:

  SOURCE shall be a scalar or array of any type.

  MOLD shall be a scalar or array of any type. ...

I was struggling for some moment with the idea that SOURCE could be
a procedure pointer (technically), but finally dismissed it.
The patch thus rejects procedures as arguments.

Regtests cleanly on x86_64-pc-linux-gnu.

OK for trunk?

Harald

2019-03-17  Harald Anlauf  

PR fortran/85797
* check.c (gfc_check_transfer): Reject procedures as actual
arguments for SOURCE and MOLD of TRANSFER intrinsic.

2019-03-17  Harald Anlauf  

PR fortran/85797
* gfortran.dg/pr85797.f90: New test.

Index: gcc/fortran/check.c
===
--- gcc/fortran/check.c (revision 269717)
+++ gcc/fortran/check.c (working copy)
@@ -5544,6 +5544,24 @@
   size_t source_size;
   size_t result_size;
 
+  /* SOURCE shall be a scalar or array of any type.  */
+  if (source->ts.type == BT_PROCEDURE)
+{
+  gfc_error ("% argument of % intrinsic at %L "
+ "must not be a %s", &source->where,
+gfc_basic_typename (source->ts.type));
+  return false;
+}
+
+  /* MOLD shall be a scalar or array of any type.  */
+  if (mold->ts.type == BT_PROCEDURE)
+{
+  gfc_error ("% argument of % intrinsic at %L "
+ "must not be a %s", &mold->where,
+gfc_basic_typename (mold->ts.type));
+  return false;
+}
+
   if (mold->ts.type == BT_HOLLERITH)
 {
   gfc_error ("% argument of % intrinsic at %L must not 
be"
@@ -5551,6 +5569,8 @@
   return false;
 }
 
+  /* SIZE (optional) shall be an integer scalar.  The corresponding actual
+ argument shall not be an optional dummy argument.  */
   if (size != NULL)
 {
   if (!type_check (size, 2, BT_INTEGER))
Index: gcc/testsuite/gfortran.dg/pr85797.f90
===
--- gcc/testsuite/gfortran.dg/pr85797.f90   (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr85797.f90   (working copy)
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! PR fortran/85797 - ICE in gfc_element_size, at fortran/target-memory.c:126
+! Derived from original test cases by Gerhard Steinmetz
+
+module test
+contains
+  function f ()
+f = 1.
+  end function f
+  subroutine sub ()
+  end subroutine sub
+  recursive subroutine a ()
+integer(8) :: p
+procedure(sub), pointer :: x => sub
+p = transfer (sub, p) ! { dg-error "must not be a PROCEDURE" }
+p = transfer (p, sub) ! { dg-error "must not be a PROCEDURE" }
+p = transfer (f, p)   ! { dg-error "must not be a PROCEDURE" }
+p = transfer (p, f)   ! { dg-error "must not be a PROCEDURE" }
+c = transfer (a, b)   ! { dg-error "must not be a PROCEDURE" }
+print *, transfer (x, x)  ! { dg-error "must not be a PROCEDURE" }
+  end subroutine a
+end module test


PING: [RFC] libgcc: Integrating emutls and D garbage collector

2019-03-17 Thread Johannes Pfau

Am 03.03.19 um 18:59 schrieb Johannes Pfau:

Hello all,

I wanted to ask for some feedback on an issue which has affected GDC
for a long time now: Letting the D garbage collector scan
emulated TLS memory. Basically, for every variable instance in TLS
memory we need to be able to get the address and size of that instance,
so the GC can scan this memory for pointers.

Now with libgcc emutls there are essentially two problems:

1) Memory is allocated individually for each variable, so it's not
possible to simply get a memory range as in native TLS.
I can't think of a way to get the required information with the
current API, so I've attached proof-of-concept patch which
implements a __emutls_iterate_memory function. It is however rather
intrusive, so maybe there's a better solution. Currently it keeps
the size for all variables in every threads local memory, but an
optimization would be to keep the size only once in a separate array.

A completely different, less intrusive solution would be to allow the
frontend to specify different emutls functions (e.g.
__d_emutls_get_address instead of __emutls_get_address). The main
drawback here is that linking C/D emutls variables would not be
possible due to the incompatible ABI. However, this is also true
for the other D compilers' (DMD) emutls implementation, so this may
be fine. A D emutls implementation would also be much simpler and
probably faster (we can just allocate using the GC).

(Of course it's way too late for such changes in GCC9, so I'm just
asking for some general feedback.)


Ping.
In the meantime I've also implemented the second solution: I added 
additional langhooks to make gdc/gcc call __emutls_d_get_addr instead 
and reimplemented the emutls support in druntime. However, the druntime 
implementation didn't turn out as I originally hoped: Because druntime 
uses TLS before it even uses the GC, I can't use the GC to allocate 
memory in the emutls implementation. And as core.thread uses TLS, I 
can't store the per-thread array in the Thread class as I initially 
wanted. Because of that, the D reimplementation is now 1:1 the same as 
the original libgcc implementation. In that case, it might be better to 
change libgcc, as we then still have ABI compatibility between C/D 
emutls variables.


Attached is version 2 of the original patch. This keeps the sizes for 
all threads' allocations in one array, so the memory overhead is 
constant with respect to the number of threads.


When running the testsuite I realized there's one very unfortunate 
regression with the attached patch: It breaks asan for emutls.c. The 
reason is simple: I now allocate memory when the emutls mutex is locked. 
Asan hooks into that memory allocation but it also internally uses TLS 
so it calls __emutls_get_addr again and then deadlocks as it tries to 
lock the emutls mutex again:


#2  0x7721b4d7 in __gthread_mutex_lock (__mutex=0x77221420 
) at ./gthr-default.h:749
#3  __emutls_get_address (obj=obj@entry=0x77725000 
<__emutls_v._ZN6__lsan15disable_counterE>) at 
../../../gcc/libgcc/emutls.c:294
#4  0x776d4590 in __lsan::DisabledInThisThread () at 
../../../../gcc/libsanitizer/lsan/lsan_common_linux.cc:42
#5  0x775cdfa8 in __asan::Allocator::Allocate 
(this=this@entry=0x777250c0 <__asan::instance>, size=size@entry=272, 
alignment=,
alignment@entry=8, stack=, 
alloc_type=alloc_type@entry=__asan::FROM_MALLOC, 
can_fill=can_fill@entry=false)

at ../../../../gcc/libsanitizer/asan/asan_allocator.cc:537
#6  0x775ca4fc in __asan::Allocator::Calloc 
(stack=0x7fffd980, size=size@entry=272, nmemb=nmemb@entry=272, 
this=0x777250c0 <__asan::instance>)

at ../../../../gcc/libsanitizer/asan/asan_allocator.cc:680
#7  __asan::asan_calloc (nmemb=nmemb@entry=272, size=size@entry=1, 
stack=stack@entry=0x7fffd980) at 
../../../../gcc/libsanitizer/asan/asan_allocator.cc:878
#8  0x776a9e72 in __interceptor_calloc (nmemb=272, size=1) at 
../../../../gcc/libsanitizer/asan/asan_malloc_linux.cc:154
#9  0x7721b700 in emutls_save_size (size=32, offset=1) at 
../../../gcc/libgcc/emutls.c:153


Does anybody have an idea how to fix this or any comments in general 
related to GC / emutls integration?


Best regards,
Johannes
>From cabe88b4711c451178d4211bfcd4e28cce9d5253 Mon Sep 17 00:00:00 2001
From: Johannes Pfau 
Date: Sun, 3 Mar 2019 15:18:05 +0100
Subject: [PATCH] libgcc: Introduce emutls iterate_memory hook

---
 libgcc/emutls.c  | 153 +++
 libgcc/libgcc-std.ver.in |   5 ++
 2 files changed, 158 insertions(+)

diff --git a/libgcc/emutls.c b/libgcc/emutls.c
index c725142e465..83c7572d20c 100644
--- a/libgcc/emutls.c
+++ b/libgcc/emutls.c
@@ -50,8 +50,17 @@ struct __emutls_array
   void **data[];
 };
 
+struct __emutls_word_array
+{
+  pointer size;
+  word data[];
+};
+
 void *__emutls_get_address (struct __emutls_object *);
 void __emutls_register_common (struct __emutls_object *,

[PATCH] [libbacktrace] Initialize st in elf_is_symlink

2019-03-17 Thread james . hilliard1
From: James Hilliard 

Fixes error: ‘st.st_mode’ may be used uninitialized in this function
---
 libbacktrace/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index f3988ec02a0..714bfec965d 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -765,7 +765,7 @@ elf_syminfo (struct backtrace_state *state, uintptr_t addr,
 static int
 elf_is_symlink (const char *filename)
 {
-  struct stat st;
+  struct stat st={0};
 
   if (lstat (filename, &st) < 0)
 return 0;
-- 
2.17.1



Implement C++20 constexpr , , and

2019-03-17 Thread Ed Smith-Rowland via gcc-patches

Greetings,

This patch implements C++20 p0202 - Add Constexpr Modifiers to Functions 
in  and  Headers


and C++20 p1023 - constexpr comparison operators for std::array.


The patch is large because of the testsuite additions. Basically, the 
algorithms and the array comparison operators are all marked constexpr 
for C++20.  This has been built and tested on x86_64-linux.


OK?

Ed


2019-03-18  Edward Smith-Rowland  <3dw...@verizon.net>

Implement C++20 p0202 - Add Constexpr Modifiers to Functions
in  and  Headers.
Implement C++20 p1023 - constexpr comparison operators for std::array.
* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
copy_backward, copy_if, copy_n, equal_range, fill, fill_n, find_end,
find_if_not, includes, is_heap, is_heap_until, is_partitioned,
is_permutation, is_sorted, is_sorted_until, lower_bound, none_of,
partition_copy, partition_point, remove, remove_if, remove_copy,
remove_copy_if, replace_copy, replace_copy_if, reverse_copy,
rotate_copy, unique, upper_bound, adjacent_find, count, count_if, equal,
find, find_first_of, find_if, for_each, generate, generate_n,
lexicographical_compare, merge, mismatch, replace, replace_if, search,
search_n, set_difference, set_intersection, set_symmetric_difference,
set_union, transform, unique_copy): Mark constexpr.
Make versions of operator() const.
* include/bits/cpp_type_traits.h (__miter_base): Make constexpr.
* include/bits/predefined_ops.h (_Iter_less_val, __iter_comp_val,
_Val_less_iter, __val_less_iter, __val_comp_iter, _Iter_equal_to_iter,
__iter_equal_to_iter, _Iter_equal_to_val, __iter_equal_to_val,
_Iter_comp_val, __iter_comp_val, _Val_comp_iter, __val_comp_iter,
_Iter_equals_val, __iter_equals_val, _Iter_equals_iter,
__iter_comp_iter, __pred_iter, __iter_comp_val, __negate): Constexpr
ctors. Add const operator().
* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
__search, __search_n_aux, __search_n, __find_end, find_end, all_of
none_of, any_of, find_if_not, is_partitioned, partition_point,
__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
__unique, unique, __unique_copy, reverse_copy, rotate_copy,
__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
__equal_range, equal_range, binary_search, __includes, includes,
__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
replace_copy_if, __count_if, is_sorted, __is_sorted_until,
is_sorted_until, __is_permutation, is_permutation, for_each, find,
find_if, find_first_of, adjacent_find, count, count_if, search,
search_n, transform, replace, replace_if, generate, generate_n,
unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
set_intersection, __set_difference, set_difference,
__set_symmetric_difference, set_symmetric_difference): Constexpr.
* include/bits/stl_algobase.h (__niter_base, __niter_wrap, __copy_m,
__copy_move_a, copy, move, __copy_move_backward::__copy_move_b,
__copy_move_backward_a, __copy_move_backward_a2, copy_backward,
move_backward, fill, __fill_n_a, fill_n, __equal::equal, __equal_aux,
__newlast1, __cnd2, __newlast1, __cnd2, __lexicographical_compare_impl
__lexicographical_compare::__lc, __lexicographical_compare,
__lexicographical_compare_aux, __lower_bound, lower_bound, equal,
__equal4, lexicographical_compare, __mismatch, mismatch): Constexpr.
* include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until,
is_heap): Constexpr.
* include/bits/stl_iterator.h (__niter_base, __miter_base): Constexpr.
* include/std/array: Make comparison ops constexpr.
* include/std/utility: Make exchange constexpr.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/
tuple_element_neg.cc: Adjust.
* testsuite/20_util/exchange/constexpr.cc: New.
* testsuite/23_containers/array/comparison_operators/constexpr.cc: New.
* testsuite/25_algorithms/adjacent_find/constexpr.cc: New.
* testsuite/25_algorithms/all_of/constexpr.cc: New.
* testsuite/25_algorithms/any_of/constexpr.cc: New.
* testsuite/25_algorithms/binary_search/constexpr.cc: New.
* testsuite/25_algorithms/copy/constexpr.cc: New.
* testsuite/25_algorithms/copy_backward/constexpr.cc: New.
* testsuite/25_algorithms/copy_if/constexpr.cc: New.
* testsuite/25_algorithms/copy_n/constexpr.cc: New.
* testsuite