Commit 95cc031f by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/47388 (ICE: in begin_for_stmt, at cp/semantics.c:863 with…

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
parent abba1823
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> 2011-01-21 Jason Merrill <jason@redhat.com>
PR c++/46552 PR c++/46552
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
and during the instantiation of template functions. and during the instantiation of template functions.
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 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 Written by Mark Mitchell (mmitchell@usa.net) based on code found
formerly in parse.y and pt.c. formerly in parse.y and pt.c.
...@@ -860,8 +860,9 @@ begin_for_stmt (tree scope, tree init) ...@@ -860,8 +860,9 @@ begin_for_stmt (tree scope, tree init)
if (scope == NULL_TREE) if (scope == NULL_TREE)
{ {
gcc_assert (!init); gcc_assert (!init || !(flag_new_for_scope > 0));
scope = begin_for_scope (&init); if (!init)
scope = begin_for_scope (&init);
} }
FOR_INIT_STMT (r) = init; FOR_INIT_STMT (r) = init;
TREE_CHAIN (r) = scope; TREE_CHAIN (r) = scope;
...@@ -962,8 +963,9 @@ begin_range_for_stmt (tree scope, tree init) ...@@ -962,8 +963,9 @@ begin_range_for_stmt (tree scope, tree init)
if (scope == NULL_TREE) if (scope == NULL_TREE)
{ {
gcc_assert (!init); gcc_assert (!init || !(flag_new_for_scope > 0));
scope = begin_for_scope (&init); if (!init)
scope = begin_for_scope (&init);
} }
/* RANGE_FOR_STMTs do not use nor save the init tree, so we /* RANGE_FOR_STMTs do not use nor save the init tree, so we
......
2011-01-21 Jakub Jelinek <jakub@redhat.com> 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 PR middle-end/45566
* g++.dg/tree-prof/partition3.C: New test. * g++.dg/tree-prof/partition3.C: New test.
......
// 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> ();
}
// 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> ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment