[pushed] c++: Handle multiple aggregate overloads [PR95319].

Message ID 20200527182005.12553-1-jason@redhat.com
State New
Headers show
Series
  • [pushed] c++: Handle multiple aggregate overloads [PR95319].
Related show

Commit Message

Kewen.Lin via Gcc-patches May 27, 2020, 6:20 p.m.
Here, when considering the two 'insert' overloads, we look for aggregate
conversions from the same initializer-list to B<3> or
initializer_list<B<3>>.  But since my fix for reshape_init overhead on the
PR14179 testcase we reshaped the initializer-list directly, leading to an
error when we then tried to reshape it differently for the second overload.

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

gcc/cp/ChangeLog:

	PR c++/95319
	* decl.c (reshape_init_array_1): Don't reuse in overload context.

gcc/testsuite/ChangeLog:

	PR c++/95319
	* g++.dg/cpp0x/initlist-array12.C: New test.
---
 gcc/cp/decl.c                                 |  4 +++-
 gcc/testsuite/g++.dg/cpp0x/initlist-array12.C | 24 +++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-array12.C


base-commit: a7fd43c38f7469a3ef5ee30e889d60e1376d4dfc
-- 
2.18.1

Comments

Kewen.Lin via Gcc-patches May 28, 2020, 1:44 p.m. | #1
On Wed, May 27, 2020 at 12:07 PM Jason Merrill via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>

> Here, when considering the two 'insert' overloads, we look for aggregate

> conversions from the same initializer-list to B<3> or

> initializer_list<B<3>>.  But since my fix for reshape_init overhead on the

> PR14179 testcase we reshaped the initializer-list directly, leading to an

> error when we then tried to reshape it differently for the second overload.

>

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

>

> gcc/cp/ChangeLog:

>

>         PR c++/95319

>         * decl.c (reshape_init_array_1): Don't reuse in overload context.

>

> gcc/testsuite/ChangeLog:

>

>         PR c++/95319

>         * g++.dg/cpp0x/initlist-array12.C: New test.


I got

FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++14 (test for excess errors)
FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++17 (test for excess errors)
FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++2a (test for excess errors)
FAIL: g++.dg/ext/tmplattr10.C  -std=c++98 (test for excess errors)

on Linux/x86:

https://gcc.gnu.org/pipermail/gcc-regression/2020-May/072622.html

[hjl@gnu-cfl-2 gcc]$
/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/testsuite/g++/../../xg++
-B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/testsuite/g++/../../
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/cpp0x/initlist-array12.C
-m32 -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers
-fdiagnostics-color=never -fdiagnostics-urls=never -nostdinc++
-I/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/x86_64-pc-linux-gnu/32/libstdc++-v3/include/x86_64-pc-linux-gnu
-I/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/x86_64-pc-linux-gnu/32/libstdc++-v3/include
-I/export/gnu/import/git/sources/gcc/libstdc++-v3/libsupc++
-I/export/gnu/import/git/sources/gcc/libstdc++-v3/include/backward
-I/export/gnu/import/git/sources/gcc/libstdc++-v3/testsuite/util
-fmessage-length=0 -std=c++2a -pedantic-errors -Wno-long-long -S -o
initlist-array12.s
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/cpp0x/initlist-array12.C:5:24:
fatal error: definition of ‘class std::initializer_list<
<template-parameter-1-1> >’ does not match ‘#include
<initializer_list>’
compilation terminated.
[hjl@gnu-cfl-2 gcc]$

-- 
H.J.
Kewen.Lin via Gcc-patches May 28, 2020, 1:57 p.m. | #2
On Thu, May 28, 2020 at 06:44:53AM -0700, H.J. Lu via Gcc-patches wrote:
> On Wed, May 27, 2020 at 12:07 PM Jason Merrill via Gcc-patches

> <gcc-patches@gcc.gnu.org> wrote:

> >

> > Here, when considering the two 'insert' overloads, we look for aggregate

> > conversions from the same initializer-list to B<3> or

> > initializer_list<B<3>>.  But since my fix for reshape_init overhead on the

> > PR14179 testcase we reshaped the initializer-list directly, leading to an

> > error when we then tried to reshape it differently for the second overload.

> >

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

> >

> > gcc/cp/ChangeLog:

> >

> >         PR c++/95319

> >         * decl.c (reshape_init_array_1): Don't reuse in overload context.

