]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/63149 - wrong auto deduction from braced-init-list
authorNina Dinka Ranns <dinka.ranns@gmail.com>
Fri, 19 Jul 2019 08:52:50 +0000 (08:52 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 19 Jul 2019 08:52:50 +0000 (04:52 -0400)
2019-06-04  Nina Dinka Ranns  <dinka.ranns@gmail.com>

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

    testsuite/
    * g++.dg/cpp0x/initlist-deduce2.C: New test.

From-SVN: r273595

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C [new file with mode: 0644]

index 6d2f73106baee86f70c3ba2b4441e66713be23d8..71bddd7d40d0441181de9abc95d25c7230f57834 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-19  Nina Dinka Ranns  <dinka.ranns@gmail.com>
+
+       PR c++/63149 - Wrong auto deduction from braced-init-list.
+       * pt.c (listify_autos): use non cv qualified auto_node in
+       std::initializer_list<auto>.
+
 2019-07-01  Marek Polacek  <polacek@redhat.com>
 
        Backported from mainline
index 426700a7211b8fe0d3c7efee53ae18e51881c8ed..b9137aa0a8290498da6111964ff2632eaf0ae978 100644 (file)
@@ -26851,7 +26851,7 @@ listify (tree arg)
 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)
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-deduce2.C
new file mode 100644 (file)
index 0000000..dbf68a4
--- /dev/null
@@ -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>;