Re: Update: Hurd port for gcc-7 go : 7.3.0-8+ for glibc 2.26+

2018-03-10 Thread Samuel Thibault
Hello,

Svante Signell, on sam. 10 mars 2018 19:33:35 +0100, wrote:
> Attached is the updated patch, src_libgo_build.diff, to build gccgo properly 
> on
> Debian GNU/Hurd on gcc-7 (7-7.3.0-{8,9,10}) again after the update of glibc to
> 2.26+

I have updated the gcc-7 package in Debian, thanks!

Samuel


Re: [committed] Fix va_arg gimplification on powerpc{,spe} (PR target/84772)

2018-03-10 Thread Segher Boessenkool
Hi,

On Fri, Mar 09, 2018 at 11:29:02PM +0100, Jakub Jelinek wrote:
> The following is a powerpcspe variant of the sparc PR39645, and rs6000
> has the same code (not sure if ever used or dead after powerpcspe removal).

It's not dead, this code is for the SVR4 ABI, used on most 32-bit targets
(including powerpc-linux).

Thanks for the patch,


Segher


Update: Hurd port for gcc-7 go : 7.3.0-8+ for glibc 2.26+

2018-03-10 Thread Svante Signell
Hi,

Attached is the updated patch, src_libgo_build.diff, to build gccgo properly on
Debian GNU/Hurd on gcc-7 (7-7.3.0-{8,9,10}) again after the update of glibc to
2.26+

The libgo tests show the following:

=== libgo Summary ===

# of expected passes119
# of unexpected failures26

Replacing the stub code of netpoll_gnu.go with a poll-based implementation the
libgo tests improves to:

=== libgo Summary ===

# of expected passes124
# of unexpected failures21

The change is reflected in the updated version of src_libgo_go_runtime.diff,
also attached!

Thanks!Index: gcc-7-7.3.0-8.1/src/libgo/configure.ac
===
--- gcc-7-7.3.0-8.1.orig/src/libgo/configure.ac
+++ gcc-7-7.3.0-8.1/src/libgo/configure.ac
@@ -146,7 +146,7 @@ AC_SUBST(go_include)
 # All known GOOS values.  This is the union of all operating systems
 # supported by the gofrontend and all operating systems supported by
 # the gc toolchain.
-ALLGOOS="android darwin dragonfly freebsd irix linux netbsd openbsd plan9 rtems solaris windows"
+ALLGOOS="android darwin dragonfly freebsd irix gnu linux netbsd openbsd plan9 rtems solaris windows"
 
 is_darwin=no
 is_freebsd=no
@@ -157,6 +157,7 @@ is_openbsd=no
 is_dragonfly=no
 is_rtems=no
 is_solaris=no
+is_gnu=no
 GOOS=unknown
 case ${host} in
   *-*-darwin*)   is_darwin=yes;  GOOS=darwin ;;
@@ -168,6 +169,7 @@ case ${host} in
   *-*-dragonfly*) is_dragonfly=yes; GOOS=dragonfly ;;
   *-*-rtems*)is_rtems=yes;   GOOS=rtems ;;
   *-*-solaris2*) is_solaris=yes; GOOS=solaris ;;
+  *-*-gnu*)  is_gnu=yes; GOOS=gnu ;;
 esac
 AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes)
 AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes)
@@ -178,6 +180,7 @@ AM_CONDITIONAL(LIBGO_IS_OPENBSD, test $i
 AM_CONDITIONAL(LIBGO_IS_DRAGONFLY, test $is_dragonfly = yes)
 AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
 AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
+AM_CONDITIONAL(LIBGO_IS_GNU, test $is_gnu = yes)
 AM_CONDITIONAL(LIBGO_IS_BSD, test $is_darwin = yes -o $is_dragonfly = yes -o $is_freebsd = yes -o $is_netbsd = yes -o $is_openbsd = yes)
 AC_SUBST(GOOS)
 AC_SUBST(ALLGOOS)
@@ -838,6 +841,14 @@ main ()
 CFLAGS="$CFLAGS_hold"
 LIBS="$LIBS_hold"
 ])
+
+case ${host} in
+  *-*-gnu*)
+  LIBS="$LIBS -lpthread"
+  AC_SUBST(LIBS)
+  ;;
+esac
+
 dnl overwrite for the mips* 64bit multilibs, fails on some buildds
 if test "$libgo_cv_lib_setcontext_clobbers_tls" = "yes"; then
   case "$target" in