> >

> > gcc/testsuite/ChangeLog:

> >

> >         PR c++/95319

> >         * g++.dg/cpp0x/initlist-array12.C: New test.

> 

> I got

> 

> FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++14 (test for excess errors)

> FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++17 (test for excess errors)

> FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++2a (test for excess errors)


This can be fixed with the attached patch.  Jason, is it OK?

> FAIL: g++.dg/ext/tmplattr10.C  -std=c++98 (test for excess errors)


But I don't know why this one fails.

-- >8 --

	* g++.dg/cpp0x/initlist-array12.C: Fix the definition of
	initializer_list for ilp32 target.
---
 gcc/testsuite/g++.dg/cpp0x/initlist-array12.C | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array12.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array12.C
index b012e7295d5..168c5dd6492 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist-array12.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array12.C
@@ -1,10 +1,12 @@
 // PR c++/95319
 // { dg-do compile { target c++11 } }
 
+typedef decltype(sizeof(char)) size_t;
+
 namespace std {
 template <class> class initializer_list {
   int *_M_array;
-  unsigned long _M_len;
+  size_t _M_len;
 };
 template <int _Nm> struct A { typedef int _Type[_Nm]; };
 template <int _Nm> struct B { typename A<_Nm>::_Type _M_elems; };

base-commit: 3ea6977d0f1813d982743a09660eec1760e981ec
-- 
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA
Kewen.Lin via Gcc-patches May 28, 2020, 2:05 p.m. | #3
On Thu, May 28, 2020 at 6:57 AM Marek Polacek <polacek@redhat.com> wrote:
>

> On Thu, May 28, 2020 at 06:44:53AM -0700, H.J. Lu via Gcc-patches wrote:

> > On Wed, May 27, 2020 at 12:07 PM Jason Merrill via Gcc-patches

> > <gcc-patches@gcc.gnu.org> wrote:

> > >

> > > Here, when considering the two 'insert' overloads, we look for aggregate

> > > conversions from the same initializer-list to B<3> or

> > > initializer_list<B<3>>.  But since my fix for reshape_init overhead on the

> > > PR14179 testcase we reshaped the initializer-list directly, leading to an

> > > error when we then tried to reshape it differently for the second overload.

> > >

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

> > >

> > > gcc/cp/ChangeLog:

> > >

> > >         PR c++/95319

> > >         * decl.c (reshape_init_array_1): Don't reuse in overload context.

> > >

> > > gcc/testsuite/ChangeLog:

> > >

> > >         PR c++/95319

> > >         * g++.dg/cpp0x/initlist-array12.C: New test.

> >

> > I got

> >

> > FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++14 (test for excess errors)

> > FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++17 (test for excess errors)

> > FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++2a (test for excess errors)

>

> This can be fixed with the attached patch.  Jason, is it OK?

>

> > FAIL: g++.dg/ext/tmplattr10.C  -std=c++98 (test for excess errors)

>

> But I don't know why this one fails.


[hjl@gnu-cfl-2 gcc]$
/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/testsuite/g++/../../xg++
-B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/testsuite/g++/../../
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C
-m32 -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers
-fdiagnostics-color=never -fdiagnostics-urls=never -nostdinc++
-I/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/x86_64-pc-linux-gnu/32/libstdc++-v3/include/x86_64-pc-linux-gnu
-I/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/x86_64-pc-linux-gnu/32/libstdc++-v3/include
-I/export/gnu/import/git/sources/gcc/libstdc++-v3/libsupc++
-I/export/gnu/import/git/sources/gcc/libstdc++-v3/include/backward
-I/export/gnu/import/git/sources/gcc/libstdc++-v3/testsuite/util
-fmessage-length=0 -std=c++98 -pedantic-errors -Wno-long-long -S -o
tmplattr10.s
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:15:31:
error: variadic templates only available with ‘-std=c++11’ or
‘-std=gnu++11’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:16:28:
error: variadic templates only available with ‘-std=c++11’ or
‘-std=gnu++11’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:18:11:
error: expected nested-name-specifier before ‘type’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:21:31:
error: variadic templates only available with ‘-std=c++11’ or
‘-std=gnu++11’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:22:39:
error: variadic templates only available with ‘-std=c++11’ or
‘-std=gnu++11’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:24:11:
error: expected nested-name-specifier before ‘type’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:27:31:
error: variadic templates only available with ‘-std=c++11’ or
‘-std=gnu++11’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:28:38:
error: variadic templates only available with ‘-std=c++11’ or
‘-std=gnu++11’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:30:11:
error: expected nested-name-specifier before ‘type’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:34:6:
error: ISO C++ forbids declaration of ‘wrap’ with no type
[-fpermissive]
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:34:1:
error: top-level declaration of ‘wrap’ specifies ‘auto’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:34:51:
error: trailing return type only available with ‘-std=c++11’ or
‘-std=gnu++11’
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:
In function ‘int main()’:
/export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:51:12:
error: ‘wrap’ was not declared in this scope
[hjl@gnu-cfl-2 gcc]$

-- 
H.J.
Kewen.Lin via Gcc-patches May 28, 2020, 2:16 p.m. | #4
On Thu, May 28, 2020 at 07:05:47AM -0700, H.J. Lu wrote:
> On Thu, May 28, 2020 at 6:57 AM Marek Polacek <polacek@redhat.com> wrote:

> >

> > On Thu, May 28, 2020 at 06:44:53AM -0700, H.J. Lu via Gcc-patches wrote:

> > > On Wed, May 27, 2020 at 12:07 PM Jason Merrill via Gcc-patches

> > > <gcc-patches@gcc.gnu.org> wrote:

> > > >

> > > > Here, when considering the two 'insert' overloads, we look for aggregate

> > > > conversions from the same initializer-list to B<3> or

> > > > initializer_list<B<3>>.  But since my fix for reshape_init overhead on the

> > > > PR14179 testcase we reshaped the initializer-list directly, leading to an

> > > > error when we then tried to reshape it differently for the second overload.

> > > >

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

> > > >

> > > > gcc/cp/ChangeLog:

> > > >

> > > >         PR c++/95319

> > > >         * decl.c (reshape_init_array_1): Don't reuse in overload context.

> > > >

> > > > gcc/testsuite/ChangeLog:

> > > >

> > > >         PR c++/95319

> > > >         * g++.dg/cpp0x/initlist-array12.C: New test.

> > >

> > > I got

> > >

> > > FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++14 (test for excess errors)

> > > FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++17 (test for excess errors)

> > > FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++2a (test for excess errors)

> >

> > This can be fixed with the attached patch.  Jason, is it OK?

> >

> > > FAIL: g++.dg/ext/tmplattr10.C  -std=c++98 (test for excess errors)

> >

> > But I don't know why this one fails.

> 

> [hjl@gnu-cfl-2 gcc]$

> /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/testsuite/g++/../../xg++

> -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/testsuite/g++/../../

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C

> -m32 -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers

> -fdiagnostics-color=never -fdiagnostics-urls=never -nostdinc++

> -I/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/x86_64-pc-linux-gnu/32/libstdc++-v3/include/x86_64-pc-linux-gnu

> -I/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/x86_64-pc-linux-gnu/32/libstdc++-v3/include

> -I/export/gnu/import/git/sources/gcc/libstdc++-v3/libsupc++

> -I/export/gnu/import/git/sources/gcc/libstdc++-v3/include/backward

> -I/export/gnu/import/git/sources/gcc/libstdc++-v3/testsuite/util

> -fmessage-length=0 -std=c++98 -pedantic-errors -Wno-long-long -S -o

> tmplattr10.s

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:15:31:

> error: variadic templates only available with ‘-std=c++11’ or

> ‘-std=gnu++11’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:16:28:

> error: variadic templates only available with ‘-std=c++11’ or

> ‘-std=gnu++11’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:18:11:

> error: expected nested-name-specifier before ‘type’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:21:31:

> error: variadic templates only available with ‘-std=c++11’ or

> ‘-std=gnu++11’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:22:39:

> error: variadic templates only available with ‘-std=c++11’ or

> ‘-std=gnu++11’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:24:11:

> error: expected nested-name-specifier before ‘type’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:27:31:

> error: variadic templates only available with ‘-std=c++11’ or

> ‘-std=gnu++11’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:28:38:

> error: variadic templates only available with ‘-std=c++11’ or

> ‘-std=gnu++11’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:30:11:

> error: expected nested-name-specifier before ‘type’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:34:6:

> error: ISO C++ forbids declaration of ‘wrap’ with no type

> [-fpermissive]

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:34:1:

> error: top-level declaration of ‘wrap’ specifies ‘auto’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:34:51:

> error: trailing return type only available with ‘-std=c++11’ or

> ‘-std=gnu++11’

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:

> In function ‘int main()’:

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:51:12:

> error: ‘wrap’ was not declared in this scope

> [hjl@gnu-cfl-2 gcc]$


I see, thanks.  Jason, is this one OK too, then?

Tested
make check-g++ RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} dg.exp=tmplattr10.C'

