re PR c++/47388 (ICE: in begin_for_stmt, at cp/semantics.c:863 with -fno-for-scope and for(;;) inside a template)
PR c++/47388 * semantics.c (begin_for_stmt): If -fno-for-scope, don't assume init must be NULL if scope is NULL. (begin_range_for_stmt): Likewise. * g++.dg/cpp0x/range-for10.C: New test. * g++.dg/template/for1.C: New test. From-SVN: r169105
This commit is contained in:
parent
abba182313
commit
95cc031fd8
5 changed files with 59 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
2011-01-21 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/47388
|
||||
* semantics.c (begin_for_stmt): If -fno-for-scope, don't
|
||||
assume init must be NULL if scope is NULL.
|
||||
(begin_range_for_stmt): Likewise.
|
||||
|
||||
2011-01-21 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/46552
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
and during the instantiation of template functions.
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||
2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
Written by Mark Mitchell (mmitchell@usa.net) based on code found
|
||||
formerly in parse.y and pt.c.
|
||||
|
||||
|
@ -860,8 +860,9 @@ begin_for_stmt (tree scope, tree init)
|
|||
|
||||
if (scope == NULL_TREE)
|
||||
{
|
||||
gcc_assert (!init);
|
||||
scope = begin_for_scope (&init);
|
||||
gcc_assert (!init || !(flag_new_for_scope > 0));
|
||||
if (!init)
|
||||
scope = begin_for_scope (&init);
|
||||
}
|
||||
FOR_INIT_STMT (r) = init;
|
||||
TREE_CHAIN (r) = scope;
|
||||
|
@ -962,8 +963,9 @@ begin_range_for_stmt (tree scope, tree init)
|
|||
|
||||
if (scope == NULL_TREE)
|
||||
{
|
||||
gcc_assert (!init);
|
||||
scope = begin_for_scope (&init);
|
||||
gcc_assert (!init || !(flag_new_for_scope > 0));
|
||||
if (!init)
|
||||
scope = begin_for_scope (&init);
|
||||
}
|
||||
|
||||
/* RANGE_FOR_STMTs do not use nor save the init tree, so we
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
2011-01-21 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/47388
|
||||
* g++.dg/cpp0x/range-for10.C: New test.
|
||||
* g++.dg/template/for1.C: New test.
|
||||
|
||||
PR middle-end/45566
|
||||
* g++.dg/tree-prof/partition3.C: New test.
|
||||
|
||||
|
|
18
gcc/testsuite/g++.dg/cpp0x/range-for10.C
Normal file
18
gcc/testsuite/g++.dg/cpp0x/range-for10.C
Normal file
|
@ -0,0 +1,18 @@
|
|||
// PR c++/47388
|
||||
// { dg-do compile }
|
||||
// { dg-options "-fno-for-scope -std=c++0x" }
|
||||
|
||||
template <int>
|
||||
void
|
||||
foo ()
|
||||
{
|
||||
int a[] = { 1, 2, 3, 4 };
|
||||
for (int i : a)
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
bar ()
|
||||
{
|
||||
foo <0> ();
|
||||
}
|
23
gcc/testsuite/g++.dg/template/for1.C
Normal file
23
gcc/testsuite/g++.dg/template/for1.C
Normal file
|
@ -0,0 +1,23 @@
|
|||
// PR c++/47388
|
||||
// { dg-do compile }
|
||||
// { dg-options "-fno-for-scope" }
|
||||
|
||||
template <int>
|
||||
void
|
||||
foo ()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
;
|
||||
for (int j = 0; j < 16; j++)
|
||||
;
|
||||
if (j != 16)
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
bar ()
|
||||
{
|
||||
foo <0> ();
|
||||
}
|
Loading…
Add table
Reference in a new issue