Index: gcc-7-7.3.0-8.1/src/libgo/Makefile.am
===
--- gcc-7-7.3.0-8.1.orig/src/libgo/Makefile.am
+++ gcc-7-7.3.0-8.1/src/libgo/Makefile.am
@@ -420,10 +420,14 @@ else
 if LIBGO_IS_NETBSD
 runtime_getncpu_file = runtime/getncpu-bsd.c
 else
+if LIBGO_IS_GNU
+runtime_getncpu_file = runtime/getncpu-gnu.c
+else
 runtime_getncpu_file = runtime/getncpu-none.c
 endif
 endif
 endif
+endif
 endif
 endif
 endif
Index: gcc-7-7.3.0-8.1/src/libgo/Makefile.in
===
--- gcc-7-7.3.0-8.1.orig/src/libgo/Makefile.in
+++ gcc-7-7.3.0-8.1/src/libgo/Makefile.in
@@ -183,7 +183,8 @@ libgo_llgo_la_DEPENDENCIES = $(am__DEPEN
 @LIBGO_IS_LINUX_FALSE@am__objects_2 = thread-sema.lo
 @LIBGO_IS_LINUX_TRUE@am__objects_2 = thread-linux.lo
 @LIBGO_IS_RTEMS_TRUE@am__objects_3 = rtems-task-variable-add.lo
-@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-none.lo
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-none.lo
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-gnu.lo
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_TRUE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-bsd.lo
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-bsd.lo
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_TRUE@am__objects_4 = getncpu-solaris.lo
@@ -768,7 +769,8 @@ toolexeclibgounicode_DATA = \
 @LIBGO_IS_RTEMS_TRUE@rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
 @LIBGO_IS_LINUX_FALSE@runtime_thread_files = runtime/thread-sema.c
 @LIBGO_IS_LINUX_TRUE@runtime_thread_files = runtime/thread-linux.c
-@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-none.c
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_FALSE@@LIBGO_IS_IRI

Re: GCC 6 backports

2018-03-10 Thread H.J. Lu
On Wed, Mar 7, 2018 at 1:41 AM, Martin Liška  wrote:
> Hi.
>
> Sending GCC 6 branch backports.
> Patches can bootstrap on ppc64le-redhat-linux and survives regression tests.
> I'm going to install the patches.
>
> Martin

I am going to backport:

https://gcc.gnu.org/ml/gcc-cvs/2018-01/msg00211.html

to GCC 6 branch to fix:

FAIL: g++.dg/ipa/pr82352.C  -std=gnu++11 (test for excess errors)
FAIL: g++.dg/ipa/pr82352.C  -std=gnu++14 (test for excess errors)
FAIL: g++.dg/ipa/pr82352.C  -std=gnu++98 (test for excess errors)

-- 
H.J.


Re: patch to fix PR83712

2018-03-10 Thread Jeff Law
On 03/10/2018 09:40 AM, Vladimir Makarov wrote:
> A few people reported that the patch broke i686.  I am going to work on
> the patch more.  Meanwhile I've reverted the patch.
Just a note, none of my other builds failed.  Though i686 probably
stresses the class-likely-spilled bits than any other.

jeff


Re: patch to fix PR83712

2018-03-10 Thread Vladimir Makarov
A few people reported that the patch broke i686.  I am going to work on 
the patch more.  Meanwhile I've reverted the patch.


On 03/09/2018 11:16 AM, Vladimir Makarov wrote:

The following patch fixes

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83712

It is another "cannot find a spill reg for reload" problem.  LRA has 
already a code splitting hard reg live ranges to avoid such problem.  
This code is in LRA inheritance pass.  Unfortunately, the code does 
splitting for small class pseudos only.  This PR is a more complicated 
code and it is hard to adapt the inheritance sub-pass to reliably 
solve such problems.


To fix the PR, I added a sub-pass which works in very rare cases after 
we already found that we have no hard regs for a reload pseudo.  It 
tries to split a hard reg live range for the pseudo. After that it 
tries again to assign a hard reg to the pseudo.  The patch changes 
LRA-subpass flow for this.  I hope that the patch will finally solved 
all such problems but I am not sure to be completely certain.


The patch was bootstrapped and tested on x86-64 and ppc64.

Committed as rev. 258390.





[wwwdocs] www.fsf.org switched to https - lists.html

2018-03-10 Thread Gerald Pfeifer
Applied.

Gerald

Index: lists.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/lists.html,v
retrieving revision 1.112
diff -u -r1.112 lists.html
--- lists.html  31 Aug 2014 16:32:23 -  1.112
+++ lists.html  10 Mar 2018 16:31:59 -
@@ -47,7 +47,7 @@
   Recruiting postings, including recruiting for GCC or other
   free software jobs, are not permitted on any of our mailing lists.
   If you are interested in hiring a GCC developer, please visit the
-  http://www.fsf.org/resources/jobs/";>FSF jobs page.
+  https://www.fsf.org/resources/jobs/";>FSF jobs page.
 
   All major decisions and changes, like abandoning ports or front ends,
   should be announced and discussed here.  Ideally, this list should be


Re: [wwwdocs] Adjust to new MPC homepage (gcc-4.5/changes.html)

2018-03-10 Thread Gerald Pfeifer
On Sun, 4 Mar 2018, Gerald Pfeifer wrote:
> Not sure why they made this change, but the main address now
> redirects to an MPC-specific page.

Turns out I missed the second link on that page; let's avoid that
going forward. ;-)