-- >8 --
This test uses C++11 features so should only run in c++11.

	* g++.dg/ext/tmplattr10.C: Only run in c++11.
---
 gcc/testsuite/g++.dg/ext/tmplattr10.C | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/ext/tmplattr10.C b/gcc/testsuite/g++.dg/ext/tmplattr10.C
index 3fb8c21ccbe..46caa070098 100644
--- a/gcc/testsuite/g++.dg/ext/tmplattr10.C
+++ b/gcc/testsuite/g++.dg/ext/tmplattr10.C
@@ -1,5 +1,5 @@
 // PR c++/95222
-// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } }
+// { dg-do compile { target { { { i?86-*-* x86_64-*-* } && ia32 } && c++11 } } }
 
 #if defined(_MSC_VER)
 #define CC_FASTCALL __fastcall

base-commit: 3ea6977d0f1813d982743a09660eec1760e981ec
-- 
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA
Kewen.Lin via Gcc-patches May 28, 2020, 3:01 p.m. | #5
On Thu, May 28, 2020 at 10:16 AM Marek Polacek <polacek@redhat.com> wrote:

> On Thu, May 28, 2020 at 07:05:47AM -0700, H.J. Lu wrote:

> > On Thu, May 28, 2020 at 6:57 AM Marek Polacek <polacek@redhat.com>

