PR C++/63149

Message ID CAAcHv8fXLz5MNiEye6KS0AJbpUt+pihU_+WArHqxF9YbGqwKAg@mail.gmail.com
State New
Headers show
Series
  • PR C++/63149
Related show

Commit Message

Nina Dinka Ranns June 4, 2019, 4:36 p.m.
Tested on Linux x86_64

2019-06-04  Nina Dinka Ranns  <dinka.ranns@gmail.com>
    gcc/cp

     PR c++/63149
    * pt.c (listify_autos): use non cv qualified auto_node in
std::initializer_list<auto>

     testsuite/

     PR c++/63149
    * g++.dg/cpp0x/initlist-deduce.C: New

Comments

Paolo Carlini June 4, 2019, 4:53 p.m. | #1
Hi,

On 04/06/19 18:36, Nina Dinka Ranns wrote:
> +// Test for PR63149

> +// { dg-do run { target c++11 } }


Are you sure you want a dg-do run?

Paolo.
Nina Dinka Ranns June 4, 2019, 7:26 p.m. | #2
Good point, dg-do compile is sufficient to demonstrate the issue.
Amended, new patch attached.
Thanks,
Nina

On Tue, 4 Jun 2019 at 17:53, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>

> Hi,

>

> On 04/06/19 18:36, Nina Dinka Ranns wrote:

> > +// Test for PR63149

> > +// { dg-do run { target c++11 } }

>

> Are you sure you want a dg-do run?

>

> Paolo.

>