Committed.

Gerald

Index: gcc-4.5/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.5/changes.html,v
retrieving revision 1.117
diff -u -r1.117 changes.html
--- gcc-4.5/changes.html4 Mar 2018 12:04:07 -   1.117
+++ gcc-4.5/changes.html10 Mar 2018 16:28:58 -
@@ -100,8 +100,7 @@
 allows the user to get debugging dumps when doing parallel builds
 without two builds of the same filename interfering with each other.
 
-GCC has been integrated with the http://www.multiprecision.org/";>MPC library.  This
+GCC has been integrated with the MPC library. This
 allows GCC to evaluate complex arithmetic at compile time https://gcc.gnu.org/PR30789";>more
 accurately.  It also allows GCC to evaluate calls to complex


[wwwdocs] AVR entry in readings.htmls

2018-03-10 Thread Gerald Pfeifer
It appears this link at atmel.com has been taken down without
what appears a replacement, so I applied the patch below.

Denis, if you have a new reference, happy to add that, of course.

Gerald

Index: readings.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/readings.html,v
retrieving revision 1.289
diff -u -r1.289 readings.html
--- readings.html   4 Mar 2018 10:02:19 -   1.289
+++ readings.html   10 Mar 2018 16:10:22 -
@@ -88,7 +88,6 @@
 
  AVR
   Manufacturer: Atmel
-  http://www.atmel.com/products/microcontrollers/avr/";>AVR 
Documentation
  
 
  Blackfin


[PATCH] i386: Fix a typo: Enforcment -> Enforcement

2018-03-10 Thread H.J. Lu
I am checking this in as an obvious fix.

H.J.
PR target/84807
* config/i386/i386.opt: Replace Enforcment with Enforcement.
---
 gcc/config/i386/i386.opt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 150d78e345a..311b99d9739 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -1008,18 +1008,18 @@ Generate code which uses only the general registers.
 
 mcet
 Target Report Var(flag_cet) Init(0)
-Support Control-flow  Enforcment Technology (CET) built-in functions
+Support Control-flow Enforcement Technology (CET) built-in functions
 and code generation.
 
 mibt
 Target Report Mask(ISA_IBT) Var(ix86_isa_flags2) Save
 Specifically enables an indirect branch tracking feature from Control-flow
-Enforcment Technology (CET).
+Enforcement Technology (CET).
 
 mshstk
 Target Report Mask(ISA_SHSTK) Var(ix86_isa_flags) Save
 Specifically enables an shadow stack support feature from Control-flow
-Enforcment Technology (CET).
+Enforcement Technology (CET).
 
 mcet-switch
 Target Report Undocumented Var(flag_cet_switch) Init(0)
-- 
2.14.3



Re: patch to fix PR83712

