cp_parser_range_for: use safe_push instead of quick_push (PR
authorMartin Liska <marxin@gcc.gnu.org>
Thu, 24 Nov 2016 11:26:12 +0000 (11:26 +0000)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 24 Nov 2016 11:26:12 +0000 (11:26 +0000)
PR bootstrap/78493
* parser.c (cp_parser_range_for): Use safe_push instead of quick_push.
PR bootstrap/78493
* g++.dg/cpp1z/decomp18.C: New test.

From-SVN: r242828

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/decomp18.C [new file with mode: 0644]

index 1386d4efa540269bcd769b100e279b17e0364749..20b356ff3dbe5b07dfcd11d121c88be11dd53efd 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-24  Martin Liska  <mliska@suse.cz>
+
+       PR bootstrap/78493
+       * parser.c (cp_parser_range_for): Use safe_push instead of quick_push.
+
 2016-11-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/77907
index 9da4b30f656c3c2258e545966b3606c84623a3ce..843cbe2849404b193534090793c1204a2442417a 100644 (file)
@@ -11503,8 +11503,8 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl,
              for (unsigned int i = 0; i < decomp_cnt; i++, d = DECL_CHAIN (d))
                {
                  tree name = DECL_NAME (d);
-                 names.quick_push (name);
-                 bindings.quick_push (IDENTIFIER_BINDING (name));
+                 names.safe_push (name);
+                 bindings.safe_push (IDENTIFIER_BINDING (name));
                  IDENTIFIER_BINDING (name)
                    = IDENTIFIER_BINDING (name)->previous;
                }
@@ -11513,8 +11513,8 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl,
       if (names.is_empty ())
        {
          tree name = DECL_NAME (range_decl);
-         names.quick_push (name);
-         bindings.quick_push (IDENTIFIER_BINDING (name));
+         names.safe_push (name);
+         bindings.safe_push (IDENTIFIER_BINDING (name));
          IDENTIFIER_BINDING (name) = IDENTIFIER_BINDING (name)->previous;
        }
     }
index a6e71460a1296e6bb14b9cf85b28743b91164531..99412e21d469d181b11c6ad1c6352777e7b4bc35 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR bootstrap/78493
+       * g++.dg/cpp1z/decomp18.C: New test.
+
 2016-11-23  Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>
 
        * gcc.target/aarch64/ldp_stp_1.c : Add -mcpu=generic.
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp18.C b/gcc/testsuite/g++.dg/cpp1z/decomp18.C
new file mode 100644 (file)
index 0000000..d5c68a2
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+struct A { char a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r; } a[64];
+
+void
+foo ()
+{
+  int z = 0;
+  for (auto & [ b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s ] : a)    // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+    z += b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s;
+}