>
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 271709)
+++ gcc/cp/pt.c	(working copy)
@@ -26836,7 +26836,7 @@
 static tree
 listify_autos (tree type, tree auto_node)
 {
-  tree init_auto = listify (auto_node);
+  tree init_auto = listify (strip_top_quals(auto_node));
   tree argvec = make_tree_vec (1);
   TREE_VEC_ELT (argvec, 0) = init_auto;
   if (processing_template_decl)
Index: gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(working copy)
@@ -0,0 +1,12 @@
+// Test for PR63149
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+const auto r = { 1, 2, 3 };
+using X = decltype(r);
+using X = const std::initializer_list<int>;
+
+int main()
+{
+}
Paolo Carlini June 4, 2019, 7:45 p.m. | #3
Hi,

On 04/06/19 21:26, Nina Dinka Ranns wrote:
> Good point, dg-do compile is sufficient to demonstrate the issue.


I agree.

A couple of additional nits, sorry for mentioning only now.

>

> C++63149_2.diff

>

> Index: gcc/cp/pt.c

> ===================================================================

> --- gcc/cp/pt.c	(revision 271709)

> +++ gcc/cp/pt.c	(working copy)

> @@ -26836,7 +26836,7 @@

>   static tree

>   listify_autos (tree type, tree auto_node)

>   {

> -  tree init_auto = listify (auto_node);

> +  tree init_auto = listify (strip_top_quals(auto_node));


You want a space after strip_top_quals.

>     tree argvec = make_tree_vec (1);

>     TREE_VEC_ELT (argvec, 0) = init_auto;

>     if (processing_template_decl)

> Index: gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C

> ===================================================================

> --- gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(nonexistent)

> +++ gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(working copy)

> @@ -0,0 +1,12 @@

> +// Test for PR63149

> +// { dg-do compile { target c++11 } }

> +

> +#include <initializer_list>

> +

> +const auto r = { 1, 2, 3 };

> +using X = decltype(r);

> +using X = const std::initializer_list<int>;

> +

> +int main()

> +{

> +}


With dg-do compile you don't need a main anymore.

I seem to remember also a couple of minor formatting issues in the 
ChangeLog entry: just harmonize the format with everything else you find 
in the ChangeLog, in terms of the usual trivial details: upper cases, 
line lenghts and line wraps, etc.

Paolo.
Jakub Jelinek June 4, 2019, 8:04 p.m. | #4
On Tue, Jun 04, 2019 at 08:26:58PM +0100, Nina Dinka Ranns wrote:

ChangeLog entry is missing.

> Index: gcc/cp/pt.c

> ===================================================================

> --- gcc/cp/pt.c	(revision 271709)

> +++ gcc/cp/pt.c	(working copy)

> @@ -26836,7 +26836,7 @@

>  static tree

>  listify_autos (tree type, tree auto_node)

>  {

> -  tree init_auto = listify (auto_node);

> +  tree init_auto = listify (strip_top_quals(auto_node));


There should be space before ( in the function call.

>    tree argvec = make_tree_vec (1);

>    TREE_VEC_ELT (argvec, 0) = init_auto;

>    if (processing_template_decl)

> Index: gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C

> ===================================================================

> --- gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(nonexistent)

> +++ gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(working copy)

> @@ -0,0 +1,12 @@

> +// Test for PR63149

> +// { dg-do compile { target c++11 } }

> +

> +#include <initializer_list>

> +

> +const auto r = { 1, 2, 3 };

> +using X = decltype(r);

> +using X = const std::initializer_list<int>;

> +

> +int main()

> +{

> +}


No need for main in dg-do compile test if it is not needed for what the test
wants to test.

	Jakub
Nina Dinka Ranns June 5, 2019, 9:24 a.m. | #5
Hi both,
Addressing all comments in this e-mail, as some are duplicate.

On Tue, 4 Jun 2019 at 20:45, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>

> Hi,

>

> On 04/06/19 21:26, Nina Dinka Ranns wrote:

>

> Good point, dg-do compile is sufficient to demonstrate the issue.

>

> I agree.

>

> A couple of additional nits, sorry for mentioning only now.

>

>

> C++63149_2.diff

>

> Index: gcc/cp/pt.c

> ===================================================================

> --- gcc/cp/pt.c (revision 271709)

> +++ gcc/cp/pt.c (working copy)

> @@ -26836,7 +26836,7 @@

>  static tree

>  listify_autos (tree type, tree auto_node)

>  {

> -  tree init_auto = listify (auto_node);

> +  tree init_auto = listify (strip_top_quals(auto_node));

>

> You want a space after strip_top_quals.


fixed.

>

>    tree argvec = make_tree_vec (1);

>    TREE_VEC_ELT (argvec, 0) = init_auto;

>    if (processing_template_decl)

> Index: gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C

> ===================================================================

> --- gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C (nonexistent)

> +++ gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C (working copy)

> @@ -0,0 +1,12 @@

> +// Test for PR63149

> +// { dg-do compile { target c++11 } }

> +

> +#include <initializer_list>

> +

> +const auto r = { 1, 2, 3 };

> +using X = decltype(r);

> +using X = const std::initializer_list<int>;

> +

> +int main()

> +{

> +}

>

> With dg-do compile you don't need a main anymore.

>

fixed

> I seem to remember also a couple of minor formatting issues in the ChangeLog entry: just harmonize the format with everything else you find in the ChangeLog, in terms of the usual trivial details: upper cases, line lenghts and line wraps, etc.

>


Below is the amended change log. If there is anything else off, I
would need specifics as I've made all the changes I could spot myself.
:)

Thanks,
Nina

2019-06-04  Nina Dinka Ranns  <dinka.ranns@gmail.com>
    gcc/cp

    PR C++/63149
    * pt.c (listify_autos): Use non cv qualified auto_node in
    std::initializer_list<auto>.

    testsuite/

    PR C++/63149
    * g++.dg/cpp0x/initlist-deduce.C: New test.
Nina Dinka Ranns June 5, 2019, 9:34 a.m. | #6
yes, I forgot to attach the latest patch. :)

On Wed, 5 Jun 2019 at 10:24, Nina Dinka Ranns <dinka.ranns@gmail.com> wrote:
>

> Hi both,

> Addressing all comments in this e-mail, as some are duplicate.

>

> On Tue, 4 Jun 2019 at 20:45, Paolo Carlini <paolo.carlini@oracle.com> wrote:

> >

> > Hi,

> >

> > On 04/06/19 21:26, Nina Dinka Ranns wrote:

> >

> > Good point, dg-do compile is sufficient to demonstrate the issue.

> >

> > I agree.

> >

> > A couple of additional nits, sorry for mentioning only now.

> >

> >

> > C++63149_2.diff

> >

> > Index: gcc/cp/pt.c

> > ===================================================================

> > --- gcc/cp/pt.c (revision 271709)

> > +++ gcc/cp/pt.c (working copy)

> > @@ -26836,7 +26836,7 @@

> >  static tree

> >  listify_autos (tree type, tree auto_node)

> >  {

> > -  tree init_auto = listify (auto_node);

> > +  tree init_auto = listify (strip_top_quals(auto_node));

> >

> > You want a space after strip_top_quals.

>

> fixed.

>

> >

> >    tree argvec = make_tree_vec (1);

> >    TREE_VEC_ELT (argvec, 0) = init_auto;

> >    if (processing_template_decl)

> > Index: gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C

> > ===================================================================

> > --- gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C (nonexistent)

> > +++ gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C (working copy)

> > @@ -0,0 +1,12 @@

> > +// Test for PR63149

> > +// { dg-do compile { target c++11 } }

> > +

> > +#include <initializer_list>

> > +

> > +const auto r = { 1, 2, 3 };

> > +using X = decltype(r);

> > +using X = const std::initializer_list<int>;

> > +

> > +int main()

> > +{

> > +}

> >

> > With dg-do compile you don't need a main anymore.

> >

> fixed

>

> > I seem to remember also a couple of minor formatting issues in the ChangeLog entry: just harmonize the format with everything else you find in the ChangeLog, in terms of the usual trivial details: upper cases, line lenghts and line wraps, etc.

> >

>

> Below is the amended change log. If there is anything else off, I

> would need specifics as I've made all the changes I could spot myself.

> :)

>

> Thanks,

> Nina

>

> 2019-06-04  Nina Dinka Ranns  <dinka.ranns@gmail.com>

>     gcc/cp

>

>     PR C++/63149

>     * pt.c (listify_autos): Use non cv qualified auto_node in

>     std::initializer_list<auto>.

>

>     testsuite/

>

>     PR C++/63149

>     * g++.dg/cpp0x/initlist-deduce.C: New test.
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 271709)
+++ gcc/cp/pt.c	(working copy)
@@ -26836,7 +26836,7 @@
 static tree
 listify_autos (tree type, tree auto_node)
 {
-  tree init_auto = listify (auto_node);
+  tree init_auto = listify (strip_top_quals (auto_node));
   tree argvec = make_tree_vec (1);
   TREE_VEC_ELT (argvec, 0) = init_auto;
   if (processing_template_decl)
Index: gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(working copy)
@@ -0,0 +1,8 @@
+// Test for PR63149
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+const auto r = { 1, 2, 3 };
+using X = decltype(r);
+using X = const std::initializer_list<int>;
Marek Polacek June 5, 2019, 12:39 p.m. | #7
On Wed, Jun 05, 2019 at 10:34:05AM +0100, Nina Dinka Ranns wrote:
> >     PR C++/63149

> >     * pt.c (listify_autos): Use non cv qualified auto_node in

> >     std::initializer_list<auto>.

> >

> >     testsuite/

> >

> >     PR C++/63149


"c++" instead of "C++", thought I don't think anyone would mind.

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


You're actually adding initlist-deduce2.C.

Marek
Jakub Jelinek June 5, 2019, 12:50 p.m. | #8
On Wed, Jun 05, 2019 at 08:39:56AM -0400, Marek Polacek wrote:
> On Wed, Jun 05, 2019 at 10:34:05AM +0100, Nina Dinka Ranns wrote:

> > >     PR C++/63149

> > >     * pt.c (listify_autos): Use non cv qualified auto_node in

> > >     std::initializer_list<auto>.

> > >

> > >     testsuite/

> > >

> > >     PR C++/63149

> 

> "c++" instead of "C++", thought I don't think anyone would mind.


I would, I have scripts that grab the PR strings from ChangeLog entries
and need to fix stuff by hand if it is incorrect like this (or if people
forget to use the component/ part altogether).

	Jakub
Marek Polacek June 5, 2019, 12:59 p.m. | #9
On Wed, Jun 05, 2019 at 02:50:54PM +0200, Jakub Jelinek wrote:
> On Wed, Jun 05, 2019 at 08:39:56AM -0400, Marek Polacek wrote:

> > On Wed, Jun 05, 2019 at 10:34:05AM +0100, Nina Dinka Ranns wrote:

> > > >     PR C++/63149

> > > >     * pt.c (listify_autos): Use non cv qualified auto_node in

> > > >     std::initializer_list<auto>.

> > > >

> > > >     testsuite/

> > > >

> > > >     PR C++/63149

> > 

> > "c++" instead of "C++", thought I don't think anyone would mind.

> 

> I would, I have scripts that grab the PR strings from ChangeLog entries

> and need to fix stuff by hand if it is incorrect like this (or if people

> forget to use the component/ part altogether).


Fair enough.  Nina, please adjust that too, then.

Marek
Nina Dinka Ranns June 5, 2019, 5:29 p.m. | #10
Ack. Amended change log is below. Changes are :
* changed C++ -> c++
* fixed the name of added test

There are no changes in the diff, but I attached it to this e-mail for
reference.

Thanks,
Nina

2019-06-04  Nina Dinka Ranns  <dinka.ranns@gmail.com>
    gcc/cp

    PR c++/63149
    * pt.c (listify_autos): Use non cv qualified auto_node in
    std::initializer_list<auto>.

    testsuite/

    PR c++/63149
    * g++.dg/cpp0x/initlist-deduce2.C: New test.





On Wed, 5 Jun 2019 at 13:59, Marek Polacek <polacek@redhat.com> wrote:
>

> On Wed, Jun 05, 2019 at 02:50:54PM +0200, Jakub Jelinek wrote:

> > On Wed, Jun 05, 2019 at 08:39:56AM -0400, Marek Polacek wrote:

> > > On Wed, Jun 05, 2019 at 10:34:05AM +0100, Nina Dinka Ranns wrote:

> > > > >     PR C++/63149

> > > > >     * pt.c (listify_autos): Use non cv qualified auto_node in

> > > > >     std::initializer_list<auto>.

> > > > >

> > > > >     testsuite/

> > > > >

> > > > >     PR C++/63149

> > >

> > > "c++" instead of "C++", thought I don't think anyone would mind.

> >

> > I would, I have scripts that grab the PR strings from ChangeLog entries

> > and need to fix stuff by hand if it is incorrect like this (or if people

> > forget to use the component/ part altogether).

>

> Fair enough.  Nina, please adjust that too, then.

>

> Marek
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 271709)
+++ gcc/cp/pt.c	(working copy)
@@ -26836,7 +26836,7 @@
 static tree
 listify_autos (tree type, tree auto_node)
 {
-  tree init_auto = listify (auto_node);
+  tree init_auto = listify (strip_top_quals (auto_node));
   tree argvec = make_tree_vec (1);
   TREE_VEC_ELT (argvec, 0) = init_auto;
   if (processing_template_decl)
Index: gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(working copy)
@@ -0,0 +1,8 @@
+// Test for PR63149
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+const auto r = { 1, 2, 3 };
+using X = decltype(r);
+using X = const std::initializer_list<int>;
Jason Merrill June 5, 2019, 6:19 p.m. | #11
On 6/5/19 1:29 PM, Nina Dinka Ranns wrote:
> Ack. Amended change log is below. Changes are :

> * changed C++ -> c++

> * fixed the name of added test

> 

> There are no changes in the diff, but I attached it to this e-mail for

> reference.


Applied, thanks!

For future reference it's also customary to add a bit of discussion of 
the rationale for the patch.  Also, please include the word "PATCH" on 
the subject line.

Jason
Nina Dinka Ranns June 5, 2019, 7:12 p.m. | #12
On Wed, 5 Jun 2019 at 19:19, Jason Merrill <jason@redhat.com> wrote:

> On 6/5/19 1:29 PM, Nina Dinka Ranns wrote:

> > Ack. Amended change log is below. Changes are :

> > * changed C++ -> c++

> > * fixed the name of added test

> >

> > There are no changes in the diff, but I attached it to this e-mail for

> > reference.

>

> Applied, thanks!

>

> For future reference it's also customary to add a bit of discussion of

> the rationale for the patch.  Also, please include the word "PATCH" on

> the subject line.



Noted.
Thank you,
Nina


>

> Jason

>

Patch

Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 271709)
+++ gcc/cp/pt.c	(working copy)
@@ -26836,7 +26836,7 @@ 
 static tree
 listify_autos (tree type, tree auto_node)
 {
-  tree init_auto = listify (auto_node);
+  tree init_auto = listify (strip_top_quals(auto_node));
   tree argvec = make_tree_vec (1);
   TREE_VEC_ELT (argvec, 0) = init_auto;
   if (processing_template_decl)
Index: gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C	(working copy)
@@ -0,0 +1,12 @@ 
+// Test for PR63149
+// { dg-do run { target c++11 } }
+
+#include <initializer_list>
+
+const auto r = { 1, 2, 3 };
+using X = decltype(r);
+using X = const std::initializer_list<int>;
+
+int main()
+{
+}