2018-03-10 Thread H.J. Lu
On Fri, Mar 9, 2018 at 8:16 AM, Vladimir Makarov  wrote:
> The following patch fixes
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83712
>
> It is another "cannot find a spill reg for reload" problem.  LRA has already
> a code splitting hard reg live ranges to avoid such problem.  This code is
> in LRA inheritance pass.  Unfortunately, the code does splitting for small
> class pseudos only.  This PR is a more complicated code and it is hard to
> adapt the inheritance sub-pass to reliably solve such problems.
>
> To fix the PR, I added a sub-pass which works in very rare cases after we
> already found that we have no hard regs for a reload pseudo.  It tries to
> split a hard reg live range for the pseudo. After that it tries again to
> assign a hard reg to the pseudo.  The patch changes LRA-subpass flow for
> this.  I hope that the patch will finally solved all such problems but I am
> not sure to be completely certain.
>
> The patch was bootstrapped and tested on x86-64 and ppc64.
>
> Committed as rev. 258390.
>

This caused:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84806

-- 
H.J.


[PR c++/84647] undeclared fn called in auto default arg in ptr decl

2018-03-10 Thread Alexandre Oliva
We ICEd when attempting to convert a default arg for an auto parm, the
default arg amounting to a call to an undeclared function, in a
declaration of a pointer to function variable.  It's all wrong, but
because of the bogus implicit template, we accept the typeless
expression at first.  Later on, after we finish the implicit template
because it's bogus (but deferring the reporting of the error to the end
of cp_parser_init_declarator), no longer processing_template_decl, we
attempt to perform the impossible conversion from NULL type to an
unresolved and unresolvable type placeholder.  We crash in
implicit_conversion because FROM is NULL, and then (once we arrange to
return a NULL conversion there) in perform_implicit_conversion_flags
when trying to determine whether the expr is an invalid use of a
nonstatic memfn.

This patch makes implicit_conversion return NULL when the FROM type is
NULL, and reports a proper error for typeless EXPRs in
perform_implicit_conversion_flags.  I considered testing for
!processing_template_decl, but decided not to bother.

FWIW, I'd tried temporarily incrementing processing_template_decl while
completing the parsing of the bogus implicit template, but that didn't
go very well: we'd skip the conversion all right, but start_decl would
attempt to push_template_decl, and that would silently return
error_mark_node, which would in turn silence the bogus implicit template
error.  With -fpermissive, all the other errors (misplaced auto,
unexpected default arg in pointer declaration, and undeclared function
call) would be turned to warnings or vanish altogether, so compilation
would complete in spite of the bogus parsing and the failed template
declaration.  I decided not to explore that path further, and ended up
working around the errors in the conversion, so as to make sure we'd get
at least some error (we get all of them with the enclosed testcase).

Regstrapped on i686- and x86_64-linux-gnu.  Ok to install?

for  gcc/cp/ChangeLog

PR c++/84647
* call.c (implicit_conversion): Return NULL conv for NULL
from type.
(perform_implicit_conversion_flags): If conv is NULL, check
for NULL expr type and report an error instead of ICEing.

for  gcc/testsuite/ChangeLog

PR c++/84647
* g++.dg/cpp0x/pr84647.C: New.

---
 gcc/cp/call.c|   10 ++
 gcc/testsuite/g++.dg/cpp0x/pr84647.C |3 +++
 2 files changed, 13 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr84647.C

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 45c22aaa312c..cb95fe35891a 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1836,6 +1836,9 @@ implicit_conversion (tree to, tree from, tree expr, bool 
c_cast_p,
   from = TREE_TYPE (expr);
 }
 
+  if (!from)
+return NULL;
+
   if (TREE_CODE (to) == REFERENCE_TYPE)
 conv = reference_binding (to, from, expr, c_cast_p, flags, complain);
   else
@@ -10586,6 +10589,13 @@ perform_implicit_conversion_flags (tree type, tree 
expr,
 Call instantiate_type to get good error messages.  */
  if (TREE_TYPE (expr) == unknown_type_node)
instantiate_type (type, expr, complain);
+ /* We may find this if we parse a default argument as part
+of a bogus implicit template function declaration.  It
+might be a template-dependent expression, or a call of an
+undeclared function.  */
+ else if (!TREE_TYPE (expr))
+   error_at (loc, "cannot convert typeless expression %qE",
+ expr);
  else if (invalid_nonstatic_memfn_p (loc, expr, complain))
/* We gave an error.  */;
  else
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr84647.C 
b/gcc/testsuite/g++.dg/cpp0x/pr84647.C
new file mode 100644
index ..63292bd8f692
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr84647.C
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++11 } }
+
+void (*a)(auto b = c()); // { dg-error "parameter declaration|depend on a 
template|undeclared name|not declared|default arguments|typeless 
expression|implicit template" }

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer


[PR c++/84610,84642] recover from implicit template parms gracefully

2018-03-10 Thread Alexandre Oliva
If we get a parse error during an attempted fully implicit function
template parse, and need to skip to the end of the statement or block,
we may discard the function parms scope rather than the enclosing
injected implicit template parms scope.  If we rollback a tentative
parse and try something else, we'll no longer be in a function parms
scope, but rather in a template parms scope, but we may still attempt
to synthesize implicit template parms and then fail the assert that
checks we're in a function parms scope.

This patch introduces an alternative to
finish_fully_implicit_template_p, to be used during error recovery,
that floats the implicit template parm scope to the top so that it
gets discarded as we finish and discard the failed implicit template
data, while other scopes are retained as expected.  It also clears the
implicit template parser data as we finish the template, so that it
doesn't linger on referencing discarded or used scopes and parms.

Regstrapped on i686- and x86_64-linux-gnu.  Ok to install?

While debugging this, I first tried another patch, that avoids the same
ICEs.  I thought this one was a more complete solution, and it renders
the other unnecessary, but I still though it might be useful to disable
auto->implicit_parm while parsing declarators, so as to avoid useless
processing.

for gcc/cp/ChangeLog

PR c++/84610
PR c++/84642
* parser.c (abort_fully_implicit_template_p): New.
(cp_parser_skip_to_end_of_statement): Use it.
(cp_parser_skip_to_end_of_block_or_statement): Likewise.
(finish_fully_implicit_template_p): Clear
implicit_template_parms and implicit_template_scope.

for  gcc/testsuite/ChangeLog

PR c++/84610
PR c++/84642
* g++.dg/cpp0x/pr84610.C: New.
* g++.dg/cpp0x/pr84642.C: New.
---
 gcc/cp/parser.c  |   38 --
 gcc/testsuite/g++.dg/cpp0x/pr84610.C |3 +++
 gcc/testsuite/g++.dg/cpp0x/pr84642.C |3 +++
 3 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr84610.C
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr84642.C

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index cdc623889732..e17507d7f6e0 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -2264,6 +2264,8 @@ static tree synthesize_implicit_template_parm
   (cp_parser *, tree);
 static tree finish_fully_implicit_template
   (cp_parser *, tree);
+static void abort_fully_implicit_template
+  (cp_parser *);
 
 /* Classes [gram.class] */
 
@@ -3585,7 +3587,7 @@ cp_parser_skip_to_end_of_statement (cp_parser* parser)
 
   /* Unwind generic function template scope if necessary.  */
   if (parser->fully_implicit_function_template_p)