> wrote:

> > >

> > > On Thu, May 28, 2020 at 06:44:53AM -0700, H.J. Lu via Gcc-patches

> wrote:

> > > > On Wed, May 27, 2020 at 12:07 PM Jason Merrill via Gcc-patches

> > > > <gcc-patches@gcc.gnu.org> wrote:

> > > > >

> > > > > Here, when considering the two 'insert' overloads, we look for

> aggregate

> > > > > conversions from the same initializer-list to B<3> or

> > > > > initializer_list<B<3>>.  But since my fix for reshape_init

> overhead on the

> > > > > PR14179 testcase we reshaped the initializer-list directly,

> leading to an

> > > > > error when we then tried to reshape it differently for the second

> overload.

> > > > >

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

> > > > >

> > > > > gcc/cp/ChangeLog:

> > > > >

> > > > >         PR c++/95319

> > > > >         * decl.c (reshape_init_array_1): Don't reuse in overload

> context.

> > > > >

> > > > > gcc/testsuite/ChangeLog:

> > > > >

> > > > >         PR c++/95319

> > > > >         * g++.dg/cpp0x/initlist-array12.C: New test.

> > > >

> > > > I got

> > > >

> > > > FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++14 (test for excess

> errors)

> > > > FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++17 (test for excess

> errors)

> > > > FAIL: g++.dg/cpp0x/initlist-array12.C  -std=c++2a (test for excess

> errors)

> > >

> > > This can be fixed with the attached patch.  Jason, is it OK?

> > >

> > > > FAIL: g++.dg/ext/tmplattr10.C  -std=c++98 (test for excess errors)

> > >

> > > But I don't know why this one fails.

> >

> > [hjl@gnu-cfl-2 gcc]$

> >

> /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/testsuite/g++/../../xg++

> >

> -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/testsuite/g++/../../

> > /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C

> > -m32 -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers

> > -fdiagnostics-color=never -fdiagnostics-urls=never -nostdinc++

> >

> -I/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/x86_64-pc-linux-gnu/32/libstdc++-v3/include/x86_64-pc-linux-gnu

> >

> -I/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/x86_64-pc-linux-gnu/32/libstdc++-v3/include

> > -I/export/gnu/import/git/sources/gcc/libstdc++-v3/libsupc++

> > -I/export/gnu/import/git/sources/gcc/libstdc++-v3/include/backward

> > -I/export/gnu/import/git/sources/gcc/libstdc++-v3/testsuite/util

> > -fmessage-length=0 -std=c++98 -pedantic-errors -Wno-long-long -S -o

> > tmplattr10.s

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:15:31:

> > error: variadic templates only available with ‘-std=c++11’ or

> > ‘-std=gnu++11’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:16:28:

> > error: variadic templates only available with ‘-std=c++11’ or

> > ‘-std=gnu++11’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:18:11:

> > error: expected nested-name-specifier before ‘type’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:21:31:

> > error: variadic templates only available with ‘-std=c++11’ or

> > ‘-std=gnu++11’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:22:39:

> > error: variadic templates only available with ‘-std=c++11’ or

> > ‘-std=gnu++11’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:24:11:

> > error: expected nested-name-specifier before ‘type’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:27:31:

> > error: variadic templates only available with ‘-std=c++11’ or

> > ‘-std=gnu++11’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:28:38:

> > error: variadic templates only available with ‘-std=c++11’ or

> > ‘-std=gnu++11’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:30:11:

> > error: expected nested-name-specifier before ‘type’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:34:6:

> > error: ISO C++ forbids declaration of ‘wrap’ with no type

> > [-fpermissive]

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:34:1:

> > error: top-level declaration of ‘wrap’ specifies ‘auto’

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:34:51:

> > error: trailing return type only available with ‘-std=c++11’ or

> > ‘-std=gnu++11’

> > /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:

> > In function ‘int main()’:

> >

> /export/gnu/import/git/sources/gcc/gcc/testsuite/g++.dg/ext/tmplattr10.C:51:12:

> > error: ‘wrap’ was not declared in this scope

> > [hjl@gnu-cfl-2 gcc]$

>

> I see, thanks.  Jason, is this one OK too, then?

>


Yes, thanks.  I wonder what was wrong with my testing setup that I didn't
see these myself...


> Tested

> make check-g++ RUNTESTFLAGS='--target_board=unix\{-m32,-m64\}

> dg.exp=tmplattr10.C'

>

> -- >8 --

> This test uses C++11 features so should only run in c++11.

>

>         * g++.dg/ext/tmplattr10.C: Only run in c++11.

> ---

>  gcc/testsuite/g++.dg/ext/tmplattr10.C | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/gcc/testsuite/g++.dg/ext/tmplattr10.C

> b/gcc/testsuite/g++.dg/ext/tmplattr10.C

> index 3fb8c21ccbe..46caa070098 100644

> --- a/gcc/testsuite/g++.dg/ext/tmplattr10.C

> +++ b/gcc/testsuite/g++.dg/ext/tmplattr10.C

> @@ -1,5 +1,5 @@

>  // PR c++/95222

> -// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } }

> +// { dg-do compile { target { { { i?86-*-* x86_64-*-* } && ia32 } &&

> c++11 } } }

>

>  #if defined(_MSC_VER)

>  #define CC_FASTCALL __fastcall

>

> base-commit: 3ea6977d0f1813d982743a09660eec1760e981ec

> --

> Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA

>

>

Patch

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5476965996b..56571e39570 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6029,8 +6029,10 @@  reshape_init_array_1 (tree elt_type, tree max_index, reshape_iter *d,
 
   /* The initializer for an array is always a CONSTRUCTOR.  If this is the
      outermost CONSTRUCTOR and the element type is non-aggregate, we don't need
-     to build a new one.  */
+     to build a new one.  But don't reuse if not complaining; if this is
+     tentative, we might also reshape to another type (95319).  */
   bool reuse = (first_initializer_p
+		&& (complain & tf_error)
 		&& !CP_AGGREGATE_TYPE_P (elt_type)
 		&& !TREE_SIDE_EFFECTS (first_initializer_p));
   if (reuse)
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array12.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array12.C
new file mode 100644
index 00000000000..b012e7295d5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array12.C
@@ -0,0 +1,24 @@ 
+// PR c++/95319
+// { dg-do compile { target c++11 } }
+
+namespace std {
+template <class> class initializer_list {
+  int *_M_array;
+  unsigned long _M_len;
+};
+template <int _Nm> struct A { typedef int _Type[_Nm]; };
+template <int _Nm> struct B { typename A<_Nm>::_Type _M_elems; };
+class C {
+public:
+  void insert(int, B<3>);
+  void insert(int, initializer_list<B<3>>);
+};
+} // namespace std
+int a;
+int
+main() {
+  using ArrayVector = std::C;
+  auto b = ArrayVector();
+  b.insert(a, {{2}});
+  return 0;
+}