-finish_fully_implicit_template (parser, /*member_decl_opt=*/0);
+abort_fully_implicit_template (parser);
 
   while (true)
 {
@@ -3675,7 +3677,7 @@ cp_parser_skip_to_end_of_block_or_statement (cp_parser* 
parser)
 
   /* Unwind generic function template scope if necessary.  */
   if (parser->fully_implicit_function_template_p)
-finish_fully_implicit_template (parser, /*member_decl_opt=*/0);
+abort_fully_implicit_template (parser);
 
   while (nesting_depth >= 0)
 {
@@ -39261,11 +39263,43 @@ finish_fully_implicit_template (cp_parser *parser, 
tree member_decl_opt)
   end_template_decl ();
 
   parser->fully_implicit_function_template_p = false;
+  parser->implicit_template_parms = 0;
+  parser->implicit_template_scope = 0;
   --parser->num_template_parameter_lists;
 
   return member_decl_opt;
 }
 
+/* Like finish_fully_implicit_template, but to be used in error
+   recovery, rearranging scopes so that we restore the state we had
+   before synthesize_implicit_template_parm inserted the implement
+   template parms scope.  */
+
+static void
+abort_fully_implicit_template (cp_parser *parser)
+{
+  cp_binding_level *return_to_scope = current_binding_level;
+
+  if (parser->implicit_template_scope
+  && return_to_scope != parser->implicit_template_scope)
+{
+  cp_binding_level *child = return_to_scope;
+  for (cp_binding_level *scope = child->level_chain;
+  scope != parser->implicit_template_scope;
+  scope = child->level_chain)
+   child = scope;
+  child->level_chain = parser->implicit_template_scope->level_chain;
+  parser->implicit_template_scope->level_chain = return_to_scope;
+  current_binding_level = parser->implicit_template_scope;
+}
+  else
+return_to_scope = return_to_scope->level_chain;
+
+  finish_fully_implicit_template (parser, NULL);
+
+  gcc_assert (current_binding_level == return_to_scope);
+}
+
 /* Helper function for diagnostics that have complained about things
being used with 'extern "C"' linkage.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr84610.C 
b/gcc/testsuite/g++.dg/cpp0x/pr84610.C
new file mode 100644
index ..cc70748967bc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr84610.C
@@

[PR c++/84729] convert new init to array elt type

2018-03-10 Thread Alexandre Oliva
A parenthesized initializer is only accepted when new()ing an array in
permissive mode.  We were not careful, however, to convert the
TREE_LIST initializer to the array element type in this extension.
This patch fixes it: after turning the TREE_LIST initializer to a
compound_expr, we convert it to the base type.

Regstrapped on i686- and x86_64-linux-gnu.  Ok to install?

for  gcc/cp/ChangeLog

PR c++/84729
* init.c (build_vec_init): Convert tree list to base type.

for  gcc/testsuite/ChangeLog

PR c++/84729
* g++.dg/pr84729.C: New.
---
 gcc/cp/init.c  |   10 --
 gcc/testsuite/g++.dg/pr84729.C |7 +++
 2 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr84729.C

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 15cee17c780c..cb62f4886e6d 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -4405,8 +4405,14 @@ build_vec_init (tree base, tree maxindex, tree init,
  else
{
  if (TREE_CODE (init) == TREE_LIST)
-   init = build_x_compound_expr_from_list (init, ELK_INIT,
-   complain);
+   {
+ init = build_x_compound_expr_from_list (init, ELK_INIT,
+ complain);
+ init
+   = convert_for_initialization (NULL_TREE, type, init,
+ LOOKUP_IMPLICIT, ICR_INIT,
+ NULL_TREE, 0, complain);
+   }
  elt_init = (init == error_mark_node
  ? error_mark_node
  : build2 (INIT_EXPR, type, to, init));
diff --git a/gcc/testsuite/g++.dg/pr84729.C b/gcc/testsuite/g++.dg/pr84729.C
new file mode 100644
index ..6ca7fb0032f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr84729.C
@@ -0,0 +1,7 @@
+// { dg-do compile }
+// { dg-options "-fpermissive" }
+
+typedef int b[2];
+void a() {
+  new b(a); // { dg-warning "parenthesized initializer in array new|invalid 
conversion" }
+}

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer


[Ada] Fix wrong call to protected function returning VFA type

2018-03-10 Thread Eric Botcazou
This is a small regression present on the mainline and 7 branch: the call to a 
protected function returning a composite type with Volatile_Full_Access aspect 
or pragma yields a segfault at run time.

Tested on x86-64/Linux, applied on the mainline and 7 branch.


2018-03-10  Eric Botcazou  

* gcc-interface/trans.c (node_has_volatile_full_access) :
Consider only entities for objects.


2018-03-10  Eric Botcazou  

* gnat.dg/prot3.adb: New test.
* gnat.dg/prot3_pkg.ad[sb]: New helper.

-- 
Eric BotcazouIndex: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 258411)
+++ gcc-interface/trans.c	(working copy)
@@ -4082,6 +4082,8 @@ node_has_volatile_full_access (Node_Id g
 case N_Identifier:
 case N_Expanded_Name:
   gnat_entity = Entity (gnat_node);
+  if (!Is_Object (gnat_entity))
+	break;
   return Is_Volatile_Full_Access (gnat_entity)
 	 || Is_Volatile_Full_Access (Etype (gnat_entity));
 
package body Prot3_Pkg is
   
   protected body Prot is
  function Fn (J : Short_Integer) return Rec
  is
  begin
	 return (V1 => J * J,
		 V2 => J);
  end;
  
  procedure Foo (J : Short_Integer) is
  begin
	 Val := Fn (J);
  end;
   end Prot;
   
end Prot3_Pkg;
package Prot3_Pkg is
   
   type Rec is record
  V1 : Short_Integer;
  V2 : Short_Integer;
   end record with Volatile_Full_Access;
   
   protected type Prot is
  procedure Foo (J : Short_Integer);
   private
  Val : Rec;
   end Prot;
   
   P : Prot;
   
end Prot3_Pkg;
--  { dg-do run }

with Prot3_Pkg; use Prot3_Pkg;

procedure Prot3 is
begin
   P.Foo (4);
end;